@nx/react 24.0.0-canary.20261016-5ef7804 → 24.0.0-canary.20261020-e7ffd79

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.
Files changed (80) hide show
  1. package/dist/internal.d.ts +1 -0
  2. package/dist/internal.js +3 -1
  3. package/dist/module-federation.d.ts +6 -0
  4. package/dist/module-federation.js +31 -0
  5. package/dist/plugins/component-testing/index.js +92 -33
  6. package/dist/plugins/storybook/index.js +18 -18
  7. package/dist/plugins/with-react.d.ts +3 -7
  8. package/dist/plugins/with-react.js +5 -19
  9. package/dist/ready-check.d.ts +1 -0
  10. package/dist/ready-check.js +5 -0
  11. package/dist/src/generators/_utils/mf-dependencies.js +3 -0
  12. package/dist/src/generators/application/application.js +1 -36
  13. package/dist/src/generators/application/files/base-rspack/rspack.config.js__tmpl__ +0 -15
  14. package/dist/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +0 -17
  15. package/dist/src/generators/application/lib/add-e2e.js +9 -8
  16. package/dist/src/generators/application/lib/add-linting.js +0 -1
  17. package/dist/src/generators/application/lib/add-project.js +0 -167
  18. package/dist/src/generators/application/lib/bundlers/add-rsbuild.js +0 -1
  19. package/dist/src/generators/application/lib/bundlers/add-vite.js +0 -2
  20. package/dist/src/generators/application/lib/bundlers/add-webpack.js +0 -1
  21. package/dist/src/generators/application/lib/create-application-files.d.ts +0 -1
  22. package/dist/src/generators/application/lib/create-application-files.js +2 -11
  23. package/dist/src/generators/application/lib/normalize-options.js +0 -4
  24. package/dist/src/generators/application/schema.d.ts +0 -2
  25. package/dist/src/generators/consumer/consumer.js +2 -0
  26. package/dist/src/generators/consumer/files/rsbuild/package.json__tmpl__ +1 -0
  27. package/dist/src/generators/consumer/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
  28. package/dist/src/generators/consumer/files/rspack/package.json__tmpl__ +1 -0
  29. package/dist/src/generators/consumer/files/rspack/rspack.config.ts__tmpl__ +2 -0
  30. package/dist/src/generators/consumer/files/vite/package.json__tmpl__ +1 -0
  31. package/dist/src/generators/consumer/files/vite/vite.config.mts__tmpl__ +2 -0
  32. package/dist/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -16
  33. package/dist/src/generators/cypress-component-configuration/lib/add-files.d.ts +1 -2
  34. package/dist/src/generators/cypress-component-configuration/lib/add-files.js +4 -2
  35. package/dist/src/generators/cypress-component-configuration/schema.d.ts +0 -1
  36. package/dist/src/generators/init/init.js +3 -5
  37. package/dist/src/generators/init/schema.d.ts +0 -1
  38. package/dist/src/generators/library/lib/add-linting.js +0 -1
  39. package/dist/src/generators/library/lib/add-rollup-build-target.js +3 -47
  40. package/dist/src/generators/library/lib/normalize-options.js +0 -4
  41. package/dist/src/generators/library/library.js +1 -4
  42. package/dist/src/generators/library/schema.d.ts +0 -1
  43. package/dist/src/generators/provider/files/rsbuild/package.json__tmpl__ +1 -0
  44. package/dist/src/generators/provider/files/rsbuild/rsbuild.config.ts__tmpl__ +2 -0
  45. package/dist/src/generators/provider/files/rspack/package.json__tmpl__ +1 -0
  46. package/dist/src/generators/provider/files/rspack/rspack.config.ts__tmpl__ +2 -0
  47. package/dist/src/generators/provider/files/vite/package.json__tmpl__ +1 -0
  48. package/dist/src/generators/provider/files/vite/vite.config.mts__tmpl__ +2 -0
  49. package/dist/src/generators/provider/provider.js +2 -0
  50. package/dist/src/generators/stories/stories.js +0 -5
  51. package/dist/src/generators/storybook-configuration/configuration.js +1 -9
  52. package/dist/src/generators/storybook-configuration/schema.d.ts +0 -1
  53. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.d.ts +4 -0
  54. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.js +13 -0
  55. package/dist/src/migrations/update-24-0-0/register-typescript-plugin-for-typecheck.md +40 -0
  56. package/dist/src/plugins/router-plugin-utils.d.ts +4 -0
  57. package/dist/src/plugins/router-plugin-utils.js +15 -0
  58. package/dist/src/plugins/router-plugin.d.ts +0 -1
  59. package/dist/src/plugins/router-plugin.js +35 -44
  60. package/dist/src/utils/ast-utils.d.ts +0 -1
  61. package/dist/src/utils/ast-utils.js +0 -23
  62. package/dist/src/utils/ct-utils.d.ts +0 -7
  63. package/dist/src/utils/ct-utils.js +71 -55
  64. package/dist/src/utils/deprecation.d.ts +1 -1
  65. package/dist/src/utils/deprecation.js +3 -5
  66. package/dist/src/utils/framework.js +1 -3
  67. package/dist/src/utils/react-router-serve-ready-check.d.ts +11 -0
  68. package/dist/src/utils/react-router-serve-ready-check.js +25 -0
  69. package/dist/src/utils/versions.d.ts +0 -4
  70. package/dist/src/utils/versions.js +1 -5
  71. package/generators.json +0 -6
  72. package/migrations.json +6 -0
  73. package/package.json +32 -15
  74. package/dist/src/generators/setup-ssr/files/server.ts__tmpl__ +0 -28
  75. package/dist/src/generators/setup-ssr/files/src/main.server.tsx__tmpl__ +0 -47
  76. package/dist/src/generators/setup-ssr/files/tsconfig.server.json__tmpl__ +0 -17
  77. package/dist/src/generators/setup-ssr/schema.d.ts +0 -8
  78. package/dist/src/generators/setup-ssr/schema.json +0 -54
  79. package/dist/src/generators/setup-ssr/setup-ssr.d.ts +0 -4
  80. package/dist/src/generators/setup-ssr/setup-ssr.js +0 -198
@@ -6,3 +6,4 @@ export { suppressReactComposeHelperWarnings } from './src/utils/deprecation';
6
6
  export { hasWebpackPlugin } from './src/utils/has-webpack-plugin';
7
7
  export { getReactDependenciesVersionsToInstall, isReact18, } from './src/utils/version-utils';
8
8
  export { testingLibraryDomVersion, testingLibraryReactVersion, babelCoreVersion, babelPresetReactVersion, } from './src/utils/versions';
9
+ export { applyReactConfig } from './plugins/nx-react-webpack-plugin/lib/apply-react-config';
package/dist/internal.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // internal consumers and may change without semver protection. Mirrors
6
6
  // `@nx/devkit/internal`.
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.assertPackageIsInstalled = exports.addRollupBuildTarget = exports.addE2e = void 0;
8
+ exports.applyReactConfig = exports.babelPresetReactVersion = exports.babelCoreVersion = exports.testingLibraryReactVersion = exports.testingLibraryDomVersion = exports.isReact18 = exports.getReactDependenciesVersionsToInstall = exports.hasWebpackPlugin = exports.suppressReactComposeHelperWarnings = exports.isComponent = exports.assertPackageIsInstalled = exports.addRollupBuildTarget = exports.addE2e = void 0;
9
9
  var add_e2e_1 = require("./src/generators/application/lib/add-e2e");
10
10
  Object.defineProperty(exports, "addE2e", { enumerable: true, get: function () { return add_e2e_1.addE2e; } });
11
11
  var add_rollup_build_target_1 = require("./src/generators/library/lib/add-rollup-build-target");
@@ -26,3 +26,5 @@ Object.defineProperty(exports, "testingLibraryDomVersion", { enumerable: true, g
26
26
  Object.defineProperty(exports, "testingLibraryReactVersion", { enumerable: true, get: function () { return versions_1.testingLibraryReactVersion; } });
27
27
  Object.defineProperty(exports, "babelCoreVersion", { enumerable: true, get: function () { return versions_1.babelCoreVersion; } });
28
28
  Object.defineProperty(exports, "babelPresetReactVersion", { enumerable: true, get: function () { return versions_1.babelPresetReactVersion; } });
29
+ var apply_react_config_1 = require("./plugins/nx-react-webpack-plugin/lib/apply-react-config");
30
+ Object.defineProperty(exports, "applyReactConfig", { enumerable: true, get: function () { return apply_react_config_1.applyReactConfig; } });
@@ -0,0 +1,6 @@
1
+ type IdentityConfigFn = <T>(config: T, ...rest: unknown[]) => T;
2
+ /** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
3
+ export declare function withModuleFederation(..._args: unknown[]): Promise<IdentityConfigFn>;
4
+ /** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
5
+ export declare function withModuleFederationForSSR(..._args: unknown[]): Promise<IdentityConfigFn>;
6
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withModuleFederation = withModuleFederation;
4
+ exports.withModuleFederationForSSR = withModuleFederationForSSR;
5
+ const devkit_1 = require("@nx/devkit");
6
+ // TODO(v25): Delete this subpath. It keeps 23.x configs loading during graph creation so `nx migrate` can run.
7
+ const REMOVED_MESSAGE = 'Nx Module Federation was removed in Nx v24. `@nx/react/module-federation` is a stub that keeps old configs loadable during project graph creation; it does not configure Module Federation. Follow https://nx.dev/docs/kb/migrate-from-nx-module-federation to move to the official Module Federation plugin.';
8
+ let warned = false;
9
+ // Graph creation only reads the config, so it keeps working; a build would silently drop federation.
10
+ function failOutsideGraphCreation() {
11
+ if (!global.NX_GRAPH_CREATION)
12
+ throw new Error(REMOVED_MESSAGE);
13
+ if (warned)
14
+ return;
15
+ warned = true;
16
+ devkit_1.logger.warn(REMOVED_MESSAGE);
17
+ }
18
+ /** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
19
+ async function withModuleFederation(..._args) {
20
+ failOutsideGraphCreation();
21
+ return (config) => config;
22
+ }
23
+ /** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
24
+ async function withModuleFederationForSSR(..._args) {
25
+ failOutsideGraphCreation();
26
+ return (config) => config;
27
+ }
28
+ // Older generated configs use `const withModuleFederation = require('@nx/react/module-federation')`.
29
+ module.exports = withModuleFederation;
30
+ module.exports.withModuleFederation = withModuleFederation;
31
+ module.exports.withModuleFederationForSSR = withModuleFederationForSSR;
@@ -4,9 +4,11 @@ exports.nxComponentTestingPreset = nxComponentTestingPreset;
4
4
  const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
5
5
  const internal_1 = require("@nx/cypress/internal");
6
6
  const devkit_1 = require("@nx/devkit");
7
- const internal_2 = require("@nx/js/internal");
7
+ const internal_2 = require("@nx/devkit/internal");
8
+ const internal_3 = require("@nx/js/internal");
8
9
  const fs_1 = require("fs");
9
10
  const path_1 = require("path");
11
+ const url_1 = require("url");
10
12
  /**
11
13
  * React nx preset for Cypress Component Testing
12
14
  *
@@ -34,7 +36,10 @@ function nxComponentTestingPreset(pathToConfig, options) {
34
36
  // options, cast to any to avoid type errors
35
37
  return basePresetSettings;
36
38
  }
37
- const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
39
+ pathToConfig = pathToConfig.startsWith('file://')
40
+ ? (0, url_1.fileURLToPath)(pathToConfig)
41
+ : pathToConfig;
42
+ const normalizedProjectRootPath = (0, fs_1.statSync)(pathToConfig).isDirectory()
38
43
  ? pathToConfig
39
44
  : (0, path_1.dirname)(pathToConfig);
40
45
  if (options?.bundler === 'vite') {
@@ -154,51 +159,105 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
154
159
  Has component config? ${!!ctProjectConfig}
155
160
  `);
156
161
  }
162
+ const buildConfig = buildableProjectConfig.targets[parsed.target];
163
+ if (buildConfig.metadata?.technologies?.includes('webpack')) {
164
+ return async () => {
165
+ const configPath = ['js', 'cjs', 'mjs', 'ts', 'cts', 'mts']
166
+ .map((ext) => (0, path_1.join)(devkit_1.workspaceRoot, buildableProjectConfig.root, `webpack.config.${ext}`))
167
+ .find((path) => (0, fs_1.existsSync)(path));
168
+ if (!configPath)
169
+ throw new Error(`Cannot find webpack config for ${buildTarget}`);
170
+ const previousBuildTarget = process.env.NX_BUILD_TARGET;
171
+ process.env.NX_BUILD_TARGET = buildTarget;
172
+ try {
173
+ const exported = await (0, internal_2.loadConfigFile)(configPath);
174
+ const config = typeof exported === 'function'
175
+ ? await exported({}, { mode: 'development' })
176
+ : exported;
177
+ // Cypress runs its own dev server; the app's port and history
178
+ // fallback would collide with it and replace its spec page.
179
+ const { devServer: _devServer, ...ctConfig } = config;
180
+ return ctConfig;
181
+ }
182
+ finally {
183
+ if (previousBuildTarget === undefined)
184
+ delete process.env.NX_BUILD_TARGET;
185
+ else
186
+ process.env.NX_BUILD_TARGET = previousBuildTarget;
187
+ }
188
+ };
189
+ }
157
190
  if (buildableProjectConfig.targets[parsed.target].executor !==
158
191
  '@nx/webpack:webpack' &&
159
192
  buildableProjectConfig.targets[parsed.target].executor !==
160
193
  '@nx/rspack:rspack') {
161
- throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' or '@nx/rspack:rspack' executor. ` +
162
- `Please make sure to use '@nx/webpack:webpack' or '@nx/rspack:rspack' executor in that target to use Cypress Component Testing.`);
194
+ throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not a Webpack build target. ` +
195
+ `Cypress Component Testing needs a build target inferred by '@nx/webpack/plugin'.`);
196
+ }
197
+ const context = (0, internal_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.configuration);
198
+ const { resolveUserDefinedWebpackConfig, webpackExecutorContext, } = require('@nx/webpack/internal');
199
+ const { normalizeOptions } = require('@nx/webpack');
200
+ const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, (0, internal_3.getProjectSourceRoot)(buildableProjectConfig));
201
+ if (!options.webpackConfig) {
202
+ return null;
163
203
  }
164
- const context = (0, internal_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
165
- const { resolveUserDefinedWebpackConfig } = require('@nx/webpack/internal');
166
- const { normalizeOptions, composePluginsSync, withNx, withWeb, } = require('@nx/webpack');
167
- const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, (0, internal_2.getProjectSourceRoot)(buildableProjectConfig));
168
- let customWebpack;
169
- if (options.webpackConfig) {
170
- customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
204
+ return () => webpackExecutorContext.run({
205
+ target: parsed,
206
+ options: {
207
+ ...options,
208
+ // Cypress supplies component-index.html and builds library sources.
209
+ generateIndexHtml: false,
210
+ extractLicenses: false,
211
+ },
212
+ }, async () => {
213
+ const customWebpack = await resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
171
214
  ? options.tsConfig
172
215
  : (0, path_1.join)(context.root, options.tsConfig));
173
- }
174
- return async () => {
175
- customWebpack = await customWebpack;
176
- // For legacy `composePlugins(...)` setup, we need change some options to make Cypress CT work properly.
216
+ // Unmigrated `composePlugins(...)` configs are inert, so CT uses its fallback config.
177
217
  if (customWebpack &&
178
218
  require('@nx/webpack').isNxWebpackComposablePlugin(customWebpack) // using inline since @nx/webpack may not be installed when using vite so top-level import would error
179
219
  ) {
180
- return await customWebpack({}, {
181
- options: {
182
- ...options,
183
- // cypress will generate its own index.html from component-index.html
184
- generateIndexHtml: false,
185
- // causes issues with buildable libraries with ENOENT: no such file or directory, scandir error
186
- extractLicenses: false,
187
- root: devkit_1.workspaceRoot,
188
- projectRoot: ctProjectConfig.root,
189
- sourceRoot: (0, internal_2.getProjectSourceRoot)(ctProjectConfig),
190
- },
191
- context,
192
- configuration: parsed.configuration,
220
+ const { buildBaseWebpackConfig } = require('./webpack-fallback');
221
+ return buildBaseWebpackConfig({
222
+ tsConfigPath: findTsConfig((0, path_1.join)(devkit_1.workspaceRoot, ctProjectConfig.root)),
223
+ compiler: options.compiler || 'babel',
193
224
  });
194
225
  }
195
226
  else if (typeof customWebpack === 'object' ||
196
227
  typeof customWebpack === 'function') {
197
- // If this is a standard webpack config object or function, just return. it
198
- return customWebpack;
228
+ const config = typeof customWebpack === 'function'
229
+ ? await customWebpack({}, { mode: 'development' })
230
+ : customWebpack;
231
+ const { NxAppWebpackPlugin, } = require('@nx/webpack/app-plugin');
232
+ config.plugins = config.plugins?.map((plugin) => plugin instanceof NxAppWebpackPlugin
233
+ ? {
234
+ apply(compiler) {
235
+ // Cypress installs its harness after this config is returned.
236
+ const entry = { ...compiler.options.entry };
237
+ const output = { ...compiler.options.output };
238
+ const devtool = compiler.options.devtool;
239
+ const optimization = {
240
+ ...compiler.options.optimization,
241
+ };
242
+ const mode = compiler.options.mode;
243
+ const watchOptions = compiler.options.watchOptions;
244
+ const context = compiler.options.context;
245
+ plugin.apply(compiler);
246
+ compiler.options.entry = entry;
247
+ compiler.options.output = output;
248
+ compiler.options.devtool = devtool;
249
+ compiler.options.optimization = optimization;
250
+ compiler.options.mode = mode;
251
+ compiler.options.watchOptions = watchOptions;
252
+ compiler.options.context = context;
253
+ compiler.context = context;
254
+ },
255
+ }
256
+ : plugin);
257
+ return config;
199
258
  }
200
- return null; // return null to use fallback config
201
- };
259
+ return null;
260
+ });
202
261
  }
203
262
  function findViteConfig(projectRootFullPath) {
204
263
  const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
@@ -216,7 +275,7 @@ function findTsConfig(projectRoot) {
216
275
  ];
217
276
  for (const config of potentialConfigs) {
218
277
  if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, config))) {
219
- return config;
278
+ return (0, path_1.join)(projectRoot, config);
220
279
  }
221
280
  }
222
281
  }
@@ -3,13 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.webpack = exports.core = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/js/internal");
6
- const webpack_1 = require("@nx/webpack");
7
6
  const internal_2 = require("@nx/webpack/internal");
8
7
  const fs_1 = require("fs");
9
8
  const path_1 = require("path");
10
- const webpack_2 = require("webpack");
11
- const with_react_1 = require("../with-react");
12
- const deprecation_1 = require("../../src/utils/deprecation");
9
+ const webpack_1 = require("webpack");
10
+ const apply_react_config_1 = require("../nx-react-webpack-plugin/lib/apply-react-config");
13
11
  const merge_plugins_1 = require("./merge-plugins");
14
12
  // This is shamelessly taken from CRA and modified for NX use
15
13
  // https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
@@ -120,7 +118,6 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
120
118
  catch {
121
119
  throw new Error(`'@nx/webpack' package is not installed. Install it and try again.`);
122
120
  }
123
- const { withNx, withWeb } = require('@nx/webpack');
124
121
  const projectData = await getProjectData(options);
125
122
  const tsconfigPath = (0, fs_1.existsSync)((0, path_1.join)(projectData.projectRoot, 'tsconfig.storybook.json'))
126
123
  ? (0, path_1.join)(projectData.projectRoot, 'tsconfig.storybook.json')
@@ -141,18 +138,21 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
141
138
  extractCss: storybookWebpackConfig.mode === 'production',
142
139
  target: 'web',
143
140
  };
144
- // ESM build for modern browsers.
145
- let baseWebpackConfig = {};
146
- // Nx composes these helpers internally for the storybook preset; suppress
147
- // their deprecation warning so it fires only for user-authored configs.
148
- const finalConfig = (0, internal_2.suppressWebpackComposeHelperWarnings)(() => (0, deprecation_1.suppressReactComposeHelperWarnings)(() => {
149
- const configure = (0, webpack_1.composePluginsSync)(withNx({ target: 'web', skipTypeChecking: true }), (0, with_react_1.withReact)());
150
- return configure(baseWebpackConfig, {
151
- options: builderOptions,
152
- // TODO(JamesHenry): replace as any type assertion with as ExecutorContext once the nx repo is updated to use https://github.com/nrwl/nx/pull/33095
153
- context: { root: devkit_1.workspaceRoot }, // The context is not used here.
154
- });
155
- }));
141
+ const finalConfig = {};
142
+ const configOptions = {
143
+ ...builderOptions,
144
+ projectName: undefined,
145
+ targetName: undefined,
146
+ configurationName: undefined,
147
+ projectGraph: undefined,
148
+ };
149
+ (0, internal_2.applyBaseConfig)({
150
+ ...configOptions,
151
+ assets: builderOptions.assets ?? [],
152
+ skipTypeChecking: true,
153
+ }, finalConfig);
154
+ (0, internal_2.applyWebConfig)(configOptions, finalConfig);
155
+ (0, apply_react_config_1.applyReactConfig)({}, finalConfig);
156
156
  return {
157
157
  ...storybookWebpackConfig,
158
158
  module: {
@@ -176,7 +176,7 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
176
176
  []), ...(finalConfig.resolve
177
177
  .plugins ?? [])),
178
178
  },
179
- plugins: (0, merge_plugins_1.mergePlugins)(new webpack_2.DefinePlugin(getClientEnvironment(storybookWebpackConfig.mode).stringified), ...(storybookWebpackConfig.plugins ?? []), ...(finalConfig.plugins ?? [])),
179
+ plugins: (0, merge_plugins_1.mergePlugins)(new webpack_1.DefinePlugin(getClientEnvironment(storybookWebpackConfig.mode).stringified), ...(storybookWebpackConfig.plugins ?? []), ...(finalConfig.plugins ?? [])),
180
180
  };
181
181
  };
182
182
  exports.webpack = webpack;
@@ -3,11 +3,7 @@ import type { NxWebpackExecutionContext, WithWebOptions } from '@nx/webpack';
3
3
  export interface WithReactOptions extends WithWebOptions {
4
4
  }
5
5
  /**
6
- * @deprecated Will be removed in Nx v24. Use `NxReactWebpackPlugin` from
7
- * `@nx/react/webpack-plugin` in a standard webpack config and run
8
- * `nx g @nx/webpack:convert-to-inferred`. See
9
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
10
- * @param {WithReactOptions} pluginOptions
11
- * @returns {NxWebpackPlugin}
6
+ * @deprecated Use `NxReactWebpackPlugin` from `@nx/react/webpack-plugin`.
7
+ * This inert stub will be removed in Nx v25.
12
8
  */
13
- export declare function withReact(pluginOptions?: WithReactOptions): (config: Configuration, context: NxWebpackExecutionContext) => Configuration;
9
+ export declare function withReact(_options?: WithReactOptions): (config: Configuration, _context?: NxWebpackExecutionContext) => Configuration;
@@ -1,27 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withReact = withReact;
4
- const apply_react_config_1 = require("./nx-react-webpack-plugin/lib/apply-react-config");
5
4
  const deprecation_1 = require("../src/utils/deprecation");
6
- const processed = new Set();
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
7
6
  /**
8
- * @deprecated Will be removed in Nx v24. Use `NxReactWebpackPlugin` from
9
- * `@nx/react/webpack-plugin` in a standard webpack config and run
10
- * `nx g @nx/webpack:convert-to-inferred`. See
11
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
12
- * @param {WithReactOptions} pluginOptions
13
- * @returns {NxWebpackPlugin}
7
+ * @deprecated Use `NxReactWebpackPlugin` from `@nx/react/webpack-plugin`.
8
+ * This inert stub will be removed in Nx v25.
14
9
  */
15
- function withReact(pluginOptions = {}) {
10
+ function withReact(_options = {}) {
16
11
  (0, deprecation_1.warnReactWithReactDeprecation)();
17
- return function configure(config, context) {
18
- const { withWeb } = require('@nx/webpack');
19
- if (processed.has(config))
20
- return config;
21
- // Apply web config for CSS, JSX, index.html handling, etc.
22
- config = withWeb(pluginOptions)(config, context);
23
- (0, apply_react_config_1.applyReactConfig)({}, config);
24
- processed.add(config);
25
- return config;
26
- };
12
+ return (config, _context) => config;
27
13
  }
@@ -0,0 +1 @@
1
+ export { waitForReactRouterServe as waitForDevServer } from './src/utils/react-router-serve-ready-check';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitForDevServer = void 0;
4
+ var react_router_serve_ready_check_1 = require("./src/utils/react-router-serve-ready-check");
5
+ Object.defineProperty(exports, "waitForDevServer", { enumerable: true, get: function () { return react_router_serve_ready_check_1.waitForReactRouterServe; } });
@@ -48,6 +48,7 @@ function bundlerDeps(bundler) {
48
48
  dependencies: {},
49
49
  devDependencies: {
50
50
  '@module-federation/vite': mfVersions.moduleFederationVitePluginVersion,
51
+ '@nx/vite': versions_2.nxVersion,
51
52
  '@vitejs/plugin-react': mfVersions.vitejsPluginReactVersion,
52
53
  vite: mfVersions.viteVersion,
53
54
  },
@@ -57,6 +58,7 @@ function bundlerDeps(bundler) {
57
58
  dependencies: {},
58
59
  devDependencies: {
59
60
  '@module-federation/rsbuild-plugin': mfVersions.moduleFederationRsbuildPluginVersion,
61
+ '@nx/rsbuild': versions_2.nxVersion,
60
62
  '@rsbuild/core': mfVersions.rsbuildCoreVersion,
61
63
  '@rsbuild/plugin-react': mfVersions.rsbuildPluginReactVersion,
62
64
  },
@@ -69,6 +71,7 @@ function bundlerDeps(bundler) {
69
71
  '@module-federation/enhanced': mfVersions.moduleFederationEnhancedVersion,
70
72
  },
71
73
  devDependencies: {
74
+ '@nx/rspack': versions_2.nxVersion,
72
75
  '@rspack/cli': mfVersions.rspackCliVersion,
73
76
  '@rspack/core': mfVersions.rspackCoreVersion,
74
77
  '@rspack/dev-server': mfVersions.rspackDevServerVersion,
@@ -26,7 +26,6 @@ const add_rsbuild_1 = require("./lib/bundlers/add-rsbuild");
26
26
  const add_vite_1 = require("./lib/bundlers/add-vite");
27
27
  async function applicationGenerator(tree, schema) {
28
28
  return await applicationGeneratorInternal(tree, {
29
- addPlugin: false,
30
29
  useProjectJson: true,
31
30
  ...schema,
32
31
  });
@@ -34,7 +33,7 @@ async function applicationGenerator(tree, schema) {
34
33
  async function applicationGeneratorInternal(tree, schema) {
35
34
  (0, assert_supported_react_version_1.assertSupportedReactVersion)(tree);
36
35
  const tasks = [];
37
- const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin, schema.useTsSolution);
36
+ const addTsPlugin = (0, internal_2.shouldConfigureTsSolutionSetup)(tree, schema.useTsSolution);
38
37
  const jsInitTask = await (0, js_1.initGenerator)(tree, {
39
38
  ...schema,
40
39
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
@@ -59,25 +58,6 @@ async function applicationGeneratorInternal(tree, schema) {
59
58
  useReactRouterPlugin: options.useReactRouter,
60
59
  });
61
60
  tasks.push(initTask);
62
- if (!options.addPlugin) {
63
- const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
64
- const existing = findBuildDefault(nxJson.targetDefaults);
65
- if (!existing) {
66
- (0, internal_1.upsertTargetDefault)(tree, nxJson, {
67
- target: 'build',
68
- cache: true,
69
- dependsOn: ['^build'],
70
- });
71
- (0, devkit_1.updateNxJson)(tree, nxJson);
72
- }
73
- else if (!existing.dependsOn) {
74
- (0, internal_1.upsertTargetDefault)(tree, nxJson, {
75
- target: 'build',
76
- dependsOn: ['^build'],
77
- });
78
- (0, devkit_1.updateNxJson)(tree, nxJson);
79
- }
80
- }
81
61
  if (options.bundler === 'webpack') {
82
62
  await (0, add_webpack_1.initWebpack)(tree, options, tasks);
83
63
  }
@@ -160,19 +140,4 @@ async function applicationGeneratorInternal(tree, schema) {
160
140
  });
161
141
  return (0, devkit_1.runTasksInSerial)(...tasks);
162
142
  }
163
- function findBuildDefault(td) {
164
- if (!td)
165
- return undefined;
166
- const value = td['build'];
167
- if (value === undefined)
168
- return undefined;
169
- if (Array.isArray(value)) {
170
- const found = value.find((e) => e.filter === undefined);
171
- if (!found)
172
- return undefined;
173
- const { filter: _f, ...rest } = found;
174
- return rest;
175
- }
176
- return value;
177
- }
178
143
  exports.default = applicationGenerator;
@@ -1,4 +1,3 @@
1
- <%_ if (rspackPluginOptions) { _%>
2
1
  const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
3
2
  const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
4
3
  const { join } = require('path');
@@ -29,17 +28,3 @@ module.exports = {
29
28
  new NxReactRspackPlugin(),
30
29
  ],
31
30
  };
32
- <%_ } else { _%>
33
- const { composePlugins, withNx, withReact } = require('@nx/rspack');
34
-
35
- // Nx plugins for rspack.
36
- module.exports = composePlugins(
37
- withNx(),
38
- withReact(),
39
- (config) => {
40
- // Update the rspack config as needed here.
41
- // e.g. `config.plugins.push(new MyPlugin())`
42
- return config;
43
- }
44
- );
45
- <%_ } _%>
@@ -1,4 +1,3 @@
1
- <%_ if (webpackPluginOptions) { _%>
2
1
  const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
3
2
  const { NxReactWebpackPlugin } = require('@nx/react/webpack-plugin');
4
3
  const { join } = require('path');
@@ -31,19 +30,3 @@ module.exports = {
31
30
  new NxReactWebpackPlugin(),
32
31
  ],
33
32
  };
34
- <%_ } else { _%>
35
- const { composePlugins, withNx } = require('@nx/webpack');
36
- const { withReact } = require('@nx/react');
37
-
38
- // Nx plugins for webpack.
39
- module.exports = composePlugins(
40
- withNx(),
41
- withReact(),
42
- (config) => {
43
- // Update the webpack config as needed here.
44
- // e.g. `config.plugins.push(new MyPlugin())`
45
- config.output.clean = true;
46
- return config;
47
- }
48
- );
49
- <%_ } _%>
@@ -24,26 +24,26 @@ async function addE2e(tree, options) {
24
24
  };
25
25
  if (options.bundler === 'webpack') {
26
26
  const { getWebpackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
27
- e2eWebServerInfo = await getWebpackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.port);
27
+ e2eWebServerInfo = await getWebpackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.${options.js ? 'js' : 'ts'}`), options.port);
28
28
  }
29
29
  else if (options.bundler === 'rspack') {
30
30
  const { getRspackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
31
- e2eWebServerInfo = await getRspackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `rspack.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.port);
31
+ e2eWebServerInfo = await getRspackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `rspack.config.${options.js ? 'js' : 'ts'}`), options.port);
32
32
  }
33
33
  else if (options.bundler === 'vite') {
34
34
  const { getViteE2EWebServerInfo, getReactRouterE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
35
35
  e2eWebServerInfo = options.useReactRouter
36
- ? await getReactRouterE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.port ?? 4200,
36
+ ? await getReactRouterE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.port ?? 4200,
37
37
  // If the user manually sets the port, then use it for dev and preview
38
38
  options.port)
39
- : await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.port ?? 4200,
39
+ : await getViteE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `vite.config.${options.js ? 'js' : 'ts'}`), options.port ?? 4200,
40
40
  // If the user manually sets the port, then use it for dev and preview
41
41
  options.port);
42
42
  }
43
43
  else if (options.bundler === 'rsbuild') {
44
44
  (0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
45
45
  const { getRsbuildE2EWebServerInfo, } = require('@nx/rsbuild/config-utils');
46
- e2eWebServerInfo = await getRsbuildE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `rsbuild.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.port ?? 4200);
46
+ e2eWebServerInfo = await getRsbuildE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `rsbuild.config.${options.js ? 'js' : 'ts'}`), options.port ?? 4200);
47
47
  }
48
48
  if (!hasNxBuildPlugin) {
49
49
  await (0, web_1.webStaticServeGenerator)(tree, {
@@ -138,10 +138,11 @@ async function addE2e(tree, options) {
138
138
  js: false,
139
139
  linter: options.linter,
140
140
  enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
141
- webServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
142
- webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
141
+ webServerCommand: e2eWebServerInfo.e2eWebServerCommand,
142
+ webServerAddress: e2eWebServerInfo.e2eWebServerAddress,
143
+ ciWebServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
144
+ ciWebServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
143
145
  rootProject: options.rootProject,
144
- addPlugin: options.addPlugin,
145
146
  });
146
147
  return e2eTask;
147
148
  }
@@ -22,7 +22,6 @@ async function addLinting(host, options) {
22
22
  rootProject: options.rootProject,
23
23
  skipPackageJson: options.skipPackageJson,
24
24
  enableTypedLinting: (0, internal_1.isTypedLintingEnabled)(options),
25
- addPlugin: options.addPlugin,
26
25
  }));
27
26
  // Predefined configs, `extends` and ignore entries are ESLint concepts with
28
27
  // no equivalent in other linters.