@nx/react 23.0.0-rc.4 → 23.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,13 +7,12 @@
7
7
 
8
8
  <div style="text-align: center;">
9
9
 
10
- [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
10
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
11
  [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
12
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
- [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
+ [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
17
16
 
18
17
  </div>
19
18
 
@@ -1,3 +1,3 @@
1
1
  import { ResolvePluginInstance, RuleSetRule, WebpackPluginInstance } from 'webpack';
2
- export declare const mergeRules: (...args: RuleSetRule[]) => (WebpackPluginInstance | RuleSetRule)[];
2
+ export declare const mergeRules: (...args: RuleSetRule[]) => (RuleSetRule | WebpackPluginInstance)[];
3
3
  export declare const mergePlugins: (...args: (WebpackPluginInstance | ResolvePluginInstance)[]) => (WebpackPluginInstance | ResolvePluginInstance)[];
@@ -3,41 +3,16 @@ import { WithNxOptions } from '@nx/webpack';
3
3
  import { WithReactOptions } from '../../../../plugins/with-react';
4
4
  import { NormalizedSchema } from '../schema';
5
5
  export declare function getDefaultTemplateVariables(host: Tree, options: NormalizedSchema): {
6
- typesNodeVersion: string;
7
- typesReactDomVersion: string;
8
- reactRouterVersion: string;
9
- typesReactVersion: string;
10
- reactDomVersion: string;
11
- reactVersion: string;
12
- reactRouterIsBotVersion: string;
13
- js: boolean;
14
- tmpl: string;
15
- offsetFromRoot: string;
16
- appTests: string;
17
- inSourceVitestTests: string;
18
- style: import("../../../..").SupportedStyles;
19
- hasStyleFile: boolean;
20
- isUsingTsSolutionSetup: boolean;
21
- port: number;
22
- projectName: string;
23
- appProjectRoot: string;
24
- e2eProjectName: string;
25
- e2eProjectRoot: string;
26
- importPath: string;
27
- parsedTags: string[];
28
- fileName: string;
29
- hasStyles: boolean;
30
- unitTestRunner: "jest" | "vitest" | "none";
31
- addPlugin?: boolean;
32
- names: ReturnType<typeof import("@nx/devkit").names>;
33
- isUsingTsSolutionConfig?: boolean;
34
- directory: string;
35
6
  name: string;
7
+ className: string;
8
+ propertyName: string;
9
+ constantName: string;
10
+ directory: string;
36
11
  skipFormat?: boolean;
37
12
  tags?: string;
38
13
  inSourceTests?: boolean;
39
- e2eTestRunner: "cypress" | "playwright" | "none";
40
- linter: import("packages/eslint/dist").Linter | import("packages/eslint/dist").LinterType;
14
+ e2eTestRunner: 'cypress' | 'playwright' | 'none';
15
+ linter: import("@nx/eslint").Linter | import("@nx/eslint").LinterType;
41
16
  classComponent?: boolean;
42
17
  routing?: boolean;
43
18
  useReactRouter?: boolean;
@@ -45,20 +20,45 @@ export declare function getDefaultTemplateVariables(host: Tree, options: Normali
45
20
  globalCss?: boolean;
46
21
  strict?: boolean;
47
22
  setParserOptionsProject?: boolean;
48
- compiler?: "babel" | "swc";
23
+ compiler?: 'babel' | 'swc';
49
24
  remotes?: string[];
50
25
  devServerPort?: number;
51
26
  skipPackageJson?: boolean;
52
27
  rootProject?: boolean;
53
- bundler?: "webpack" | "vite" | "rspack" | "rsbuild";
28
+ bundler?: 'webpack' | 'vite' | 'rspack' | 'rsbuild';
54
29
  minimal?: boolean;
55
30
  nxCloudToken?: string;
56
31
  useTsSolution?: boolean;
57
- formatter?: "prettier" | "none";
32
+ formatter?: 'prettier' | 'none';
58
33
  useProjectJson?: boolean;
59
- className: string;
60
- propertyName: string;
61
- constantName: string;
34
+ projectName: string;
35
+ appProjectRoot: string;
36
+ e2eProjectName: string;
37
+ e2eProjectRoot: string;
38
+ importPath: string;
39
+ parsedTags: string[];
40
+ fileName: string;
41
+ hasStyles: boolean;
42
+ unitTestRunner: 'jest' | 'vitest' | 'none';
43
+ addPlugin?: boolean;
44
+ names: ReturnType<typeof import("@nx/devkit").names>;
45
+ isUsingTsSolutionConfig?: boolean;
46
+ typesNodeVersion: string;
47
+ typesReactDomVersion: string;
48
+ reactRouterVersion: string;
49
+ typesReactVersion: string;
50
+ reactDomVersion: string;
51
+ reactVersion: string;
52
+ reactRouterIsBotVersion: string;
53
+ js: boolean;
54
+ tmpl: string;
55
+ offsetFromRoot: string;
56
+ appTests: string;
57
+ inSourceVitestTests: string;
58
+ style: import("../../../..").SupportedStyles;
59
+ hasStyleFile: boolean;
60
+ isUsingTsSolutionSetup: boolean;
61
+ port: number;
62
62
  };
63
63
  export declare function createNxRspackPluginOptions(options: NormalizedSchema, rootOffset: string, tsx?: boolean): WithNxOptions & WithReactOptions;
64
64
  export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): Promise<void>;
@@ -6,6 +6,8 @@ const { join } = require('path');
6
6
  const config = require('./module-federation.config');
7
7
 
8
8
  module.exports = {
9
+ // rspack-cli dev mode defaults this on; it breaks module federation.
10
+ lazyCompilation: false,
9
11
  output: {
10
12
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
11
13
  publicPath: 'auto'
@@ -8,6 +8,8 @@ const serverMfConfig = require('./module-federation.server.config');
8
8
 
9
9
  const browserRspackConfig = {
10
10
  name: 'browser',
11
+ // rspack-cli dev mode defaults this on; it breaks module federation.
12
+ lazyCompilation: false,
11
13
  output: {
12
14
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>', 'browser'),
13
15
  publicPath: 'auto'
@@ -8,6 +8,8 @@ import serverMfConfig from './module-federation.server.config';
8
8
 
9
9
  const browserRspackConfig = {
10
10
  name: 'browser',
11
+ // rspack-cli dev mode defaults this on; it breaks module federation.
12
+ lazyCompilation: false,
11
13
  output: {
12
14
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>', 'browser'),
13
15
  publicPath: 'auto'
@@ -6,6 +6,8 @@ import { join } from 'path';
6
6
  import config from './module-federation.config';
7
7
 
8
8
  export default {
9
+ // rspack-cli dev mode defaults this on; it breaks module federation.
10
+ lazyCompilation: false,
9
11
  output: {
10
12
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
11
13
  publicPath: 'auto'
@@ -6,6 +6,8 @@ const { join } = require('path');
6
6
  const config = require('./module-federation.config');
7
7
 
8
8
  module.exports = {
9
+ // rspack-cli dev mode defaults this on; it breaks module federation.
10
+ lazyCompilation: false,
9
11
  output: {
10
12
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
11
13
  publicPath: 'auto'
@@ -8,6 +8,8 @@ const serverMfConfig = require('./module-federation.server.config');
8
8
 
9
9
  const browserRspackConfig = {
10
10
  name: 'browser',
11
+ // rspack-cli dev mode defaults this on; it breaks module federation.
12
+ lazyCompilation: false,
11
13
  output: {
12
14
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>', 'browser'),
13
15
  publicPath: 'auto'
@@ -8,6 +8,8 @@ import serverMfConfig from './module-federation.server.config';
8
8
 
9
9
  const browserRspackConfig = {
10
10
  name: 'browser',
11
+ // rspack-cli dev mode defaults this on; it breaks module federation.
12
+ lazyCompilation: false,
11
13
  output: {
12
14
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>', 'browser'),
13
15
  publicPath: 'auto'
@@ -6,6 +6,8 @@ import { join } from 'path';
6
6
  import config from './module-federation.config';
7
7
 
8
8
  export default {
9
+ // rspack-cli dev mode defaults this on; it breaks module federation.
10
+ lazyCompilation: false,
9
11
  output: {
10
12
  path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
11
13
  publicPath: 'auto'
@@ -0,0 +1,44 @@
1
+ # React 18 -> 19 Migration Instructions for LLM
2
+
3
+ Migrate the Nx workspace's React projects from 18 to 19. Run the codemods first, fix the rest by hand, build after each project.
4
+
5
+ ## Step 1: Codemods
6
+
7
+ ```bash
8
+ npx codemod@latest react/19/migration-recipe
9
+ npx types-react-codemod@latest preset-19 ./PROJECT_PATH
10
+ ```
11
+
12
+ First handles API changes, second handles `@types/react` 19 types. Review the diffs.
13
+
14
+ ## Step 2: Removed APIs (fix by hand if codemod misses)
15
+
16
+ - `ReactDOM.render` / `hydrate` -> `createRoot` / `hydrateRoot` from `react-dom/client`. Note `hydrateRoot(container, element)` swaps the arg order vs `hydrate`.
17
+ - `ReactDOM.unmountComponentAtNode` -> keep the root from `createRoot` / `hydrateRoot` and call `root.unmount()`.
18
+ - `ReactDOM.findDOMNode` -> use refs.
19
+ - `propTypes` -> removed for ALL components (class and function); drop it, use TS types.
20
+ - `defaultProps` -> removed for FUNCTION components (use default params); still works on classes.
21
+ - Legacy string refs -> callback refs or `useRef`.
22
+ - Legacy Context: consumer `contextTypes` and provider `childContextTypes` / `getChildContext` -> `createContext`.
23
+ - `react-test-renderer` is deprecated -> migrate tests to `@testing-library/react`.
24
+
25
+ ## Step 3: ref as prop
26
+
27
+ `forwardRef` is no longer needed; `ref` is a normal prop. Existing `forwardRef` calls still work (deprecated).
28
+
29
+ ## Step 4: Types
30
+
31
+ `@types/react@19`: `useRef` needs an initial arg, implicit `children` removed (declare it on props), `JSX` global moved. The types codemod handles most.
32
+
33
+ ## Validate
34
+
35
+ ```bash
36
+ nx run PROJECT:build
37
+ nx affected -t build,lint,test
38
+ ```
39
+
40
+ ## Notes for LLM
41
+
42
+ - Codemods first (API + types), then manual.
43
+ - One project at a time, build after each.
44
+ - Confirm third-party libs support React 19 before bumping.
@@ -0,0 +1,38 @@
1
+ #### Upgrade React 18 to 19
2
+
3
+ Bumps `react`, `react-dom`, and the React type packages from 18 to 19. React 19 removes several long-deprecated APIs; the change every project hits is the root API (`ReactDOM.render` -> `createRoot`). Read more in the [React 19 upgrade guide](https://react.dev/blog/2024/04/25/react-19-upgrade-guide).
4
+
5
+ The paired AI instructions migration walks an agent through the full set of changes. The common ones are shown below.
6
+
7
+ #### Examples
8
+
9
+ ##### Before
10
+
11
+ ```tsx title="src/main.tsx"
12
+ import ReactDOM from 'react-dom';
13
+
14
+ ReactDOM.render(<App />, document.getElementById('root'));
15
+ ```
16
+
17
+ ##### After
18
+
19
+ ```tsx title="src/main.tsx"
20
+ import { createRoot } from 'react-dom/client';
21
+
22
+ createRoot(document.getElementById('root')!).render(<App />);
23
+ ```
24
+
25
+ `defaultProps` on a function component becomes a default parameter:
26
+
27
+ ##### Before
28
+
29
+ ```tsx
30
+ function Badge({ color }) {}
31
+ Badge.defaultProps = { color: 'gray' };
32
+ ```
33
+
34
+ ##### After
35
+
36
+ ```tsx
37
+ function Badge({ color = 'gray' }) {}
38
+ ```
@@ -35,7 +35,7 @@ function createTsConfigForTsSolution(host, projectRoot, type, options, relativeP
35
35
  if (options.rootProject) {
36
36
  json.compileOnSave = false;
37
37
  json.compilerOptions = {
38
- ...shared.tsConfigBaseOptions,
38
+ ...(0, internal_1.getTsConfigBaseOptions)(host),
39
39
  ...json.compilerOptions,
40
40
  };
41
41
  json.exclude = ['node_modules', 'tmp'];
@@ -63,7 +63,6 @@ function createTsConfigForNonTsSolution(host, projectRoot, type, options, relati
63
63
  compilerOptions: {
64
64
  jsx: 'react-jsx',
65
65
  allowJs: false,
66
- esModuleInterop: false,
67
66
  allowSyntheticDefaultImports: true,
68
67
  strict: options.strict,
69
68
  },
@@ -85,7 +84,7 @@ function createTsConfigForNonTsSolution(host, projectRoot, type, options, relati
85
84
  if (options.rootProject) {
86
85
  json.compileOnSave = false;
87
86
  json.compilerOptions = {
88
- ...shared.tsConfigBaseOptions,
87
+ ...(0, internal_1.getTsConfigBaseOptions)(host),
89
88
  ...json.compilerOptions,
90
89
  };
91
90
  json.exclude = ['node_modules', 'tmp'];
@@ -10,5 +10,5 @@ export declare function getBundlerFromTarget(found: FoundTarget, tree: Tree): Pr
10
10
  export declare function getActualBundler(tree: Tree, options: {
11
11
  buildTarget?: string;
12
12
  bundler?: 'vite' | 'webpack';
13
- }, found: FoundTarget): Promise<"webpack" | "vite">;
13
+ }, found: FoundTarget): Promise<"vite" | "webpack">;
14
14
  export declare function isComponent(tree: Tree, filePath: string): boolean;
@@ -17,3 +17,13 @@ declare module '*.module.less' {
17
17
  const classes: { readonly [key: string]: string };
18
18
  export default classes;
19
19
  }
20
+
21
+ // TS 6.0 enables `noUncheckedSideEffectImports`, which errors on plain
22
+ // `import './x.css'` unless the module is declared. Empty bodies allow the
23
+ // side-effect import without granting a default-import `any`.
24
+ // Keep these below the '*.module.*' declarations - equally-specific wildcard
25
+ // patterns resolve by registration order and the typed modules must win.
26
+ declare module '*.css' {}
27
+ declare module '*.scss' {}
28
+ declare module '*.sass' {}
29
+ declare module '*.less' {}
package/migrations.json CHANGED
@@ -30,6 +30,15 @@
30
30
  "version": "23.0.0-beta.25",
31
31
  "description": "Rewrites `@nx/react/src/*` subpath imports now that the `./src/*` subpath is no longer exposed by `@nx/react`'s exports map. Named imports/exports of public symbols are routed to `@nx/react` and the rest to the new `@nx/react/internal` entry; `require`, dynamic `import` and `jest.mock` calls reference the whole module and are routed to `@nx/react/internal`.",
32
32
  "implementation": "./dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports"
33
+ },
34
+ "update-23-1-0-create-ai-instructions-for-react-19": {
35
+ "version": "23.1.0-beta.0",
36
+ "requires": {
37
+ "react": ">=19.0.0"
38
+ },
39
+ "description": "Create AI instructions to help migrate workspaces from React 18 to 19.",
40
+ "prompt": "./dist/src/migrations/update-23-1-0/ai-instructions-for-react-19.md",
41
+ "documentation": "./dist/src/migrations/update-23-1-0/upgrade-to-react-19.md"
33
42
  }
34
43
  },
35
44
  "packageJsonUpdates": {
@@ -202,6 +211,38 @@
202
211
  "alwaysAddToPackageJson": false
203
212
  }
204
213
  }
214
+ },
215
+ "23.1.0": {
216
+ "version": "23.1.0-beta.0",
217
+ "requires": {
218
+ "react": ">=18.0.0 <19.0.0"
219
+ },
220
+ "packages": {
221
+ "react": {
222
+ "version": "^19.0.0",
223
+ "alwaysAddToPackageJson": false
224
+ },
225
+ "react-dom": {
226
+ "version": "^19.0.0",
227
+ "alwaysAddToPackageJson": false
228
+ },
229
+ "react-is": {
230
+ "version": "^19.0.0",
231
+ "alwaysAddToPackageJson": false
232
+ },
233
+ "@types/react": {
234
+ "version": "^19.0.0",
235
+ "alwaysAddToPackageJson": false
236
+ },
237
+ "@types/react-dom": {
238
+ "version": "^19.0.0",
239
+ "alwaysAddToPackageJson": false
240
+ },
241
+ "@types/react-is": {
242
+ "version": "^19.0.0",
243
+ "alwaysAddToPackageJson": false
244
+ }
245
+ }
205
246
  }
206
247
  }
207
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "23.0.0-rc.4",
3
+ "version": "23.1.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -108,25 +108,25 @@
108
108
  "express": "^4.21.2",
109
109
  "http-proxy-middleware": "^3.0.5",
110
110
  "semver": "^7.6.3",
111
- "@nx/devkit": "23.0.0-rc.4",
112
- "@nx/js": "23.0.0-rc.4",
113
- "@nx/eslint": "23.0.0-rc.4",
114
- "@nx/web": "23.0.0-rc.4",
115
- "@nx/module-federation": "23.0.0-rc.4",
116
- "@nx/rollup": "23.0.0-rc.4"
111
+ "@nx/devkit": "23.1.0-beta.0",
112
+ "@nx/js": "23.1.0-beta.0",
113
+ "@nx/eslint": "23.1.0-beta.0",
114
+ "@nx/web": "23.1.0-beta.0",
115
+ "@nx/module-federation": "23.1.0-beta.0",
116
+ "@nx/rollup": "23.1.0-beta.0"
117
117
  },
118
118
  "devDependencies": {
119
- "@nx/cypress": "23.0.0-rc.4",
120
- "@nx/playwright": "23.0.0-rc.4",
121
- "@nx/rsbuild": "23.0.0-rc.4",
122
- "@nx/vite": "23.0.0-rc.4",
123
- "@nx/vitest": "23.0.0-rc.4",
124
- "@nx/webpack": "23.0.0-rc.4",
125
- "@nx/storybook": "23.0.0-rc.4",
126
- "nx": "23.0.0-rc.4"
119
+ "@nx/cypress": "23.1.0-beta.0",
120
+ "@nx/playwright": "23.1.0-beta.0",
121
+ "@nx/rsbuild": "23.1.0-beta.0",
122
+ "@nx/vite": "23.1.0-beta.0",
123
+ "@nx/vitest": "23.1.0-beta.0",
124
+ "@nx/webpack": "23.1.0-beta.0",
125
+ "@nx/storybook": "23.1.0-beta.0",
126
+ "nx": "23.1.0-beta.0"
127
127
  },
128
128
  "optionalDependencies": {
129
- "@nx/vite": "23.0.0-rc.4"
129
+ "@nx/vite": "23.1.0-beta.0"
130
130
  },
131
131
  "publishConfig": {
132
132
  "access": "public"
@@ -17,3 +17,13 @@ declare module '*.module.less' {
17
17
  const classes: { readonly [key: string]: string };
18
18
  export default classes;
19
19
  }
20
+
21
+ // TS 6.0 enables `noUncheckedSideEffectImports`, which errors on plain
22
+ // `import './x.css'` unless the module is declared. Empty bodies allow the
23
+ // side-effect import without granting a default-import `any`.
24
+ // Keep these below the '*.module.*' declarations - equally-specific wildcard
25
+ // patterns resolve by registration order and the typed modules must win.
26
+ declare module '*.css' {}
27
+ declare module '*.scss' {}
28
+ declare module '*.sass' {}
29
+ declare module '*.less' {}