@nx/rspack 23.0.0-beta.2 → 23.0.0-beta.21

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 (87) hide show
  1. package/migrations.json +52 -8
  2. package/package.json +27 -13
  3. package/src/executors/dev-server/dev-server.impl.d.ts.map +1 -1
  4. package/src/executors/dev-server/dev-server.impl.js +6 -4
  5. package/src/executors/dev-server/schema.json +1 -0
  6. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts.map +1 -1
  7. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +6 -4
  8. package/src/executors/module-federation-dev-server/schema.json +1 -0
  9. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts.map +1 -1
  10. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +6 -4
  11. package/src/executors/module-federation-ssr-dev-server/schema.json +1 -0
  12. package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts.map +1 -1
  13. package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +6 -4
  14. package/src/executors/module-federation-static-server/schema.json +1 -0
  15. package/src/executors/rspack/lib/normalize-options.js +2 -2
  16. package/src/executors/rspack/rspack.impl.d.ts.map +1 -1
  17. package/src/executors/rspack/rspack.impl.js +6 -4
  18. package/src/executors/rspack/schema.json +1 -0
  19. package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts.map +1 -1
  20. package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +2 -2
  21. package/src/generators/configuration/configuration.d.ts.map +1 -1
  22. package/src/generators/configuration/configuration.js +13 -10
  23. package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.d.ts.map +1 -1
  24. package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.js +5 -7
  25. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +1 -1
  26. package/src/generators/convert-to-inferred/convert-to-inferred.js +13 -6
  27. package/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +8 -8
  28. package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts.map +1 -1
  29. package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +4 -4
  30. package/src/generators/convert-to-inferred/utils/types.d.ts +1 -1
  31. package/src/generators/convert-to-inferred/utils/types.d.ts.map +1 -1
  32. package/src/generators/convert-webpack/convert-webpack.d.ts.map +1 -1
  33. package/src/generators/convert-webpack/convert-webpack.js +8 -1
  34. package/src/generators/init/init.d.ts.map +1 -1
  35. package/src/generators/init/init.js +14 -7
  36. package/src/generators/init/schema.json +1 -1
  37. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts.map +1 -1
  38. package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +2 -2
  39. package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts.map +1 -1
  40. package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +2 -2
  41. package/src/migrations/update-22-0-0/remove-deprecated-options.d.ts.map +1 -1
  42. package/src/migrations/update-22-0-0/remove-deprecated-options.js +3 -3
  43. package/src/migrations/update-23-0-0/add-svgr-to-rspack-config.d.ts +3 -0
  44. package/src/migrations/update-23-0-0/add-svgr-to-rspack-config.d.ts.map +1 -0
  45. package/src/migrations/update-23-0-0/add-svgr-to-rspack-config.js +413 -0
  46. package/src/migrations/update-23-0-0/add-svgr-to-rspack-config.md +84 -0
  47. package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.d.ts +1 -7
  48. package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.d.ts.map +1 -1
  49. package/src/plugins/plugin.d.ts.map +1 -1
  50. package/src/plugins/plugin.js +17 -27
  51. package/src/plugins/utils/apply-base-config.js +2 -2
  52. package/src/plugins/utils/apply-react-config.d.ts +1 -4
  53. package/src/plugins/utils/apply-react-config.d.ts.map +1 -1
  54. package/src/plugins/utils/apply-react-config.js +1 -32
  55. package/src/plugins/utils/apply-web-config.d.ts.map +1 -1
  56. package/src/plugins/utils/apply-web-config.js +4 -14
  57. package/src/plugins/utils/models.d.ts +1 -10
  58. package/src/plugins/utils/models.d.ts.map +1 -1
  59. package/src/plugins/utils/plugins/normalize-options.js +2 -2
  60. package/src/plugins/utils/plugins/nx-tsconfig-paths-rspack-plugin.js +3 -3
  61. package/src/utils/assert-supported-rspack-version.d.ts +3 -0
  62. package/src/utils/assert-supported-rspack-version.d.ts.map +1 -0
  63. package/src/utils/assert-supported-rspack-version.js +8 -0
  64. package/src/utils/config.js +2 -2
  65. package/src/utils/deprecation.d.ts +6 -0
  66. package/src/utils/deprecation.d.ts.map +1 -0
  67. package/src/utils/deprecation.js +21 -0
  68. package/src/utils/e2e-web-server-info-utils.d.ts +1 -1
  69. package/src/utils/e2e-web-server-info-utils.d.ts.map +1 -1
  70. package/src/utils/e2e-web-server-info-utils.js +6 -5
  71. package/src/utils/generator-utils.d.ts.map +1 -1
  72. package/src/utils/generator-utils.js +3 -4
  73. package/src/utils/module-federation-deprecation.d.ts +7 -0
  74. package/src/utils/module-federation-deprecation.d.ts.map +1 -0
  75. package/src/utils/module-federation-deprecation.js +30 -0
  76. package/src/utils/resolve-user-defined-rspack-config.js +2 -2
  77. package/src/utils/version-utils.d.ts +27 -0
  78. package/src/utils/version-utils.d.ts.map +1 -0
  79. package/src/utils/version-utils.js +53 -0
  80. package/src/utils/versions.d.ts +18 -3
  81. package/src/utils/versions.d.ts.map +1 -1
  82. package/src/utils/versions.js +21 -4
  83. package/src/utils/with-react.d.ts +1 -7
  84. package/src/utils/with-react.d.ts.map +1 -1
  85. package/src/utils/with-react.js +1 -1
  86. package/src/utils/with-web.d.ts +1 -1
  87. package/src/utils/with-web.d.ts.map +1 -1
@@ -2,23 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToInferred = convertToInferred;
4
4
  exports.createCollectingLogger = createCollectingLogger;
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const devkit_1 = require("@nx/devkit");
6
- const aggregate_log_util_1 = require("@nx/devkit/src/generators/plugin-migrations/aggregate-log-util");
7
- const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
8
7
  const tsquery_1 = require("@phenomnomnominal/tsquery");
9
8
  const plugin_1 = require("../../plugins/plugin");
10
9
  const versions_1 = require("../../utils/versions");
11
10
  const utils_1 = require("./utils");
12
11
  const devkit_exports_1 = require("nx/src/devkit-exports");
12
+ const assert_supported_rspack_version_1 = require("../../utils/assert-supported-rspack-version");
13
13
  async function convertToInferred(tree, options) {
14
+ (0, assert_supported_rspack_version_1.assertSupportedRspackVersion)(tree);
14
15
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
15
16
  const migrationContext = {
16
- logger: new aggregate_log_util_1.AggregatedLog(),
17
+ logger: new internal_1.AggregatedLog(),
17
18
  projectGraph,
18
19
  workspaceRoot: tree.root,
19
20
  };
20
21
  const logger = createCollectingLogger();
21
- const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/rspack/plugin', plugin_1.createNodesV2, {
22
+ const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/rspack/plugin', plugin_1.createNodesV2, {
22
23
  buildTargetName: 'build',
23
24
  previewTargetName: 'preview',
24
25
  serveStaticTargetName: 'serve-static',
@@ -47,13 +48,19 @@ async function convertToInferred(tree, options) {
47
48
  }
48
49
  else {
49
50
  logger.flushLogs();
50
- throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError();
51
+ throw new internal_1.NoTargetsToMigrateError();
51
52
  }
52
53
  }
53
54
  else {
54
55
  logger.flushLogs();
55
56
  }
56
- const installCallback = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@rspack/core': versions_1.rspackCoreVersion }, undefined, true);
57
+ const installCallback = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
58
+ '@rspack/core': versions_1.rspackCoreVersion,
59
+ // The inferred plugin's targets run the `rspack` CLI. Since
60
+ // @rspack/cli is an optional peer dependency of @nx/rspack, install
61
+ // it explicitly so the converted targets can execute.
62
+ '@rspack/cli': versions_1.rspackCoreVersion,
63
+ }, undefined, true);
57
64
  if (!options.skipFormat) {
58
65
  await (0, devkit_1.formatFiles)(tree);
59
66
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildPostTargetTransformerFactory = buildPostTargetTransformerFactory;
4
4
  const tslib_1 = require("tslib");
5
- const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
5
+ const internal_1 = require("@nx/devkit/internal");
6
6
  const tsquery_1 = require("@phenomnomnominal/tsquery");
7
7
  const ts = tslib_1.__importStar(require("typescript"));
8
8
  const ast_1 = require("./ast");
@@ -16,7 +16,7 @@ function buildPostTargetTransformerFactory(migrationContext) {
16
16
  const { pluginOptions, rspackConfigPath } = processOptions(target, context);
17
17
  updateRspackConfig(tree, rspackConfigPath, pluginOptions);
18
18
  if (target.outputs) {
19
- (0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTarget, {
19
+ (0, internal_1.processTargetOutputs)(target, [], inferredTarget, {
20
20
  projectName: projectDetails.projectName,
21
21
  projectRoot: projectDetails.root,
22
22
  });
@@ -50,29 +50,29 @@ function extractPluginOptions(options, context, configName) {
50
50
  const pluginOptions = {};
51
51
  for (const [key, value] of Object.entries(options)) {
52
52
  if (pathOptions.has(key)) {
53
- pluginOptions[key] = (0, plugin_migration_utils_1.toProjectRelativePath)(value, context.projectRoot);
53
+ pluginOptions[key] = (0, internal_1.toProjectRelativePath)(value, context.projectRoot);
54
54
  delete options[key];
55
55
  }
56
56
  else if (assetsOptions.has(key)) {
57
57
  pluginOptions[key] = value.map((asset) => {
58
58
  if (typeof asset === 'string') {
59
- return (0, plugin_migration_utils_1.toProjectRelativePath)(asset, context.projectRoot);
59
+ return (0, internal_1.toProjectRelativePath)(asset, context.projectRoot);
60
60
  }
61
- asset.input = (0, plugin_migration_utils_1.toProjectRelativePath)(asset.input, context.projectRoot);
61
+ asset.input = (0, internal_1.toProjectRelativePath)(asset.input, context.projectRoot);
62
62
  return asset;
63
63
  });
64
64
  delete options[key];
65
65
  }
66
66
  else if (key === 'fileReplacements') {
67
67
  pluginOptions.fileReplacements = value.map((replacement) => ({
68
- replace: (0, plugin_migration_utils_1.toProjectRelativePath)(replacement.replace, context.projectRoot),
69
- with: (0, plugin_migration_utils_1.toProjectRelativePath)(replacement.with, context.projectRoot),
68
+ replace: (0, internal_1.toProjectRelativePath)(replacement.replace, context.projectRoot),
69
+ with: (0, internal_1.toProjectRelativePath)(replacement.with, context.projectRoot),
70
70
  }));
71
71
  delete options.fileReplacements;
72
72
  }
73
73
  else if (key === 'additionalEntryPoints') {
74
74
  pluginOptions.additionalEntryPoints = value.map((entryPoint) => {
75
- entryPoint.entryPath = (0, plugin_migration_utils_1.toProjectRelativePath)(entryPoint.entryPath, context.projectRoot);
75
+ entryPoint.entryPath = (0, internal_1.toProjectRelativePath)(entryPoint.entryPath, context.projectRoot);
76
76
  return entryPoint;
77
77
  });
78
78
  delete options.additionalEntryPoints;
@@ -1 +1 @@
1
- {"version":3,"file":"serve-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/generators/convert-to-inferred/utils/serve-post-target-transformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC;AAEpE,wBAAgB,iCAAiC,CAC/C,gBAAgB,EAAE,gBAAgB,IAGhC,QAAQ,mBAAmB,EAC3B,MAAM,IAAI,EACV,gBAAgB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrD,gBAAgB,mBAAmB,KAClC,OAAO,CAAC,mBAAmB,CAAC,CAwBhC"}
1
+ {"version":3,"file":"serve-post-target-transformer.d.ts","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/generators/convert-to-inferred/utils/serve-post-target-transformer.ts"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAQpB,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,SAAS,CAAC;AAEpE,wBAAgB,iCAAiC,CAC/C,gBAAgB,EAAE,gBAAgB,IAGhC,QAAQ,mBAAmB,EAC3B,MAAM,IAAI,EACV,gBAAgB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACrD,gBAAgB,mBAAmB,KAClC,OAAO,CAAC,mBAAmB,CAAC,CAwBhC"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.servePostTargetTransformerFactory = servePostTargetTransformerFactory;
4
4
  const tslib_1 = require("tslib");
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const devkit_1 = require("@nx/devkit");
6
- const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
7
7
  const tsquery_1 = require("@phenomnomnominal/tsquery");
8
8
  const path_1 = require("path");
9
9
  const ts = tslib_1.__importStar(require("typescript"));
@@ -19,7 +19,7 @@ function servePostTargetTransformerFactory(migrationContext) {
19
19
  const { devServerOptions, rspackConfigPath } = await processOptions(tree, target, context);
20
20
  updateRspackConfig(tree, rspackConfigPath, devServerOptions, context);
21
21
  if (target.outputs) {
22
- (0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTarget, {
22
+ (0, internal_1.processTargetOutputs)(target, [], inferredTarget, {
23
23
  projectName: projectDetails.projectName,
24
24
  projectRoot: projectDetails.root,
25
25
  });
@@ -64,8 +64,8 @@ function extractDevServerOptions(options, context) {
64
64
  devServerOptions.server = { type: 'https' };
65
65
  if (options.sslCert && options.sslKey) {
66
66
  devServerOptions.server.options = {};
67
- devServerOptions.server.options.cert = (0, plugin_migration_utils_1.toProjectRelativePath)(options.sslCert, context.projectRoot);
68
- devServerOptions.server.options.key = (0, plugin_migration_utils_1.toProjectRelativePath)(options.sslKey, context.projectRoot);
67
+ devServerOptions.server.options.cert = (0, internal_1.toProjectRelativePath)(options.sslCert, context.projectRoot);
68
+ devServerOptions.server.options.key = (0, internal_1.toProjectRelativePath)(options.sslKey, context.projectRoot);
69
69
  }
70
70
  else if (options.sslCert) {
71
71
  context.logger.addLog({
@@ -1,5 +1,5 @@
1
1
  import type { ProjectGraph } from '@nx/devkit';
2
- import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
2
+ import type { AggregatedLog } from '@nx/devkit/internal';
3
3
  export type MigrationContext = {
4
4
  logger: AggregatedLog;
5
5
  projectGraph: ProjectGraph;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/generators/convert-to-inferred/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gEAAgE,CAAC;AAEpG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/generators/convert-to-inferred/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,aAAa,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"convert-webpack.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/generators/convert-webpack/convert-webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC,yBAA+B,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mDAwJzD"}
1
+ {"version":3,"file":"convert-webpack.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/generators/convert-webpack/convert-webpack.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAWlC,yBAA+B,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,mDAiKzD"}
@@ -6,7 +6,9 @@ const versions_1 = require("../../utils/versions");
6
6
  const transform_esm_1 = require("./lib/transform-esm");
7
7
  const transform_cjs_1 = require("./lib/transform-cjs");
8
8
  const transform_plugin_config_1 = require("./lib/transform-plugin-config");
9
+ const assert_supported_rspack_version_1 = require("../../utils/assert-supported-rspack-version");
9
10
  async function default_1(tree, options) {
11
+ (0, assert_supported_rspack_version_1.assertSupportedRspackVersion)(tree);
10
12
  const projects = (0, devkit_1.getProjects)(tree);
11
13
  if (!projects.has(options.project)) {
12
14
  throw new Error(`Could not find project '${options.project}'. Ensure you have specified the project you'd like to convert correctly.`);
@@ -113,7 +115,12 @@ async function default_1(tree, options) {
113
115
  const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
114
116
  '@rspack/core': versions_1.rspackCoreVersion,
115
117
  '@rspack/dev-server': versions_1.rspackDevServerVersion,
116
- });
118
+ // @rspack/plugin-react-refresh is required at runtime by
119
+ // apply-react-config when building a React project. Since it is an
120
+ // optional peer dependency of @nx/rspack, the convert generator must
121
+ // install it explicitly.
122
+ '@rspack/plugin-react-refresh': versions_1.rspackPluginReactRefreshVersion,
123
+ }, undefined, true);
117
124
  if (!options.skipFormat) {
118
125
  await (0, devkit_1.formatFiles)(tree);
119
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,IAAI,EACL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,mBAAmB,8BAyG5B;AAED,eAAe,mBAAmB,CAAC;AAEnC,eAAO,MAAM,mBAAmB,sFAA0C,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,iBAAiB,EAGjB,IAAI,EACL,MAAM,YAAY,CAAC;AAWpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,mBAAmB,8BAiH5B;AAED,eAAe,mBAAmB,CAAC;AAEnC,eAAO,MAAM,mBAAmB,sFAA0C,CAAC"}
@@ -2,19 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.rspackInitSchematic = void 0;
4
4
  exports.rspackInitGenerator = rspackInitGenerator;
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const devkit_1 = require("@nx/devkit");
6
- const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
7
  const js_1 = require("@nx/js");
8
8
  const plugin_1 = require("../../../plugin");
9
9
  const versions_1 = require("../../utils/versions");
10
+ const version_utils_1 = require("../../utils/version-utils");
11
+ const assert_supported_rspack_version_1 = require("../../utils/assert-supported-rspack-version");
10
12
  async function rspackInitGenerator(tree, schema) {
13
+ (0, assert_supported_rspack_version_1.assertSupportedRspackVersion)(tree);
11
14
  const tasks = [];
12
15
  const nxJson = (0, devkit_1.readNxJson)(tree);
13
16
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
14
17
  nxJson.useInferencePlugins !== false;
15
18
  schema.addPlugin ??= addPluginDefault;
16
19
  if (schema.addPlugin) {
17
- await (0, add_plugin_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rspack/plugin', plugin_1.createNodesV2, {
20
+ await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/rspack/plugin', plugin_1.createNodesV2, {
18
21
  buildTargetName: [
19
22
  'build',
20
23
  'rspack:build',
@@ -59,12 +62,15 @@ async function rspackInitGenerator(tree, schema) {
59
62
  skipFormat: true,
60
63
  });
61
64
  tasks.push(jsInitTask);
65
+ const rspackVersions = (0, version_utils_1.getRspackVersionsForInstalledMajor)(tree);
66
+ const keepExistingVersions = schema.keepExistingVersions ?? true;
62
67
  const devDependencies = {
63
- '@rspack/core': versions_1.rspackCoreVersion,
64
- '@rspack/cli': versions_1.rspackCoreVersion,
68
+ '@rspack/core': rspackVersions.rspackCoreVersion,
69
+ '@rspack/cli': rspackVersions.rspackCoreVersion,
70
+ '@rspack/dev-server': rspackVersions.rspackDevServerVersion,
65
71
  ...(!schema.framework || schema.framework === 'react'
66
72
  ? {
67
- '@rspack/plugin-react-refresh': versions_1.rspackPluginReactRefreshVersion,
73
+ '@rspack/plugin-react-refresh': rspackVersions.rspackPluginReactRefreshVersion,
68
74
  'react-refresh': versions_1.reactRefreshVersion,
69
75
  }
70
76
  : {}),
@@ -82,9 +88,10 @@ async function rspackInitGenerator(tree, schema) {
82
88
  devDependencies['sass-embedded'] = versions_1.sassEmbeddedVersion;
83
89
  }
84
90
  if (schema.framework !== 'none' || schema.devServer) {
85
- devDependencies['@rspack/dev-server'] = versions_1.rspackDevServerVersion;
91
+ devDependencies['@rspack/dev-server'] =
92
+ rspackVersions.rspackDevServerVersion;
86
93
  }
87
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, schema.keepExistingVersions);
94
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, keepExistingVersions);
88
95
  tasks.push(installTask);
89
96
  return (0, devkit_1.runTasksInSerial)(...tasks);
90
97
  }
@@ -24,7 +24,7 @@
24
24
  "type": "boolean",
25
25
  "x-priority": "internal",
26
26
  "description": "Keep existing dependencies versions",
27
- "default": false
27
+ "default": true
28
28
  }
29
29
  },
30
30
  "required": []
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-with-mf-import-to-new-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AASpB,wBAA8B,mBAAmB,CAAC,IAAI,EAAE,IAAI,iBAqD3D"}
1
+ {"version":3,"file":"migrate-with-mf-import-to-new-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAQpB,wBAA8B,mBAAmB,CAAC,IAAI,EAAE,IAAI,iBAqD3D"}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = migrateWithMfImport;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
6
  const tsquery_1 = require("@phenomnomnominal/tsquery");
7
7
  const versions_1 = require("../../utils/versions");
8
8
  const NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/rspack/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/rspack/module-federation]';
9
9
  const NEW_IMPORT_PATH = `'@nx/module-federation/rspack'`;
10
10
  async function migrateWithMfImport(tree) {
11
11
  const projects = new Set();
12
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rspack:module-federation-dev-server', (options, project, target) => {
12
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/rspack:module-federation-dev-server', (options, project, target) => {
13
13
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
14
14
  projects.add(projectConfig.root);
15
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ensure-nx-module-federation-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-20-3-0/ensure-nx-module-federation-package.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAIpB,wBAA8B,eAAe,CAAC,IAAI,EAAE,IAAI,iBAqBvD"}
1
+ {"version":3,"file":"ensure-nx-module-federation-package.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-20-3-0/ensure-nx-module-federation-package.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAGpB,wBAA8B,eAAe,CAAC,IAAI,EAAE,IAAI,iBAqBvD"}
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = ensureMfPackage;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
6
  const versions_1 = require("../../utils/versions");
7
7
  async function ensureMfPackage(tree) {
8
8
  const projects = new Set();
9
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rspack:module-federation-dev-server', (options, project, target) => {
9
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/rspack:module-federation-dev-server', (options, project, target) => {
10
10
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
11
11
  projects.add(projectConfig.root);
12
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"remove-deprecated-options.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-22-0-0/remove-deprecated-options.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAGpB,wBAA8B,uBAAuB,CAAC,IAAI,EAAE,IAAI,iBAwH/D"}
1
+ {"version":3,"file":"remove-deprecated-options.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-22-0-0/remove-deprecated-options.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAEpB,wBAA8B,uBAAuB,CAAC,IAAI,EAAE,IAAI,iBAwH/D"}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = removeDeprecatedOptions;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
6
  async function removeDeprecatedOptions(tree) {
7
7
  const projects = new Set();
8
8
  // Find all projects using @nx/rspack:rspack or @nx/rspack:dev-server executors
9
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rspack:rspack', (options, project) => {
9
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/rspack:rspack', (options, project) => {
10
10
  projects.add(project);
11
11
  });
12
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/rspack:dev-server', (options, project) => {
12
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/rspack:dev-server', (options, project) => {
13
13
  projects.add(project);
14
14
  });
15
15
  // Update project configurations to remove deprecated options
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function addSvgrToRspackConfig(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=add-svgr-to-rspack-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-svgr-to-rspack-config.d.ts","sourceRoot":"","sources":["../../../../../../packages/rspack/src/migrations/update-23-0-0/add-svgr-to-rspack-config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AA8FpB,wBAA8B,qBAAqB,CAAC,IAAI,EAAE,IAAI,iBA+Y7D"}