@nx/react 21.0.0-canary.20250429-cf4a1f3 → 21.0.0-canary.20250501-8f50358

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NxReactWebpackPlugin as _NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
2
- /** @deprecated Use '@nx/react/webpack-plugin' instead. */
2
+ /** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
3
3
  export declare const NxReactWebpackPlugin: typeof _NxReactWebpackPlugin;
4
4
  export { extraEslintDependencies, extendReactEslintJson, } from './src/utils/lint';
5
5
  export { cssInJsDependenciesBabel } from './src/utils/styled';
package/index.js CHANGED
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = exports.NxReactWebpackPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
6
- // TODO(v21): Remove this in favor of deep imports in order to load configs faster (150-200ms faster).
7
- /** @deprecated Use '@nx/react/webpack-plugin' instead. */
6
+ /** @deprecated Use '@nx/react/webpack-plugin' instead, which can improve graph creation by 150-200ms per file. */
8
7
  exports.NxReactWebpackPlugin = nx_react_webpack_plugin_1.NxReactWebpackPlugin;
9
8
  var lint_1 = require("./src/utils/lint");
10
9
  Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
package/migrations.json CHANGED
@@ -41,6 +41,12 @@
41
41
  "version": "20.4.0-beta.0",
42
42
  "description": "Add NX_MF_DEV_REMOTES to inputs for task hashing when '@nx/webpack:webpack' or '@nx/rspack:rspack' is used for Module Federation.",
43
43
  "factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
44
+ },
45
+ "update-21-0-0-update-babel-loose": {
46
+ "cli": "nx",
47
+ "version": "21.0.0-beta.11",
48
+ "description": "Replaces `classProperties.loose` option with `loose`.",
49
+ "factory": "./src/migrations/update-21-0-0/update-babel-loose"
44
50
  }
45
51
  },
46
52
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "21.0.0-canary.20250429-cf4a1f3",
3
+ "version": "21.0.0-canary.20250501-8f50358",
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": {
@@ -38,11 +38,11 @@
38
38
  "minimatch": "9.0.3",
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
- "@nx/devkit": "21.0.0-canary.20250429-cf4a1f3",
42
- "@nx/js": "21.0.0-canary.20250429-cf4a1f3",
43
- "@nx/eslint": "21.0.0-canary.20250429-cf4a1f3",
44
- "@nx/web": "21.0.0-canary.20250429-cf4a1f3",
45
- "@nx/module-federation": "21.0.0-canary.20250429-cf4a1f3",
41
+ "@nx/devkit": "21.0.0-canary.20250501-8f50358",
42
+ "@nx/js": "21.0.0-canary.20250501-8f50358",
43
+ "@nx/eslint": "21.0.0-canary.20250501-8f50358",
44
+ "@nx/web": "21.0.0-canary.20250501-8f50358",
45
+ "@nx/module-federation": "21.0.0-canary.20250501-8f50358",
46
46
  "express": "^4.21.2",
47
47
  "http-proxy-middleware": "^3.0.3",
48
48
  "semver": "^7.6.3"
@@ -167,7 +167,7 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
167
167
  }
168
168
  return async () => {
169
169
  customWebpack = await customWebpack;
170
- // TODO(v21): Component testing need to be agnostic of the underlying executor. With Crystal, we're not using `@nx/webpack:webpack` by default.
170
+ // TODO(v22): Component testing need to be agnostic of the underlying executor. With Crystal, we're not using `@nx/webpack:webpack` by default.
171
171
  // We need to decouple CT from the build target of the app, we just care about bundler config (e.g. webpack.config.js).
172
172
  // The generated setup should support both Webpack and Vite as documented here: https://docs.cypress.io/guides/component-testing/react/overview
173
173
  // Related issue: https://github.com/nrwl/nx/issues/21546
@@ -13,26 +13,6 @@ function applyReactConfig(options, config = {}) {
13
13
  ref: true,
14
14
  };
15
15
  const svgrOptions = typeof options.svgr === 'object' ? options.svgr : defaultSvgrOptions;
16
- // TODO(v21): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
17
- // It should be:
18
- // use: [{
19
- // test: /\.svg$/i,
20
- // type: 'asset',
21
- // resourceQuery: /react/, // *.svg?react
22
- // },
23
- // {
24
- // test: /\.svg$/i,
25
- // issuer: /\.[jt]sx?$/,
26
- // resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
27
- // use: ['@svgr/webpack'],
28
- // }],
29
- // See:
30
- // - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
31
- // - Vite: https://www.npmjs.com/package/vite-plugin-svgr
32
- // - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
33
- // Note: We also need a migration for any projects that are using SVGR to convert
34
- // `import { ReactComponent as X } from './x.svg` to
35
- // `import X from './x.svg?react';
36
16
  config.module.rules.push({
37
17
  test: /\.svg$/,
38
18
  issuer: /\.(js|ts|md)x?$/,
@@ -6,6 +6,10 @@ export interface SvgrOptions {
6
6
  ref?: boolean;
7
7
  }
8
8
  export interface WithReactOptions extends WithWebOptions {
9
+ /**
10
+ * @deprecated Add SVGR support in your Webpack configuration without relying on Nx. See https://react-svgr.com/docs/webpack/
11
+ * TODO(v22): Remove this option and migrate userland webpack config to explicitly configure @svgr/webpack
12
+ * */
9
13
  svgr?: boolean | SvgrOptions;
10
14
  }
11
15
  /**
@@ -12,7 +12,7 @@ const lint_1 = require("../../../utils/lint");
12
12
  const versions_1 = require("../../../utils/versions");
13
13
  async function addLinting(host, options) {
14
14
  const tasks = [];
15
- if (options.linter === eslint_1.Linter.EsLint) {
15
+ if (options.linter === 'eslint') {
16
16
  const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
17
17
  linter: options.linter,
18
18
  project: options.projectName,
@@ -8,7 +8,7 @@ const lint_1 = require("../../../utils/lint");
8
8
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
9
9
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
10
10
  async function addLinting(host, options) {
11
- if (options.linter === eslint_1.Linter.EsLint) {
11
+ if (options.linter === 'eslint') {
12
12
  const tasks = [];
13
13
  const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
14
14
  linter: options.linter,
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function updateBabelLoose(tree: Tree): Promise<void>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = updateBabelLoose;
4
+ const devkit_1 = require("@nx/devkit");
5
+ async function updateBabelLoose(tree) {
6
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '', (path) => {
7
+ if (!path.endsWith('.babelrc'))
8
+ return;
9
+ try {
10
+ (0, devkit_1.updateJson)(tree, path, (babelConfig) => {
11
+ if (!Array.isArray(babelConfig.presets))
12
+ return babelConfig;
13
+ const ourPreset = babelConfig.presets.find((p) => Array.isArray(p) && p[0] === '@nx/react/babel');
14
+ if (!ourPreset || !ourPreset[1])
15
+ return babelConfig;
16
+ const options = ourPreset[1];
17
+ if (options['classProperties']?.loose !== undefined) {
18
+ options.loose = options['classProperties'].loose;
19
+ delete options['classProperties'];
20
+ }
21
+ return babelConfig;
22
+ });
23
+ }
24
+ catch {
25
+ // Skip if JSON does not parse for whatever reason
26
+ return;
27
+ }
28
+ });
29
+ await (0, devkit_1.formatFiles)(tree);
30
+ }
@@ -4,11 +4,10 @@ exports.createApp = createApp;
4
4
  exports.createLib = createLib;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const application_1 = require("../generators/application/application");
7
- const eslint_1 = require("@nx/eslint");
8
7
  async function createApp(tree, appName) {
9
8
  await (0, application_1.default)(tree, {
10
9
  e2eTestRunner: 'none',
11
- linter: eslint_1.Linter.EsLint,
10
+ linter: 'eslint',
12
11
  skipFormat: true,
13
12
  style: 'css',
14
13
  unitTestRunner: 'none',