ionic-team / ionic-team/ionic-cli

ionic/cli commands in a (react based) monorepo aren't working consistently

Aberta
#4,826 0 comentários 0 reações 0 responsáveis Ver no GitHub
triage
Linguagem predominante
TypeScript
Estrelas
2k
Forks
682
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

**Description:**
ionic cli commands in a (react based) monorepo aren't working consistently.

**Steps to Reproduce:**
As per instructions, I've defined the `ionic.config.json` file at the root of my (Nx) monorepo, which has the following structure:

```
apps/
-- myapp/
dist/
-- apps/
-- myapp/
libs/
node_modules/
ionic.config.json
package.json
```
This is `ionic.config.json`:
```
{
"defaultProject": "myapp",
"projects": {
"reactr": {
"name": "myapp",
"integrations": {
"capacitor": {}
},
"type": "react",
"root": "apps/myapp"
}
}
}

```
Issues:
1. ionic cli searches the app root for custom build scripts
`ionic serve` doesn't work, as I'm not using react-scripts. Fine.
I tried adding `"ionic:serve": "npm start"` to my root `package.json` to no avail. I had to create `apps/myapp/package.json` and add the scripts there. Not too bad, but not intuitive and it tooks some trial & error.

2. `ionic cap` commands searches the app root for node_modules!
ionic capacitor is searched in `apps/myapp/node_modules/` instead of the root `node_modules`, so I've had to also add `@capacitor/core` and `@capacitor/cli` to `apps/myapp/package.json`, effectively duplicating these dependencies (in monorepos you want only 1 node_modules usually).

3. `ionic cap open ` must be launched in the app root
While ionic serve/build work from the monorepo root, ionic cap must be launched from the app's root, despite having specified the app's root in ionic.config.json

**My `ionic info`:**
```
Ionic:

Ionic CLI : 6.19.0 (C:\Users\andre\AppData\Roaming\nvm\v14.18.3\node_modules\@ionic\cli)
Ionic Framework : @ionic/react 6.0.11 (C:\Users\andre\Code\reac-tr\node_modules\@ionic\react)

Capacitor:

Capacitor CLI : 3.4.3
@capacitor/android : 3.4.3
@capacitor/core : 3.4.3
@capacitor/ios : 3.4.3

Utility:

cordova-res : 0.15.4
native-run : 1.5.0

System:

NodeJS : v14.18.3 (C:\Program Files\nodejs\node.exe)
npm : 6.14.15
OS : Windows 10
```

**Other Information:**
Nx monorepo with a react app

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Start by reproducing the three reported behaviors from the Nx monorepo root using ionic.config.json, the root package.json, and apps/myapp/package.json. Compare ionic serve/build with ionic cap commands and verify whether the configured app root and root node_modules are handled consistently; done means the documented commands work from the monorepo root without duplicated dependencies.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
react, typescript
Domínio
cli, tooling
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
25/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.