Skip to content

Commit ec5a5e6

Browse files
jaysooleosvelperezndcunningham
authored
feat(react): update app and lib generators to support new TS solution setup (#28808)
This PR updates app and lib generators in the following packages such that they will generate files with the TS solution setup if it is detected. - `@nx/react` - `@nx/next` - `@nx/remix` - `@nx/expo` - `@nx/react-native` React apps and libs will be linked using npm/pnpm/yarn/bun workspaces feature rather than through tsconfig paths. This means that local aliases like `@/` will work with Next.js and Remix apps. Note: This will be behind `--workspaces` flag when using `npx create-nx-workspace` and choosing React stack. If you use the None/TS stack then adding plugins like `nx add @nx/react` then generating apps, it will automatically pick up the new TS solution setup. <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior React generators are not compatible with TS solution setup (i.e. workspaces + TS project references). ## Expected Behavior React generators work with new TS solution setup (Plain, Next.js, Remix, Expo, React Native). ## Related Issue(s) #28322 --------- Co-authored-by: Leosvel Pérez Espinosa <[email protected]> Co-authored-by: Nicholas Cunningham <[email protected]>
1 parent 2cb58b9 commit ec5a5e6

File tree

158 files changed

+3457
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+3457
-658
lines changed

docs/generated/cli/create-nx-workspace.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
2828
| `--defaultBase` | string | Default base to use for new projects. (Default: `main`) |
2929
| `--docker` | boolean | Generate a Dockerfile for the Node API. |
3030
| `--e2eTestRunner` | `playwright`, `cypress`, `none` | Test runner to use for end to end (E2E) tests. |
31+
| `--formatter` | string | Code formatter to use. |
3132
| `--framework` | string | Framework option to be used with certain stacks. |
3233
| `--help` | boolean | Show help. |
3334
| `--interactive` | boolean | Enable interactive mode with presets. (Default: `true`) |
@@ -45,6 +46,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
4546
| `--style` | string | Stylesheet type to be used with certain stacks. |
4647
| `--useGitHub` | boolean | Will you be using GitHub as your git hosting provider? (Default: `false`) |
4748
| `--version` | boolean | Show version number. |
49+
| `--workspaces` | boolean | Use package manager workspaces. (Default: `false`) |
4850
| `--workspaceType` | `integrated`, `package-based`, `standalone` | The type of workspace to create. |
4951

5052
## Presets

docs/generated/packages/expo/generators/application.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@
4444
"description": "The tool to use for running lint checks.",
4545
"type": "string",
4646
"enum": ["eslint", "none"],
47-
"default": "eslint"
47+
"default": "none",
48+
"x-priority": "important"
4849
},
4950
"unitTestRunner": {
5051
"type": "string",
5152
"enum": ["jest", "none"],
5253
"description": "Test runner to use for unit tests",
53-
"default": "jest"
54+
"default": "none",
55+
"x-priority": "important"
5456
},
5557
"tags": {
5658
"type": "string",
@@ -71,7 +73,8 @@
7173
"description": "Adds the specified e2e test runner",
7274
"type": "string",
7375
"enum": ["playwright", "cypress", "detox", "none"],
74-
"default": "none"
76+
"default": "none",
77+
"x-priority": "important"
7578
},
7679
"standaloneConfig": {
7780
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",

docs/generated/packages/expo/generators/library.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
"description": "The tool to use for running lint checks.",
3030
"type": "string",
3131
"enum": ["eslint", "none"],
32-
"default": "eslint"
32+
"default": "none",
33+
"x-prompt": "Which linter would you like to use?",
34+
"x-priority": "important"
3335
},
3436
"unitTestRunner": {
3537
"type": "string",
3638
"enum": ["jest", "none"],
3739
"description": "Test runner to use for unit tests.",
38-
"default": "jest"
40+
"default": "none",
41+
"x-priority": "important"
3942
},
4043
"tags": {
4144
"type": "string",

docs/generated/packages/next/generators/application.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@
6363
"linter": {
6464
"description": "The tool to use for running lint checks.",
6565
"type": "string",
66-
"enum": ["eslint"],
67-
"default": "eslint"
66+
"enum": ["eslint", "none"],
67+
"default": "none",
68+
"x-prompt": "Which linter would you like to use?",
69+
"x-priority": "important"
6870
},
6971
"skipFormat": {
7072
"description": "Skip formatting files.",
@@ -76,7 +78,9 @@
7678
"type": "string",
7779
"enum": ["jest", "none"],
7880
"description": "Test runner to use for unit tests.",
79-
"default": "jest"
81+
"default": "none",
82+
"x-prompt": "What unit test runner should be used?",
83+
"x-priority": "important"
8084
},
8185
"e2eTestRunner": {
8286
"type": "string",

docs/generated/packages/next/generators/library.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,29 @@
5656
]
5757
}
5858
},
59+
"bundler": {
60+
"type": "string",
61+
"description": "The bundler to use. Choosing 'none' means this library is not buildable.",
62+
"enum": ["none", "vite", "rollup"],
63+
"default": "none",
64+
"x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
65+
"x-priority": "important"
66+
},
5967
"linter": {
6068
"description": "The tool to use for running lint checks.",
6169
"type": "string",
62-
"enum": ["eslint"],
63-
"default": "eslint"
70+
"enum": ["eslint", "none"],
71+
"default": "none",
72+
"x-prompt": "Which linter would you like to use?",
73+
"x-priority": "important"
6474
},
6575
"unitTestRunner": {
6676
"type": "string",
6777
"enum": ["vitest", "jest", "none"],
6878
"description": "Test runner to use for unit tests.",
69-
"default": "vitest"
79+
"default": "none",
80+
"x-prompt": "What unit test runner should be used?",
81+
"x-priority": "important"
7082
},
7183
"tags": {
7284
"type": "string",
@@ -99,7 +111,8 @@
99111
"buildable": {
100112
"type": "boolean",
101113
"default": false,
102-
"description": "Generate a buildable library."
114+
"description": "Generate a buildable library that uses rollup to bundle.",
115+
"x-deprecated": "Use the `bundler` option for greater control (none, vite, rollup)."
103116
},
104117
"importPath": {
105118
"type": "string",

docs/generated/packages/nx/documents/create-nx-workspace.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
2828
| `--defaultBase` | string | Default base to use for new projects. (Default: `main`) |
2929
| `--docker` | boolean | Generate a Dockerfile for the Node API. |
3030
| `--e2eTestRunner` | `playwright`, `cypress`, `none` | Test runner to use for end to end (E2E) tests. |
31+
| `--formatter` | string | Code formatter to use. |
3132
| `--framework` | string | Framework option to be used with certain stacks. |
3233
| `--help` | boolean | Show help. |
3334
| `--interactive` | boolean | Enable interactive mode with presets. (Default: `true`) |
@@ -45,6 +46,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
4546
| `--style` | string | Stylesheet type to be used with certain stacks. |
4647
| `--useGitHub` | boolean | Will you be using GitHub as your git hosting provider? (Default: `false`) |
4748
| `--version` | boolean | Show version number. |
49+
| `--workspaces` | boolean | Use package manager workspaces. (Default: `false`) |
4850
| `--workspaceType` | `integrated`, `package-based`, `standalone` | The type of workspace to create. |
4951

5052
## Presets

docs/generated/packages/react-native/generators/application.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@
4444
"description": "The tool to use for running lint checks.",
4545
"type": "string",
4646
"enum": ["eslint", "none"],
47-
"default": "eslint"
47+
"default": "none",
48+
"x-priority": "important"
4849
},
4950
"unitTestRunner": {
5051
"type": "string",
5152
"enum": ["jest", "none"],
5253
"description": "Test runner to use for unit tests",
53-
"default": "jest"
54+
"default": "none",
55+
"x-priority": "important"
5456
},
5557
"tags": {
5658
"type": "string",
@@ -71,7 +73,8 @@
7173
"description": "Adds the specified e2e test runner.",
7274
"type": "string",
7375
"enum": ["playwright", "cypress", "detox", "none"],
74-
"default": "playwright"
76+
"default": "none",
77+
"x-priority": "important"
7578
},
7679
"install": {
7780
"type": "boolean",

0 commit comments

Comments
 (0)