Skip to content

Commit

Permalink
feat(react): update app and lib generators to support new TS solution…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
3 people authored Nov 29, 2024
1 parent 2cb58b9 commit ec5a5e6
Show file tree
Hide file tree
Showing 158 changed files with 3,457 additions and 658 deletions.
2 changes: 2 additions & 0 deletions docs/generated/cli/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--defaultBase` | string | Default base to use for new projects. (Default: `main`) |
| `--docker` | boolean | Generate a Dockerfile for the Node API. |
| `--e2eTestRunner` | `playwright`, `cypress`, `none` | Test runner to use for end to end (E2E) tests. |
| `--formatter` | string | Code formatter to use. |
| `--framework` | string | Framework option to be used with certain stacks. |
| `--help` | boolean | Show help. |
| `--interactive` | boolean | Enable interactive mode with presets. (Default: `true`) |
Expand All @@ -45,6 +46,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--style` | string | Stylesheet type to be used with certain stacks. |
| `--useGitHub` | boolean | Will you be using GitHub as your git hosting provider? (Default: `false`) |
| `--version` | boolean | Show version number. |
| `--workspaces` | boolean | Use package manager workspaces. (Default: `false`) |
| `--workspaceType` | `integrated`, `package-based`, `standalone` | The type of workspace to create. |

## Presets
Expand Down
9 changes: 6 additions & 3 deletions docs/generated/packages/expo/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests",
"default": "jest"
"default": "none",
"x-priority": "important"
},
"tags": {
"type": "string",
Expand All @@ -71,7 +73,8 @@
"description": "Adds the specified e2e test runner",
"type": "string",
"enum": ["playwright", "cypress", "detox", "none"],
"default": "none"
"default": "none",
"x-priority": "important"
},
"standaloneConfig": {
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
Expand Down
7 changes: 5 additions & 2 deletions docs/generated/packages/expo/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
"default": "none",
"x-priority": "important"
},
"tags": {
"type": "string",
Expand Down
10 changes: 7 additions & 3 deletions docs/generated/packages/next/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"skipFormat": {
"description": "Skip formatting files.",
Expand All @@ -76,7 +78,9 @@
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "jest"
"default": "none",
"x-prompt": "What unit test runner should be used?",
"x-priority": "important"
},
"e2eTestRunner": {
"type": "string",
Expand Down
21 changes: 17 additions & 4 deletions docs/generated/packages/next/generators/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,29 @@
]
}
},
"bundler": {
"type": "string",
"description": "The bundler to use. Choosing 'none' means this library is not buildable.",
"enum": ["none", "vite", "rollup"],
"default": "none",
"x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
"x-priority": "important"
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint"],
"default": "eslint"
"enum": ["eslint", "none"],
"default": "none",
"x-prompt": "Which linter would you like to use?",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["vitest", "jest", "none"],
"description": "Test runner to use for unit tests.",
"default": "vitest"
"default": "none",
"x-prompt": "What unit test runner should be used?",
"x-priority": "important"
},
"tags": {
"type": "string",
Expand Down Expand Up @@ -99,7 +111,8 @@
"buildable": {
"type": "boolean",
"default": false,
"description": "Generate a buildable library."
"description": "Generate a buildable library that uses rollup to bundle.",
"x-deprecated": "Use the `bundler` option for greater control (none, vite, rollup)."
},
"importPath": {
"type": "string",
Expand Down
2 changes: 2 additions & 0 deletions docs/generated/packages/nx/documents/create-nx-workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--defaultBase` | string | Default base to use for new projects. (Default: `main`) |
| `--docker` | boolean | Generate a Dockerfile for the Node API. |
| `--e2eTestRunner` | `playwright`, `cypress`, `none` | Test runner to use for end to end (E2E) tests. |
| `--formatter` | string | Code formatter to use. |
| `--framework` | string | Framework option to be used with certain stacks. |
| `--help` | boolean | Show help. |
| `--interactive` | boolean | Enable interactive mode with presets. (Default: `true`) |
Expand All @@ -45,6 +46,7 @@ Install `create-nx-workspace` globally to invoke the command directly, or use `n
| `--style` | string | Stylesheet type to be used with certain stacks. |
| `--useGitHub` | boolean | Will you be using GitHub as your git hosting provider? (Default: `false`) |
| `--version` | boolean | Show version number. |
| `--workspaces` | boolean | Use package manager workspaces. (Default: `false`) |
| `--workspaceType` | `integrated`, `package-based`, `standalone` | The type of workspace to create. |

## Presets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
"default": "none",
"x-priority": "important"
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "none"],
"description": "Test runner to use for unit tests",
"default": "jest"
"default": "none",
"x-priority": "important"
},
"tags": {
"type": "string",
Expand All @@ -71,7 +73,8 @@
"description": "Adds the specified e2e test runner.",
"type": "string",
"enum": ["playwright", "cypress", "detox", "none"],
"default": "playwright"
"default": "none",
"x-priority": "important"
},
"install": {
"type": "boolean",
Expand Down
Loading

0 comments on commit ec5a5e6

Please sign in to comment.