@nx/rspack 24.0.0-beta.1 → 24.0.0-beta.3

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 (79) hide show
  1. package/dist/src/executors/dev-server/dev-server.impl.js +0 -2
  2. package/dist/src/executors/rspack/lib/config.js +18 -8
  3. package/dist/src/generators/configuration/configuration.js +2 -24
  4. package/dist/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.js +78 -45
  5. package/dist/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.d.ts +1 -0
  6. package/dist/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.js +31 -2
  7. package/dist/src/generators/convert-config-to-rspack-plugin/schema.json +2 -2
  8. package/dist/src/generators/convert-to-inferred/convert-to-inferred.js +5 -4
  9. package/dist/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +13 -5
  10. package/dist/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +8 -14
  11. package/dist/src/generators/convert-webpack/convert-webpack.js +20 -74
  12. package/dist/src/generators/convert-webpack/lib/transform-plugin-config.d.ts +1 -1
  13. package/dist/src/generators/convert-webpack/lib/transform-plugin-config.js +47 -69
  14. package/dist/src/generators/init/init.js +38 -44
  15. package/dist/src/generators/init/schema.d.ts +0 -1
  16. package/dist/src/migrations/update-24-0-0/finish-inferred-conversion.md +11 -0
  17. package/dist/src/migrations/update-24-0-0/inventory.d.ts +9 -0
  18. package/dist/src/migrations/update-24-0-0/inventory.js +53 -0
  19. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.d.ts +10 -0
  20. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.js +60 -0
  21. package/dist/src/migrations/update-24-0-0/migrate-compose-plugins.md +95 -0
  22. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.d.ts +6 -0
  23. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.js +36 -0
  24. package/dist/src/migrations/update-24-0-0/remove-deprecated-executors.md +90 -0
  25. package/dist/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.js +4 -1
  26. package/dist/src/utils/config.d.ts +10 -14
  27. package/dist/src/utils/config.js +17 -70
  28. package/dist/src/utils/deprecation.d.ts +1 -6
  29. package/dist/src/utils/deprecation.js +4 -23
  30. package/dist/src/utils/e2e-web-server-info-utils.d.ts +1 -1
  31. package/dist/src/utils/e2e-web-server-info-utils.js +2 -2
  32. package/dist/src/utils/generator-utils.d.ts +0 -2
  33. package/dist/src/utils/generator-utils.js +45 -167
  34. package/dist/src/utils/with-nx.d.ts +5 -9
  35. package/dist/src/utils/with-nx.js +5 -32
  36. package/dist/src/utils/with-react.d.ts +5 -8
  37. package/dist/src/utils/with-react.js +5 -15
  38. package/dist/src/utils/with-web.d.ts +5 -8
  39. package/dist/src/utils/with-web.js +5 -44
  40. package/executors.json +0 -25
  41. package/migrations.json +13 -0
  42. package/package.json +6 -25
  43. package/dist/module-federation.d.ts +0 -4
  44. package/dist/module-federation.js +0 -9
  45. package/dist/src/executors/module-federation-dev-server/lib/index.d.ts +0 -2
  46. package/dist/src/executors/module-federation-dev-server/lib/index.js +0 -5
  47. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.d.ts +0 -4
  48. package/dist/src/executors/module-federation-dev-server/lib/normalize-options.js +0 -19
  49. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.d.ts +0 -5
  50. package/dist/src/executors/module-federation-dev-server/lib/start-remotes.js +0 -33
  51. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -6
  52. package/dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -74
  53. package/dist/src/executors/module-federation-dev-server/schema.d.ts +0 -25
  54. package/dist/src/executors/module-federation-dev-server/schema.json +0 -104
  55. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.d.ts +0 -2
  56. package/dist/src/executors/module-federation-ssr-dev-server/lib/index.js +0 -5
  57. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.d.ts +0 -4
  58. package/dist/src/executors/module-federation-ssr-dev-server/lib/normalize-options.js +0 -23
  59. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.d.ts +0 -5
  60. package/dist/src/executors/module-federation-ssr-dev-server/lib/start-remotes.js +0 -34
  61. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +0 -5
  62. package/dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -65
  63. package/dist/src/executors/module-federation-ssr-dev-server/schema.d.ts +0 -29
  64. package/dist/src/executors/module-federation-ssr-dev-server/schema.json +0 -85
  65. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +0 -12
  66. package/dist/src/executors/module-federation-static-server/module-federation-static-server.impl.js +0 -237
  67. package/dist/src/executors/module-federation-static-server/schema.d.ts +0 -3
  68. package/dist/src/executors/module-federation-static-server/schema.json +0 -16
  69. package/dist/src/executors/rspack/rspack.impl.d.ts +0 -7
  70. package/dist/src/executors/rspack/rspack.impl.js +0 -127
  71. package/dist/src/executors/rspack/schema.json +0 -410
  72. package/dist/src/generators/convert-webpack/lib/transform-cjs.d.ts +0 -2
  73. package/dist/src/generators/convert-webpack/lib/transform-cjs.js +0 -263
  74. package/dist/src/generators/convert-webpack/lib/transform-esm.d.ts +0 -2
  75. package/dist/src/generators/convert-webpack/lib/transform-esm.js +0 -263
  76. package/dist/src/utils/has-plugin.d.ts +0 -2
  77. package/dist/src/utils/has-plugin.js +0 -10
  78. package/dist/src/utils/module-federation-deprecation.d.ts +0 -6
  79. package/dist/src/utils/module-federation-deprecation.js +0 -30
@@ -1,6 +1,6 @@
1
- import { ExecutorContext } from '@nx/devkit';
1
+ import type { ExecutorContext } from '@nx/devkit';
2
2
  import type { Configuration } from '@rspack/core';
3
- import { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
3
+ import type { NormalizedRspackExecutorSchema } from '../executors/rspack/schema';
4
4
  export declare const nxRspackComposablePlugin = "nxRspackComposablePlugin";
5
5
  export declare function isNxRspackComposablePlugin(a: unknown): a is AsyncNxComposableRspackPlugin;
6
6
  export interface NxRspackExecutionContext {
@@ -15,22 +15,18 @@ export interface AsyncNxComposableRspackPlugin {
15
15
  (config: Configuration, ctx: NxRspackExecutionContext): Configuration | Promise<Configuration>;
16
16
  }
17
17
  /**
18
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
19
- * `@nx/rspack/app-plugin` (or `NxReactRspackPlugin` from
20
- * `@nx/rspack/react-plugin`) in a standard rspack config and run
21
- * `nx g @nx/rspack:convert-to-inferred`. See
22
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
18
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
19
+ * from `@nx/rspack/react-plugin`).
20
+ * This inert stub will be removed in Nx v25.
23
21
  */
24
- export declare function composePlugins(...plugins: (NxComposableRspackPlugin | AsyncNxComposableRspackPlugin | Promise<NxComposableRspackPlugin | AsyncNxComposableRspackPlugin>)[]): ((config: Configuration, ctx: NxRspackExecutionContext) => Promise<Configuration>) & {
22
+ export declare function composePlugins(..._plugins: (NxComposableRspackPlugin | AsyncNxComposableRspackPlugin | Promise<NxComposableRspackPlugin | AsyncNxComposableRspackPlugin>)[]): ((config?: Configuration, ctx?: NxRspackExecutionContext) => Promise<Configuration>) & {
25
23
  nxRspackComposablePlugin: boolean;
26
24
  };
27
25
  /**
28
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
29
- * `@nx/rspack/app-plugin` (or `NxReactRspackPlugin` from
30
- * `@nx/rspack/react-plugin`) in a standard rspack config and run
31
- * `nx g @nx/rspack:convert-to-inferred`. See
32
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
26
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
27
+ * from `@nx/rspack/react-plugin`).
28
+ * This inert stub will be removed in Nx v25.
33
29
  */
34
- export declare function composePluginsSync(...plugins: NxComposableRspackPlugin[]): ((config: Configuration, ctx: NxRspackExecutionContext) => Configuration) & {
30
+ export declare function composePluginsSync(..._plugins: NxComposableRspackPlugin[]): ((config?: Configuration, ctx?: NxRspackExecutionContext) => Configuration) & {
35
31
  nxRspackComposablePlugin: boolean;
36
32
  };
@@ -4,86 +4,33 @@ exports.nxRspackComposablePlugin = void 0;
4
4
  exports.isNxRspackComposablePlugin = isNxRspackComposablePlugin;
5
5
  exports.composePlugins = composePlugins;
6
6
  exports.composePluginsSync = composePluginsSync;
7
- const devkit_1 = require("@nx/devkit");
8
- const internal_1 = require("@nx/js/internal");
9
7
  const deprecation_1 = require("./deprecation");
10
- const internal_2 = require("@nx/devkit/internal");
11
8
  exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
12
9
  function isNxRspackComposablePlugin(a) {
13
10
  return a?.[exports.nxRspackComposablePlugin] === true;
14
11
  }
12
+ // TODO(v25): remove the inert config-helper stubs in this file.
15
13
  /**
16
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
17
- * `@nx/rspack/app-plugin` (or `NxReactRspackPlugin` from
18
- * `@nx/rspack/react-plugin`) in a standard rspack config and run
19
- * `nx g @nx/rspack:convert-to-inferred`. See
20
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
14
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
15
+ * from `@nx/rspack/react-plugin`).
16
+ * This inert stub will be removed in Nx v25.
21
17
  */
22
- function composePlugins(...plugins) {
18
+ function composePlugins(..._plugins) {
23
19
  (0, deprecation_1.warnRspackComposeHelpersDeprecation)();
24
- return Object.assign(async function combined(config, ctx) {
25
- // Rspack may be calling us as a standard config function.
26
- // Build up Nx context from environment variables.
27
- // This is to enable `@nx/rspack/plugin` to work with existing projects.
28
- if (ctx['env']) {
29
- ensureNxRspackExecutionContext(ctx);
30
- // Build this from scratch since what rspack passes us is the env, not config,
31
- // and `withNX()` creates a new config object anyway.
32
- config = {};
33
- }
34
- for (const plugin of plugins) {
35
- const fn = await plugin;
36
- config = await fn(config, ctx);
37
- }
38
- return config;
39
- }, {
40
- [exports.nxRspackComposablePlugin]: true,
41
- });
20
+ return Object.assign(async (config = {}, ctx) => {
21
+ // Only the legacy Nx executor passes a config; CLIs pass (env, argv).
22
+ return ctx?.context && typeof ctx.context === 'object' ? config : {};
23
+ }, { [exports.nxRspackComposablePlugin]: true });
42
24
  }
43
25
  /**
44
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
45
- * `@nx/rspack/app-plugin` (or `NxReactRspackPlugin` from
46
- * `@nx/rspack/react-plugin`) in a standard rspack config and run
47
- * `nx g @nx/rspack:convert-to-inferred`. See
48
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
26
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin` (or `NxReactRspackPlugin`
27
+ * from `@nx/rspack/react-plugin`).
28
+ * This inert stub will be removed in Nx v25.
49
29
  */
50
- function composePluginsSync(...plugins) {
30
+ function composePluginsSync(..._plugins) {
51
31
  (0, deprecation_1.warnRspackComposeHelpersDeprecation)();
52
- return Object.assign(function combined(config, ctx) {
53
- for (const plugin of plugins) {
54
- config = plugin(config, ctx);
55
- }
56
- return config;
57
- }, {
58
- [exports.nxRspackComposablePlugin]: true,
59
- });
60
- }
61
- function ensureNxRspackExecutionContext(ctx) {
62
- const projectName = process.env.NX_TASK_TARGET_PROJECT;
63
- const targetName = process.env.NX_TASK_TARGET_TARGET;
64
- const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
65
- const projectGraph = (0, devkit_1.readCachedProjectGraph)();
66
- const projectNode = projectGraph.nodes[projectName];
67
- ctx.options ??= {
68
- root: devkit_1.workspaceRoot,
69
- projectRoot: projectNode.data.root,
70
- sourceRoot: (0, internal_1.getProjectSourceRoot)(projectNode.data),
71
- // These aren't actually needed since NxRspackPlugin and withNx both support them being undefined.
72
- assets: undefined,
73
- outputFileName: undefined,
74
- outputPath: undefined,
75
- rspackConfig: undefined,
76
- useTsconfigPaths: undefined,
77
- };
78
- ctx.context ??= {
79
- projectName,
80
- targetName,
81
- configurationName,
82
- projectsConfigurations: (0, devkit_1.readProjectsConfigurationFromProjectGraph)(projectGraph),
83
- nxJsonConfiguration: (0, internal_2.readNxJsonFromDisk)(devkit_1.workspaceRoot),
84
- cwd: process.cwd(),
85
- root: devkit_1.workspaceRoot,
86
- isVerbose: process.env['NX_VERBOSE_LOGGING'] === 'true',
87
- projectGraph,
88
- };
32
+ return Object.assign((config = {}, ctx) => {
33
+ // Only the legacy Nx executor passes a config; CLIs pass (env, argv).
34
+ return ctx?.context && typeof ctx.context === 'object' ? config : {};
35
+ }, { [exports.nxRspackComposablePlugin]: true });
89
36
  }
@@ -1,8 +1,3 @@
1
- export declare const RSPACK_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/rspack:rspack` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
2
- export declare const RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/rspack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
3
- export declare function warnRspackExecutorDeprecation(): void;
4
- export declare function warnRspackDevServerExecutorDeprecation(): void;
5
- export declare function warnRspackExecutorGenerating(): void;
6
- export declare const RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The `composePlugins`, `withNx`, `withWeb`, and `withReact` config helpers from `@nx/rspack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/rspack:rspack` executor. Migrate to a standard rspack config that uses `NxAppRspackPlugin` (from `@nx/rspack/app-plugin`) or `NxReactRspackPlugin` (from `@nx/rspack/react-plugin`) under the inferred `@nx/rspack/plugin` by running `nx g @nx/rspack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
1
+ export declare const RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = "The compose config helpers from `@nx/rspack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard rspack config using `NxAppRspackPlugin` from `@nx/rspack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.";
7
2
  export declare function suppressRspackComposeHelperWarnings<T>(fn: () => T): T;
8
3
  export declare function warnRspackComposeHelpersDeprecation(): void;
@@ -1,31 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = exports.RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = exports.RSPACK_EXECUTOR_DEPRECATION_MESSAGE = void 0;
4
- exports.warnRspackExecutorDeprecation = warnRspackExecutorDeprecation;
5
- exports.warnRspackDevServerExecutorDeprecation = warnRspackDevServerExecutorDeprecation;
6
- exports.warnRspackExecutorGenerating = warnRspackExecutorGenerating;
3
+ exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = void 0;
7
4
  exports.suppressRspackComposeHelperWarnings = suppressRspackComposeHelperWarnings;
8
5
  exports.warnRspackComposeHelpersDeprecation = warnRspackComposeHelpersDeprecation;
9
6
  const devkit_1 = require("@nx/devkit");
10
- // TODO(v24): Remove the @nx/rspack:rspack and @nx/rspack:dev-server
11
- // executors. The inferred plugin (@nx/rspack/plugin) and the
12
- // convert-to-inferred generator stay supported.
13
- exports.RSPACK_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/rspack:rspack` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
14
- exports.RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/rspack:dev-server` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` to migrate to the `@nx/rspack/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
15
- function warnRspackExecutorDeprecation() {
16
- devkit_1.logger.warn(exports.RSPACK_EXECUTOR_DEPRECATION_MESSAGE);
17
- }
18
- function warnRspackDevServerExecutorDeprecation() {
19
- devkit_1.logger.warn(exports.RSPACK_DEV_SERVER_EXECUTOR_DEPRECATION_MESSAGE);
20
- }
21
- function warnRspackExecutorGenerating() {
22
- devkit_1.logger.warn('Generating targets that use the deprecated `@nx/rspack:rspack` and `@nx/rspack:dev-server` executors. These executors will be removed in Nx v24. Run `nx g @nx/rspack:convert-to-inferred` next to migrate these targets to the `@nx/rspack/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
23
- }
24
- // TODO(v24): Remove the composePlugins/withNx/withWeb/withReact config helpers.
25
- // They emit an Nx-specific config function that only runs under the
26
- // @nx/rspack:rspack executor; the inferred @nx/rspack/plugin works with standard
27
- // rspack configs built around NxAppRspackPlugin/NxReactRspackPlugin instead.
28
- exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The `composePlugins`, `withNx`, `withWeb`, and `withReact` config helpers from `@nx/rspack` are deprecated and will be removed in Nx v24. They produce an Nx-specific config function that only runs under the `@nx/rspack:rspack` executor. Migrate to a standard rspack config that uses `NxAppRspackPlugin` (from `@nx/rspack/app-plugin`) or `NxReactRspackPlugin` (from `@nx/rspack/react-plugin`) under the inferred `@nx/rspack/plugin` by running `nx g @nx/rspack:convert-to-inferred`. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
7
+ // Helper behavior was removed in v24; exports remain only as inert stubs.
8
+ // Keep their exports loadable so old configs do not block graph creation.
9
+ exports.RSPACK_COMPOSE_HELPERS_DEPRECATION_MESSAGE = 'The compose config helpers from `@nx/rspack` were removed in Nx v24. The remaining exports are inert compatibility stubs and do not configure builds. Migrate to a standard rspack config using `NxAppRspackPlugin` from `@nx/rspack/app-plugin`. Follow the config-helper migration instructions generated by `nx migrate`. Executor conversion is a separate migration.';
29
10
  let composeHelpersWarned = false;
30
11
  let suppressDepth = 0;
31
12
  // Nx-internal entry points compose these helpers themselves (e.g. the rspack
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function getRspackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, isPluginBeingAdded: boolean, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
2
+ export declare function getRspackE2EWebServerInfo(tree: Tree, projectName: string, configFilePath: string, e2ePortOverride?: number): Promise<import("@nx/devkit/internal").E2EWebServerDetails>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRspackE2EWebServerInfo = getRspackE2EWebServerInfo;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const internal_1 = require("@nx/devkit/internal");
6
- async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPluginBeingAdded, e2ePortOverride) {
6
+ async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, e2ePortOverride) {
7
7
  const nxJson = (0, devkit_1.readNxJson)(tree);
8
8
  let e2ePort = e2ePortOverride ?? 4200;
9
9
  const servePort = (0, internal_1.readTargetDefaultsForTarget)('serve', nxJson.targetDefaults)
@@ -26,5 +26,5 @@ async function getRspackE2EWebServerInfo(tree, projectName, configFilePath, isPl
26
26
  defaultE2ECiBaseUrl: `http://localhost:${e2ePort}`,
27
27
  defaultE2EPort: e2ePort,
28
28
  e2EPortIsExplicit: e2ePortOverride != null,
29
- }, isPluginBeingAdded);
29
+ });
30
30
  }
@@ -13,8 +13,6 @@ export declare function findExistingTargetsInProject(targets: {
13
13
  userProvidedTargetIsUnsupported: TargetFlags;
14
14
  alreadyHasNxRspackTargets: TargetFlags;
15
15
  };
16
- export declare function addOrChangeBuildTarget(tree: Tree, options: ConfigurationSchema, target: string): void;
17
- export declare function addOrChangeServeTarget(tree: Tree, options: ConfigurationSchema, target: string): void;
18
16
  export declare function writeRspackConfigFile(tree: Tree, options: ConfigurationSchema, stylePreprocessorOptions?: {
19
17
  includePaths?: string[];
20
18
  }): void;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findExistingTargetsInProject = findExistingTargetsInProject;
4
- exports.addOrChangeBuildTarget = addOrChangeBuildTarget;
5
- exports.addOrChangeServeTarget = addOrChangeServeTarget;
6
4
  exports.writeRspackConfigFile = writeRspackConfigFile;
7
5
  exports.deleteWebpackConfig = deleteWebpackConfig;
8
6
  exports.moveAndEditIndexHtml = moveAndEditIndexHtml;
@@ -16,7 +14,6 @@ exports.determineTsConfig = determineTsConfig;
16
14
  const internal_1 = require("@nx/devkit/internal");
17
15
  const devkit_1 = require("@nx/devkit");
18
16
  const internal_2 = require("@nx/js/internal");
19
- const has_plugin_1 = require("./has-plugin");
20
17
  function findExistingTargetsInProject(targets, userProvidedTargets) {
21
18
  const output = {
22
19
  validFoundTargetName: {},
@@ -120,75 +117,6 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
120
117
  }
121
118
  return output;
122
119
  }
123
- function addOrChangeBuildTarget(tree, options, target) {
124
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
125
- const assets = [];
126
- if (options.target === 'web' &&
127
- tree.exists((0, devkit_1.joinPathFragments)(project.root, 'src/favicon.ico'))) {
128
- assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/favicon.ico'));
129
- }
130
- if (tree.exists((0, devkit_1.joinPathFragments)(project.root, 'src/assets'))) {
131
- assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/assets'));
132
- }
133
- const isTsSolutionSetup = (0, internal_2.isUsingTsSolutionSetup)(tree);
134
- const buildOptions = {
135
- target: options.target ?? 'web',
136
- outputPath: isTsSolutionSetup
137
- ? (0, devkit_1.joinPathFragments)(project.root, 'dist')
138
- : (0, devkit_1.joinPathFragments)('dist',
139
- // If standalone project then use the project's name in dist.
140
- project.root === '.' ? project.name : project.root),
141
- index: (0, devkit_1.joinPathFragments)(project.root, 'src/index.html'),
142
- main: determineMain(tree, options),
143
- tsConfig: determineTsConfig(tree, options),
144
- rspackConfig: (0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'),
145
- assets,
146
- };
147
- const existingProjectConfigurations = {};
148
- const buildTarget = project.targets.build;
149
- if (buildTarget && buildTarget.configurations) {
150
- for (const [configurationName, configuration] of Object.entries(buildTarget.configurations)) {
151
- existingProjectConfigurations[configurationName] = configuration;
152
- }
153
- }
154
- project.targets ??= {};
155
- project.targets[target] = {
156
- executor: '@nx/rspack:rspack',
157
- outputs: ['{options.outputPath}'],
158
- defaultConfiguration: 'production',
159
- options: buildOptions,
160
- configurations: {
161
- development: {
162
- ...(existingProjectConfigurations['development'] ?? {}),
163
- mode: 'development',
164
- },
165
- production: {
166
- ...(existingProjectConfigurations['production'] ?? {}),
167
- mode: 'production',
168
- optimization: options.target === 'web' ? true : undefined,
169
- sourceMap: false,
170
- },
171
- },
172
- };
173
- (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
174
- }
175
- function addOrChangeServeTarget(tree, options, target) {
176
- const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
177
- project.targets ??= {};
178
- project.targets[target] = {
179
- executor: '@nx/rspack:dev-server',
180
- options: {
181
- buildTarget: `${options.project}:build:development`,
182
- },
183
- configurations: {
184
- development: {},
185
- production: {
186
- buildTarget: `${options.project}:build:production`,
187
- },
188
- },
189
- };
190
- (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
191
- }
192
120
  function writeRspackConfigFile(tree, options, stylePreprocessorOptions) {
193
121
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
194
122
  tree.write((0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'), createConfig(tree, { ...options, stylePreprocessorOptions }));
@@ -198,17 +126,12 @@ function createConfig(tree, options) {
198
126
  const buildOptions = createBuildOptions(tree, options, project);
199
127
  const defaultConfig = generateDefaultConfig(project, buildOptions);
200
128
  if (options.framework === 'react') {
201
- return generateReactConfig(options);
202
- }
203
- else if (isWebFramework(options)) {
204
- return generateWebConfig(tree, options, defaultConfig);
129
+ return generateReactConfig(tree, options, project, buildOptions);
205
130
  }
206
- else if (options.framework === 'nest') {
207
- return generateNestConfig(tree, options, project, buildOptions);
208
- }
209
- else {
210
- return generateGenericConfig(tree, options, defaultConfig);
131
+ else if (options.framework === 'nest' && !isWebFramework(options)) {
132
+ return generateNestConfig(project, buildOptions);
211
133
  }
134
+ return defaultConfig;
212
135
  }
213
136
  function createBuildOptions(tree, options, project) {
214
137
  return {
@@ -241,41 +164,38 @@ module.exports = {
241
164
  function isWebFramework(options) {
242
165
  return options.framework === 'web' || options.target === 'web';
243
166
  }
244
- function generateWebConfig(tree, options, defaultConfig) {
245
- if ((0, has_plugin_1.hasPlugin)(tree)) {
246
- return defaultConfig;
247
- }
167
+ function generateReactConfig(tree, options, project, buildOptions) {
168
+ const assets = ['src/favicon.ico', 'src/assets']
169
+ .map((asset) => (0, devkit_1.joinPathFragments)(project.root, asset))
170
+ .filter((asset) => tree.exists(asset));
248
171
  return `
249
- const { composePlugins, withNx, withWeb } = require('@nx/rspack');
250
- module.exports = composePlugins(withNx(), withWeb(${options.stylePreprocessorOptions
172
+ const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
173
+ const { NxReactRspackPlugin } = require('@nx/rspack/react-plugin');
174
+ const { join } = require('path');
175
+
176
+ module.exports = {
177
+ output: {
178
+ path: join(__dirname, '${(0, devkit_1.offsetFromRoot)(project.root)}${buildOptions.outputPath}'),
179
+ },
180
+ plugins: [
181
+ new NxAppRspackPlugin({
182
+ tsConfig: '${buildOptions.tsConfig}',
183
+ main: '${buildOptions.main}',
184
+ index: '${(0, devkit_1.joinPathFragments)(project.root, 'src/index.html')}',
185
+ assets: ${JSON.stringify(assets)},${options.stylePreprocessorOptions
251
186
  ? `
252
- {
253
- stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},
254
- }
255
- `
256
- : ''}), (config) => {
257
- return config;
258
- });
187
+ stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},`
188
+ : ''}
189
+ outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
190
+ optimization: process.env['NODE_ENV'] === 'production',
191
+ }),
192
+ new NxReactRspackPlugin(),
193
+ ],
194
+ };
259
195
  `;
260
196
  }
261
- function generateReactConfig({ stylePreprocessorOptions, }) {
197
+ function generateNestConfig(project, buildOptions) {
262
198
  return `
263
- const { composePlugins, withNx, withReact } = require('@nx/rspack');
264
-
265
- module.exports = composePlugins(withNx(), withReact(${stylePreprocessorOptions
266
- ? `
267
- {
268
- stylePreprocessorOptions: ${JSON.stringify(stylePreprocessorOptions)},
269
- }
270
- `
271
- : ''}), (config) => {
272
- return config;
273
- });
274
- `;
275
- }
276
- function generateNestConfig(tree, options, project, buildOptions) {
277
- if ((0, has_plugin_1.hasPlugin)(tree) && options.addPlugin !== false) {
278
- return `
279
199
  const { NxAppRspackPlugin } = require('@nx/rspack/app-plugin');
280
200
  const rspack = require('@rspack/core');
281
201
  const { join } = require('path');
@@ -309,48 +229,6 @@ module.exports = {
309
229
  })
310
230
  ]
311
231
  }`;
312
- }
313
- return `
314
- const { composePlugins, withNx } = require('@nx/rspack');
315
- const rspack = require('@rspack/core');
316
-
317
- module.exports = composePlugins(withNx(), (config) => {
318
- config.optimization = {
319
- minimizer: [
320
- new rspack.SwcJsMinimizerRspackPlugin({
321
- minimizerOptions: {
322
- compress: {
323
- keep_classnames: true,
324
- keep_fnames: true,
325
- },
326
- mangle: {
327
- keep_classnames: true,
328
- keep_fnames: true,
329
- },
330
- },
331
- }),
332
- ],
333
- };
334
- return config;
335
- });
336
- `;
337
- }
338
- function generateGenericConfig(tree, options, defaultConfig) {
339
- if ((0, has_plugin_1.hasPlugin)(tree)) {
340
- return defaultConfig;
341
- }
342
- return `
343
- const { composePlugins, withNx${options.stylePreprocessorOptions ? ', withWeb' : ''} } = require('@nx/rspack');
344
-
345
- module.exports = composePlugins(withNx()${options.stylePreprocessorOptions
346
- ? `,
347
- withWeb({
348
- stylePreprocessorOptions: ${JSON.stringify(options.stylePreprocessorOptions)},
349
- })`
350
- : ''}, (config) => {
351
- return config;
352
- });
353
- `;
354
232
  }
355
233
  function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
356
234
  const webpackConfigPath = webpackConfigFilePath && tree.exists(webpackConfigFilePath)
@@ -427,52 +305,52 @@ function getViteConfigPathForProject(tree, projectName, target) {
427
305
  }
428
306
  async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
429
307
  if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
430
- await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build', 'rspack');
308
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build');
431
309
  }
432
310
  if (framework !== 'nest' &&
433
311
  userProvidedTargetIsUnsupported.serve &&
434
312
  validFoundTargetName.serve) {
435
- await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve', 'dev-server');
313
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve');
436
314
  }
437
315
  }
438
- async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
439
- devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor.
316
+ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target) {
317
+ devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use Rspack.
440
318
  However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
441
319
 
442
- Please note that converting a potentially non-compatible project to use Vite may result in unexpected behavior. Always commit
443
- your changes before converting a project to use Vite, and test the converted project thoroughly before deploying it.
320
+ Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
321
+ your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
444
322
  `);
445
323
  const shouldConvert = await (0, internal_1.confirmationPrompt)({
446
- message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`,
324
+ message: `Should we convert the ${validFoundTargetName} target to use Rspack?`,
447
325
  });
448
326
  if (!shouldConvert) {
449
- throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor.
327
+ throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use Rspack.
450
328
  Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
451
329
  convert the first one it finds, most probably this one: ${validFoundTargetName})
452
330
 
453
- Please note that converting a potentially non-compatible project to use Vite may result in unexpected behavior. Always commit
454
- your changes before converting a project to use Vite, and test the converted project thoroughly before deploying it.
331
+ Please note that converting a potentially non-compatible project to use Rspack may result in unexpected behavior. Always commit
332
+ your changes before converting a project to use Rspack, and test the converted project thoroughly before deploying it.
455
333
  `);
456
334
  }
457
335
  }
458
336
  async function handleUnknownExecutors(projectName) {
459
337
  devkit_1.logger.warn(`
460
338
  We could not find any targets in project ${projectName} that use executors which
461
- can be converted to the @nx/rspack executors.
339
+ can be converted to Rspack.
462
340
 
463
341
  This either means that your project may not have a target
464
342
  for building, serving, or testing at all, or that your targets are
465
343
  using executors that are not known to Nx.
466
344
 
467
- If you still want to convert your project to use the @nx/rspack executors,
345
+ If you still want to convert your project to use Rspack,
468
346
  please make sure to commit your changes before running this generator.
469
347
  `);
470
348
  const shouldConvert = await (0, internal_1.confirmationPrompt)({
471
- message: `Should Nx convert your project to use the @nx/rspack executors?`,
349
+ message: `Should Nx convert your project to use Rspack?`,
472
350
  });
473
351
  if (!shouldConvert) {
474
352
  throw new Error(`
475
- Nx could not verify that the executors you are using can be converted to the @nx/rspack executors.
353
+ Nx could not verify that the executors you are using can be converted to Rspack.
476
354
  Please try again with a different project.
477
355
  `);
478
356
  }
@@ -1,12 +1,8 @@
1
- import { NxAppRspackPluginOptions } from '../plugins/utils/models';
2
- import { NxComposableRspackPlugin } from './config';
1
+ import type { NxComposableRspackPlugin } from './config';
2
+ import type { NxAppRspackPluginOptions } from '../plugins/utils/models';
3
3
  export type WithNxOptions = Partial<NxAppRspackPluginOptions>;
4
4
  /**
5
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
6
- * `@nx/rspack/app-plugin` in a standard rspack config and run
7
- * `nx g @nx/rspack:convert-to-inferred`. See
8
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
9
- * @param {WithNxOptions} pluginOptions
10
- * @returns {NxComposableRspackPlugin}
5
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
6
+ * This inert stub will be removed in Nx v25.
11
7
  */
12
- export declare function withNx(pluginOptions?: WithNxOptions): NxComposableRspackPlugin;
8
+ export declare function withNx(_options?: WithNxOptions): NxComposableRspackPlugin;
@@ -1,40 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNx = withNx;
4
- const normalize_assets_1 = require("./normalize-assets");
5
- const apply_base_config_1 = require("../plugins/utils/apply-base-config");
6
4
  const deprecation_1 = require("./deprecation");
7
- const processed = new Set();
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
8
6
  /**
9
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
10
- * `@nx/rspack/app-plugin` in a standard rspack config and run
11
- * `nx g @nx/rspack:convert-to-inferred`. See
12
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
13
- * @param {WithNxOptions} pluginOptions
14
- * @returns {NxComposableRspackPlugin}
7
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
8
+ * This inert stub will be removed in Nx v25.
15
9
  */
16
- function withNx(pluginOptions = {}) {
10
+ function withNx(_options = {}) {
17
11
  (0, deprecation_1.warnRspackComposeHelpersDeprecation)();
18
- return function makeConfig(config, { options, context }) {
19
- if (processed.has(config))
20
- return config;
21
- (0, apply_base_config_1.applyBaseConfig)({
22
- ...options,
23
- ...pluginOptions,
24
- target: options.target ?? 'web',
25
- assets: options.assets
26
- ? options.assets
27
- : pluginOptions.assets
28
- ? (0, normalize_assets_1.normalizeAssets)(pluginOptions.assets, options.root, options.sourceRoot)
29
- : [],
30
- root: context.root,
31
- projectName: context.projectName,
32
- targetName: context.targetName,
33
- configurationName: context.configurationName,
34
- projectGraph: context.projectGraph,
35
- useLegacyHtmlPlugin: pluginOptions.useLegacyHtmlPlugin ?? false,
36
- }, config);
37
- processed.add(config);
38
- return config;
39
- };
12
+ return (config) => config;
40
13
  }
@@ -1,12 +1,9 @@
1
- import type { Configuration } from '@rspack/core';
2
- import { NxRspackExecutionContext } from './config';
3
- import { WithWebOptions } from './with-web';
1
+ import type { NxComposableRspackPlugin } from './config';
2
+ import type { WithWebOptions } from './with-web';
4
3
  export interface WithReactOptions extends WithWebOptions {
5
4
  }
6
5
  /**
7
- * @deprecated Will be removed in Nx v24. Use `NxReactRspackPlugin` from
8
- * `@nx/rspack/react-plugin` in a standard rspack config and run
9
- * `nx g @nx/rspack:convert-to-inferred`. See
10
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
6
+ * @deprecated Use `NxReactRspackPlugin` from `@nx/rspack/react-plugin`.
7
+ * This inert stub will be removed in Nx v25.
11
8
  */
12
- export declare function withReact(opts?: WithReactOptions): (config: Configuration, { options, context }: NxRspackExecutionContext) => Configuration;
9
+ export declare function withReact(_options?: WithReactOptions): NxComposableRspackPlugin;