@nx/rspack 19.8.0 → 20.0.0-beta.4

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 (121) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +70 -34
  3. package/executors.json +2 -2
  4. package/module-federation.js +0 -1
  5. package/package.json +14 -9
  6. package/plugin.js +0 -1
  7. package/src/executors/dev-server/dev-server.impl.js +39 -38
  8. package/src/executors/dev-server/lib/get-dev-server-config.js +1 -3
  9. package/src/executors/dev-server/lib/serve-path.js +0 -1
  10. package/src/executors/dev-server/schema.json +3 -9
  11. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +109 -98
  12. package/src/executors/module-federation-dev-server/schema.json +1 -3
  13. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +153 -148
  14. package/src/executors/module-federation-ssr-dev-server/schema.json +1 -4
  15. package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +117 -125
  16. package/src/executors/rspack/rspack.impl.js +60 -67
  17. package/src/executors/rspack/schema.json +6 -26
  18. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +0 -1
  19. package/src/executors/ssr-dev-server/schema.json +1 -4
  20. package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +26 -40
  21. package/src/generators/application/application.js +79 -76
  22. package/src/generators/application/lib/create-ts-config.js +5 -3
  23. package/src/generators/application/lib/normalize-options.js +12 -7
  24. package/src/generators/application/schema.json +1 -0
  25. package/src/generators/configuration/configuration.js +63 -65
  26. package/src/generators/configuration/schema.json +2 -1
  27. package/src/generators/init/init.js +58 -59
  28. package/src/generators/init/schema.json +2 -1
  29. package/src/generators/preset/preset.js +26 -29
  30. package/src/generators/preset/schema.json +1 -0
  31. package/src/index.js +0 -1
  32. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -7
  33. package/src/plugins/generate-package-json-plugin.js +1 -3
  34. package/src/plugins/plugin.js +81 -90
  35. package/src/utils/config.js +7 -11
  36. package/src/utils/create-compiler.js +21 -25
  37. package/src/utils/generator-utils.js +55 -66
  38. package/src/utils/get-copy-patterns.js +1 -3
  39. package/src/utils/jest-utils.js +0 -1
  40. package/src/utils/mode-utils.js +0 -1
  41. package/src/utils/model.js +0 -1
  42. package/src/utils/module-federation/build-static.remotes.js +57 -61
  43. package/src/utils/module-federation/dependencies.js +1 -3
  44. package/src/utils/module-federation/get-remotes-for-host.js +4 -8
  45. package/src/utils/module-federation/index.js +0 -1
  46. package/src/utils/module-federation/models/index.js +0 -1
  47. package/src/utils/module-federation/package-json.js +0 -1
  48. package/src/utils/module-federation/parse-static-remotes-config.js +2 -3
  49. package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +1 -2
  50. package/src/utils/module-federation/public-api.js +0 -1
  51. package/src/utils/module-federation/remotes.js +0 -1
  52. package/src/utils/module-federation/secondary-entry-points.js +4 -5
  53. package/src/utils/module-federation/share.js +22 -19
  54. package/src/utils/module-federation/start-remote-proxies.js +0 -1
  55. package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -1
  56. package/src/utils/module-federation/typescript.js +6 -6
  57. package/src/utils/module-federation/with-module-federation/package-json.js +0 -1
  58. package/src/utils/module-federation/with-module-federation/utils.js +41 -43
  59. package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +48 -35
  60. package/src/utils/module-federation/with-module-federation/with-module-federation.js +56 -38
  61. package/src/utils/normalize-assets.js +5 -3
  62. package/src/utils/read-rspack-options.js +23 -27
  63. package/src/utils/resolve-user-defined-rspack-config.js +0 -1
  64. package/src/utils/versions.js +0 -1
  65. package/src/utils/with-nx.js +30 -13
  66. package/src/utils/with-react.js +11 -5
  67. package/src/utils/with-web.js +20 -11
  68. package/module-federation.js.map +0 -1
  69. package/plugin.js.map +0 -1
  70. package/src/executors/dev-server/dev-server.impl.js.map +0 -1
  71. package/src/executors/dev-server/lib/get-dev-server-config.js.map +0 -1
  72. package/src/executors/dev-server/lib/serve-path.js.map +0 -1
  73. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +0 -1
  74. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +0 -1
  75. package/src/executors/module-federation-static-server/module-federation-static-server.impl.js.map +0 -1
  76. package/src/executors/rspack/rspack.impl.js.map +0 -1
  77. package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js.map +0 -1
  78. package/src/executors/ssr-dev-server/ssr-dev-server.impl.js.map +0 -1
  79. package/src/generators/application/application.js.map +0 -1
  80. package/src/generators/application/lib/create-ts-config.js.map +0 -1
  81. package/src/generators/application/lib/normalize-options.js.map +0 -1
  82. package/src/generators/configuration/configuration.js.map +0 -1
  83. package/src/generators/init/init.js.map +0 -1
  84. package/src/generators/preset/preset.js.map +0 -1
  85. package/src/index.js.map +0 -1
  86. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  87. package/src/plugins/generate-package-json-plugin.js.map +0 -1
  88. package/src/plugins/plugin.js.map +0 -1
  89. package/src/utils/config.js.map +0 -1
  90. package/src/utils/create-compiler.js.map +0 -1
  91. package/src/utils/generator-utils.js.map +0 -1
  92. package/src/utils/get-copy-patterns.js.map +0 -1
  93. package/src/utils/jest-utils.js.map +0 -1
  94. package/src/utils/mode-utils.js.map +0 -1
  95. package/src/utils/model.js.map +0 -1
  96. package/src/utils/module-federation/build-static.remotes.js.map +0 -1
  97. package/src/utils/module-federation/dependencies.js.map +0 -1
  98. package/src/utils/module-federation/get-remotes-for-host.js.map +0 -1
  99. package/src/utils/module-federation/index.js.map +0 -1
  100. package/src/utils/module-federation/models/index.js.map +0 -1
  101. package/src/utils/module-federation/package-json.js.map +0 -1
  102. package/src/utils/module-federation/parse-static-remotes-config.js.map +0 -1
  103. package/src/utils/module-federation/plugins/runtime-library-control.plugin.js.map +0 -1
  104. package/src/utils/module-federation/public-api.js.map +0 -1
  105. package/src/utils/module-federation/remotes.js.map +0 -1
  106. package/src/utils/module-federation/secondary-entry-points.js.map +0 -1
  107. package/src/utils/module-federation/share.js.map +0 -1
  108. package/src/utils/module-federation/start-remote-proxies.js.map +0 -1
  109. package/src/utils/module-federation/start-ssr-remote-proxies.js.map +0 -1
  110. package/src/utils/module-federation/typescript.js.map +0 -1
  111. package/src/utils/module-federation/with-module-federation/package-json.js.map +0 -1
  112. package/src/utils/module-federation/with-module-federation/utils.js.map +0 -1
  113. package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js.map +0 -1
  114. package/src/utils/module-federation/with-module-federation/with-module-federation.js.map +0 -1
  115. package/src/utils/normalize-assets.js.map +0 -1
  116. package/src/utils/read-rspack-options.js.map +0 -1
  117. package/src/utils/resolve-user-defined-rspack-config.js.map +0 -1
  118. package/src/utils/versions.js.map +0 -1
  119. package/src/utils/with-nx.js.map +0 -1
  120. package/src/utils/with-react.js.map +0 -1
  121. package/src/utils/with-web.js.map +0 -1
@@ -3,24 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nxRspackComposablePlugin = void 0;
4
4
  exports.isNxRspackComposablePlugin = isNxRspackComposablePlugin;
5
5
  exports.composePlugins = composePlugins;
6
- const tslib_1 = require("tslib");
7
6
  exports.nxRspackComposablePlugin = 'nxRspackComposablePlugin';
8
7
  function isNxRspackComposablePlugin(a) {
9
- return (a === null || a === void 0 ? void 0 : a[exports.nxRspackComposablePlugin]) === true;
8
+ return a?.[exports.nxRspackComposablePlugin] === true;
10
9
  }
11
10
  function composePlugins(...plugins) {
12
- return Object.defineProperty(function combined(config, ctx) {
13
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
- for (const plugin of plugins) {
15
- const fn = yield plugin;
16
- config = yield fn(config, ctx);
17
- }
18
- return config;
19
- });
11
+ return Object.defineProperty(async function combined(config, ctx) {
12
+ for (const plugin of plugins) {
13
+ const fn = await plugin;
14
+ config = await fn(config, ctx);
15
+ }
16
+ return config;
20
17
  }, exports.nxRspackComposablePlugin, {
21
18
  value: true,
22
19
  enumerable: false,
23
20
  writable: false,
24
21
  });
25
22
  }
26
- //# sourceMappingURL=config.js.map
@@ -6,32 +6,28 @@ const tslib_1 = require("tslib");
6
6
  const core_1 = require("@rspack/core");
7
7
  const path = tslib_1.__importStar(require("path"));
8
8
  const resolve_user_defined_rspack_config_1 = require("./resolve-user-defined-rspack-config");
9
- function createCompiler(options, context) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- var _a;
12
- const pathToConfig = path.join(context.root, options.rspackConfig);
13
- let userDefinedConfig = {};
14
- if (options.tsConfig) {
15
- userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(pathToConfig, options.tsConfig);
16
- }
17
- else {
18
- userDefinedConfig = yield Promise.resolve(`${pathToConfig}`).then(s => tslib_1.__importStar(require(s))).then((x) => x.default || x);
19
- }
20
- if (typeof userDefinedConfig.then === 'function') {
21
- userDefinedConfig = yield userDefinedConfig;
22
- }
23
- let config = {};
24
- if (typeof userDefinedConfig === 'function') {
25
- config = yield userDefinedConfig({ devServer: options.devServer }, { options, context });
26
- }
27
- else {
28
- config = userDefinedConfig;
29
- (_a = config.devServer) !== null && _a !== void 0 ? _a : (config.devServer = options.devServer);
30
- }
31
- return (0, core_1.rspack)(config);
32
- });
9
+ async function createCompiler(options, context) {
10
+ const pathToConfig = path.join(context.root, options.rspackConfig);
11
+ let userDefinedConfig = {};
12
+ if (options.tsConfig) {
13
+ userDefinedConfig = (0, resolve_user_defined_rspack_config_1.resolveUserDefinedRspackConfig)(pathToConfig, options.tsConfig);
14
+ }
15
+ else {
16
+ userDefinedConfig = await Promise.resolve(`${pathToConfig}`).then(s => tslib_1.__importStar(require(s))).then((x) => x.default || x);
17
+ }
18
+ if (typeof userDefinedConfig.then === 'function') {
19
+ userDefinedConfig = await userDefinedConfig;
20
+ }
21
+ let config = {};
22
+ if (typeof userDefinedConfig === 'function') {
23
+ config = await userDefinedConfig({ devServer: options.devServer }, { options, context });
24
+ }
25
+ else {
26
+ config = userDefinedConfig;
27
+ config.devServer ??= options.devServer;
28
+ }
29
+ return (0, core_1.rspack)(config);
33
30
  }
34
31
  function isMultiCompiler(compiler) {
35
32
  return 'compilers' in compiler;
36
33
  }
37
- //# sourceMappingURL=create-compiler.js.map
@@ -13,7 +13,6 @@ exports.handleUnknownExecutors = handleUnknownExecutors;
13
13
  exports.determineFrameworkAndTarget = determineFrameworkAndTarget;
14
14
  exports.determineMain = determineMain;
15
15
  exports.determineTsConfig = determineTsConfig;
16
- const tslib_1 = require("tslib");
17
16
  const devkit_1 = require("@nx/devkit");
18
17
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
19
18
  function findExistingTargetsInProject(targets, userProvidedTargets) {
@@ -83,9 +82,8 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
83
82
  // If they have, we check if the executor the target is using is supported
84
83
  // If it's not supported, then we set the unsupported flag to true for that target
85
84
  function checkUserProvidedTarget(target) {
86
- var _a;
87
- if (userProvidedTargets === null || userProvidedTargets === void 0 ? void 0 : userProvidedTargets[target]) {
88
- if (supportedExecutors[target].includes((_a = targets[userProvidedTargets[target]]) === null || _a === void 0 ? void 0 : _a.executor)) {
85
+ if (userProvidedTargets?.[target]) {
86
+ if (supportedExecutors[target].includes(targets[userProvidedTargets[target]]?.executor)) {
89
87
  output.validFoundTargetName[target] = userProvidedTargets[target];
90
88
  }
91
89
  else {
@@ -104,8 +102,8 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
104
102
  for (const target in targets) {
105
103
  const executorName = targets[target].executor;
106
104
  const hasRspackTargets = output.alreadyHasNxRspackTargets;
107
- hasRspackTargets.build || (hasRspackTargets.build = executorName === '@nx/rspack:rspack');
108
- hasRspackTargets.serve || (hasRspackTargets.serve = executorName === '@nx/rspack:dev-server');
105
+ hasRspackTargets.build ||= executorName === '@nx/rspack:rspack';
106
+ hasRspackTargets.serve ||= executorName === '@nx/rspack:dev-server';
109
107
  const foundTargets = output.validFoundTargetName;
110
108
  if (!foundTargets.build &&
111
109
  supportedExecutors.build.includes(executorName)) {
@@ -115,12 +113,12 @@ function findExistingTargetsInProject(targets, userProvidedTargets) {
115
113
  supportedExecutors.serve.includes(executorName)) {
116
114
  foundTargets.serve = target;
117
115
  }
118
- output.projectContainsUnsupportedExecutor || (output.projectContainsUnsupportedExecutor = unsupportedExecutors.includes(executorName));
116
+ output.projectContainsUnsupportedExecutor ||=
117
+ unsupportedExecutors.includes(executorName);
119
118
  }
120
119
  return output;
121
120
  }
122
121
  function addOrChangeBuildTarget(tree, options, target) {
123
- var _a, _b;
124
122
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
125
123
  const assets = [];
126
124
  if (options.target === 'web' &&
@@ -131,7 +129,7 @@ function addOrChangeBuildTarget(tree, options, target) {
131
129
  assets.push((0, devkit_1.joinPathFragments)(project.root, 'src/assets'));
132
130
  }
133
131
  const buildOptions = {
134
- target: (_a = options.target) !== null && _a !== void 0 ? _a : 'web',
132
+ target: options.target ?? 'web',
135
133
  outputPath: (0, devkit_1.joinPathFragments)('dist',
136
134
  // If standalone project then use the project's name in dist.
137
135
  project.root === '.' ? project.name : project.root),
@@ -140,7 +138,7 @@ function addOrChangeBuildTarget(tree, options, target) {
140
138
  rspackConfig: (0, devkit_1.joinPathFragments)(project.root, 'rspack.config.js'),
141
139
  assets,
142
140
  };
143
- (_b = project.targets) !== null && _b !== void 0 ? _b : (project.targets = {});
141
+ project.targets ??= {};
144
142
  project.targets[target] = {
145
143
  executor: '@nx/rspack:rspack',
146
144
  outputs: ['{options.outputPath}'],
@@ -160,9 +158,8 @@ function addOrChangeBuildTarget(tree, options, target) {
160
158
  (0, devkit_1.updateProjectConfiguration)(tree, options.project, project);
161
159
  }
162
160
  function addOrChangeServeTarget(tree, options, target) {
163
- var _a;
164
161
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
165
- (_a = project.targets) !== null && _a !== void 0 ? _a : (project.targets = {});
162
+ project.targets ??= {};
166
163
  project.targets[target] = {
167
164
  executor: '@nx/rspack:dev-server',
168
165
  options: {
@@ -250,10 +247,11 @@ function deleteWebpackConfig(tree, projectRoot, webpackConfigFilePath) {
250
247
  }
251
248
  // Maybe add delete vite config?
252
249
  function moveAndEditIndexHtml(tree, options, buildTarget) {
253
- var _a, _b, _c, _d, _e, _f, _g, _h;
254
250
  const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
255
- let indexHtmlPath = (_d = (_c = (_b = (_a = projectConfig.targets) === null || _a === void 0 ? void 0 : _a[buildTarget]) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.index) !== null && _d !== void 0 ? _d : `${projectConfig.root}/src/index.html`;
256
- let mainPath = (_h = (_g = (_f = (_e = projectConfig.targets) === null || _e === void 0 ? void 0 : _e[buildTarget]) === null || _f === void 0 ? void 0 : _f.options) === null || _g === void 0 ? void 0 : _g.main) !== null && _h !== void 0 ? _h : `${projectConfig.root}/src/main.ts${options.framework === 'react' ? 'x' : ''}`;
251
+ let indexHtmlPath = projectConfig.targets?.[buildTarget]?.options?.index ??
252
+ `${projectConfig.root}/src/index.html`;
253
+ let mainPath = projectConfig.targets?.[buildTarget]?.options?.main ??
254
+ `${projectConfig.root}/src/main.ts${options.framework === 'react' ? 'x' : ''}`;
257
255
  if (projectConfig.root !== '.') {
258
256
  mainPath = mainPath.replace(projectConfig.root, '');
259
257
  }
@@ -297,60 +295,54 @@ function normalizeViteConfigFilePathWithTree(tree, projectRoot, configFile) {
297
295
  : undefined;
298
296
  }
299
297
  function getViteConfigPathForProject(tree, projectName, target) {
300
- var _a, _b, _c;
301
298
  let viteConfigPath;
302
299
  const { targets, root } = (0, devkit_1.readProjectConfiguration)(tree, projectName);
303
300
  if (target) {
304
- viteConfigPath = (_b = (_a = targets === null || targets === void 0 ? void 0 : targets[target]) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.configFile;
301
+ viteConfigPath = targets?.[target]?.options?.configFile;
305
302
  }
306
303
  else {
307
304
  const config = Object.values(targets).find((config) => config.executor === '@nx/rspack:build');
308
- viteConfigPath = (_c = config === null || config === void 0 ? void 0 : config.options) === null || _c === void 0 ? void 0 : _c.configFile;
305
+ viteConfigPath = config?.options?.configFile;
309
306
  }
310
307
  return normalizeViteConfigFilePathWithTree(tree, root, viteConfigPath);
311
308
  }
312
- function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
313
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
314
- if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
315
- yield handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build', 'rspack');
316
- }
317
- if (framework !== 'nest' &&
318
- userProvidedTargetIsUnsupported.serve &&
319
- validFoundTargetName.serve) {
320
- yield handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve', 'dev-server');
321
- }
322
- });
309
+ async function handleUnsupportedUserProvidedTargets(userProvidedTargetIsUnsupported, userProvidedTargetName, validFoundTargetName, framework) {
310
+ if (userProvidedTargetIsUnsupported.build && validFoundTargetName.build) {
311
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.build, validFoundTargetName.build, 'build', 'rspack');
312
+ }
313
+ if (framework !== 'nest' &&
314
+ userProvidedTargetIsUnsupported.serve &&
315
+ validFoundTargetName.serve) {
316
+ await handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName.serve, validFoundTargetName.serve, 'serve', 'dev-server');
317
+ }
323
318
  }
324
- function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
325
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
326
- devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor.
319
+ async function handleUnsupportedUserProvidedTargetsErrors(userProvidedTargetName, validFoundTargetName, target, executor) {
320
+ devkit_1.logger.warn(`The custom ${target} target you provided (${userProvidedTargetName}) cannot be converted to use the @nx/rspack:${executor} executor.
327
321
  However, we found the following ${target} target in your project that can be converted: ${validFoundTargetName}
328
322
 
329
323
  Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
330
324
  your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
331
325
  `);
332
- // eslint-disable-next-line @typescript-eslint/no-var-requires
333
- const { Confirm } = require('enquirer');
334
- const prompt = new Confirm({
335
- name: 'question',
336
- message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`,
337
- initial: true,
338
- });
339
- const shouldConvert = yield prompt.run();
340
- if (!shouldConvert) {
341
- throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor.
326
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
327
+ const { Confirm } = require('enquirer');
328
+ const prompt = new Confirm({
329
+ name: 'question',
330
+ message: `Should we convert the ${validFoundTargetName} target to use the @nx/rspack:${executor} executor?`,
331
+ initial: true,
332
+ });
333
+ const shouldConvert = await prompt.run();
334
+ if (!shouldConvert) {
335
+ throw new Error(`The ${target} target ${userProvidedTargetName} cannot be converted to use the @nx/rspack:${executor} executor.
342
336
  Please try again, either by providing a different ${target} target or by not providing a target at all (Nx will
343
337
  convert the first one it finds, most probably this one: ${validFoundTargetName})
344
338
 
345
339
  Please note that converting a potentially non-compatible project to use Vite.js may result in unexpected behavior. Always commit
346
340
  your changes before converting a project to use Vite.js, and test the converted project thoroughly before deploying it.
347
341
  `);
348
- }
349
- });
342
+ }
350
343
  }
351
- function handleUnknownExecutors(projectName) {
352
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
353
- devkit_1.logger.warn(`
344
+ async function handleUnknownExecutors(projectName) {
345
+ devkit_1.logger.warn(`
354
346
  We could not find any targets in project ${projectName} that use executors which
355
347
  can be converted to the @nx/rspack executors.
356
348
 
@@ -361,24 +353,22 @@ function handleUnknownExecutors(projectName) {
361
353
  If you still want to convert your project to use the @nx/rspack executors,
362
354
  please make sure to commit your changes before running this generator.
363
355
  `);
364
- // eslint-disable-next-line @typescript-eslint/no-var-requires
365
- const { Confirm } = require('enquirer');
366
- const prompt = new Confirm({
367
- name: 'question',
368
- message: `Should Nx convert your project to use the @nx/rspack executors?`,
369
- initial: true,
370
- });
371
- const shouldConvert = yield prompt.run();
372
- if (!shouldConvert) {
373
- throw new Error(`
356
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
357
+ const { Confirm } = require('enquirer');
358
+ const prompt = new Confirm({
359
+ name: 'question',
360
+ message: `Should Nx convert your project to use the @nx/rspack executors?`,
361
+ initial: true,
362
+ });
363
+ const shouldConvert = await prompt.run();
364
+ if (!shouldConvert) {
365
+ throw new Error(`
374
366
  Nx could not verify that the executors you are using can be converted to the @nx/rspack executors.
375
367
  Please try again with a different project.
376
368
  `);
377
- }
378
- });
369
+ }
379
370
  }
380
371
  function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
381
- var _a, _b, _c, _d, _e, _f, _g;
382
372
  (0, ensure_typescript_1.ensureTypescript)();
383
373
  // eslint-disable-next-line @typescript-eslint/no-var-requires
384
374
  const { tsquery } = require('@phenomnomnominal/tsquery');
@@ -386,9 +376,9 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
386
376
  if (options.target !== 'node') {
387
377
  // Try to infer from jest config if the env is node
388
378
  let jestConfigPath;
389
- if (((_a = targets === null || targets === void 0 ? void 0 : targets.test) === null || _a === void 0 ? void 0 : _a.executor) !== '@nx/jest:jest' &&
390
- ((_c = (_b = targets === null || targets === void 0 ? void 0 : targets.test) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.jestConfig)) {
391
- jestConfigPath = (_e = (_d = targets === null || targets === void 0 ? void 0 : targets.test) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.jestConfig;
379
+ if (targets?.test?.executor !== '@nx/jest:jest' &&
380
+ targets?.test?.options?.jestConfig) {
381
+ jestConfigPath = targets?.test?.options?.jestConfig;
392
382
  }
393
383
  else {
394
384
  jestConfigPath = (0, devkit_1.joinPathFragments)(projectRoot, 'jest.config.ts');
@@ -407,7 +397,7 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
407
397
  const appFileContent = tree.read((0, devkit_1.joinPathFragments)(projectRoot, 'src/main.ts'), 'utf-8');
408
398
  const file = tsquery.ast(appFileContent);
409
399
  const hasNestJsDependency = tsquery(file, `ImportDeclaration:has(StringLiteral[value="@nestjs/common"])`);
410
- if ((hasNestJsDependency === null || hasNestJsDependency === void 0 ? void 0 : hasNestJsDependency.length) > 0) {
400
+ if (hasNestJsDependency?.length > 0) {
411
401
  return { target: 'node', framework: 'nest' };
412
402
  }
413
403
  }
@@ -422,7 +412,7 @@ function determineFrameworkAndTarget(tree, options, projectRoot, targets) {
422
412
  tsConfigPath = determineTsConfig(tree, options);
423
413
  }
424
414
  const tsConfig = JSON.parse(tree.read(tsConfigPath).toString());
425
- if ((_g = (_f = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _f === void 0 ? void 0 : _f.jsx) === null || _g === void 0 ? void 0 : _g.includes('react')) {
415
+ if (tsConfig?.compilerOptions?.jsx?.includes('react')) {
426
416
  return { target: 'web', framework: 'react' };
427
417
  }
428
418
  else {
@@ -452,4 +442,3 @@ function determineTsConfig(tree, options) {
452
442
  return libJson;
453
443
  return (0, devkit_1.joinPathFragments)(project.root, 'tsconfig.json');
454
444
  }
455
- //# sourceMappingURL=generator-utils.js.map
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCopyPatterns = getCopyPatterns;
4
4
  function getCopyPatterns(assets) {
5
5
  return assets.map((asset) => {
6
- var _a;
7
6
  return {
8
7
  context: asset.input,
9
8
  // Now we remove starting slash to make Webpack place it from the output root.
@@ -14,11 +13,10 @@ function getCopyPatterns(assets) {
14
13
  '.gitkeep',
15
14
  '**/.DS_Store',
16
15
  '**/Thumbs.db',
17
- ...((_a = asset.ignore) !== null && _a !== void 0 ? _a : []),
16
+ ...(asset.ignore ?? []),
18
17
  ],
19
18
  dot: true,
20
19
  },
21
20
  };
22
21
  });
23
22
  }
24
- //# sourceMappingURL=get-copy-patterns.js.map
@@ -6,4 +6,3 @@ function updateJestConfigContent(content) {
6
6
  .replace('transform: {', "transform: {\n '^(?!.*\\\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',")
7
7
  .replace(`'babel-jest'`, `['babel-jest', { presets: ['@nx/react/babel'] }]`);
8
8
  }
9
- //# sourceMappingURL=jest-utils.js.map
@@ -4,4 +4,3 @@ exports.isMode = isMode;
4
4
  function isMode(mode) {
5
5
  return mode === 'development' || mode === 'production' || mode === 'none';
6
6
  }
7
- //# sourceMappingURL=mode-utils.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=model.js.map
@@ -1,73 +1,69 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildStaticRemotes = buildStaticRemotes;
4
- const tslib_1 = require("tslib");
5
4
  const fs_1 = require("fs");
6
5
  const node_child_process_1 = require("node:child_process");
7
6
  const cache_directory_1 = require("nx/src/utils/cache-directory");
8
7
  const logger_1 = require("nx/src/utils/logger");
9
8
  const path_1 = require("path");
10
- function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- if (!staticRemotesConfig.remotes.length) {
13
- return;
14
- }
15
- logger_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
16
- const mappedLocationOfRemotes = {};
17
- for (const app of staticRemotesConfig.remotes) {
18
- mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
19
- }
20
- yield new Promise((res, rej) => {
21
- const staticProcess = (0, node_child_process_1.fork)(nxBin, [
22
- 'run-many',
23
- `--target=build`,
24
- `--projects=${staticRemotesConfig.remotes.join(',')}`,
25
- ...(context.configurationName
26
- ? [`--configuration=${context.configurationName}`]
27
- : []),
28
- ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
29
- ], {
30
- cwd: context.root,
31
- stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
32
- });
33
- // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
34
- const remoteBuildLogFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory,
35
- // eslint-disable-next-line
36
- `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
37
- const stdoutStream = (0, fs_1.createWriteStream)(remoteBuildLogFile);
38
- staticProcess.stdout.on('data', (data) => {
39
- const ANSII_CODE_REGEX =
40
- // eslint-disable-next-line no-control-regex
41
- /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
42
- const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
43
- stdoutStream.write(stdoutString);
44
- // in addition to writing into the stdout stream, also show error directly in console
45
- // so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
46
- if (stdoutString.includes('ERROR in')) {
47
- logger_1.logger.log(stdoutString);
48
- }
49
- if (stdoutString.includes('Successfully ran target build')) {
50
- staticProcess.stdout.removeAllListeners('data');
51
- logger_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
52
- res();
53
- }
54
- });
55
- staticProcess.stderr.on('data', (data) => logger_1.logger.info(data.toString()));
56
- staticProcess.once('exit', (code) => {
57
- stdoutStream.end();
9
+ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options) {
10
+ if (!staticRemotesConfig.remotes.length) {
11
+ return;
12
+ }
13
+ logger_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
14
+ const mappedLocationOfRemotes = {};
15
+ for (const app of staticRemotesConfig.remotes) {
16
+ mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
17
+ }
18
+ await new Promise((res, rej) => {
19
+ const staticProcess = (0, node_child_process_1.fork)(nxBin, [
20
+ 'run-many',
21
+ `--target=build`,
22
+ `--projects=${staticRemotesConfig.remotes.join(',')}`,
23
+ ...(context.configurationName
24
+ ? [`--configuration=${context.configurationName}`]
25
+ : []),
26
+ ...(options.parallel ? [`--parallel=${options.parallel}`] : []),
27
+ ], {
28
+ cwd: context.root,
29
+ stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
30
+ });
31
+ // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
32
+ const remoteBuildLogFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory,
33
+ // eslint-disable-next-line
34
+ `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
35
+ const stdoutStream = (0, fs_1.createWriteStream)(remoteBuildLogFile);
36
+ staticProcess.stdout.on('data', (data) => {
37
+ const ANSII_CODE_REGEX =
38
+ // eslint-disable-next-line no-control-regex
39
+ /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
40
+ const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
41
+ stdoutStream.write(stdoutString);
42
+ // in addition to writing into the stdout stream, also show error directly in console
43
+ // so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
44
+ if (stdoutString.includes('ERROR in')) {
45
+ logger_1.logger.log(stdoutString);
46
+ }
47
+ if (stdoutString.includes('Successfully ran target build')) {
58
48
  staticProcess.stdout.removeAllListeners('data');
59
- staticProcess.stderr.removeAllListeners('data');
60
- if (code !== 0) {
61
- rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
62
- }
63
- else {
64
- res();
65
- }
66
- });
67
- process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
68
- process.on('exit', () => staticProcess.kill('SIGTERM'));
49
+ logger_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
50
+ res();
51
+ }
52
+ });
53
+ staticProcess.stderr.on('data', (data) => logger_1.logger.info(data.toString()));
54
+ staticProcess.once('exit', (code) => {
55
+ stdoutStream.end();
56
+ staticProcess.stdout.removeAllListeners('data');
57
+ staticProcess.stderr.removeAllListeners('data');
58
+ if (code !== 0) {
59
+ rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
60
+ }
61
+ else {
62
+ res();
63
+ }
69
64
  });
70
- return mappedLocationOfRemotes;
65
+ process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
66
+ process.on('exit', () => staticProcess.kill('SIGTERM'));
71
67
  });
68
+ return mappedLocationOfRemotes;
72
69
  }
73
- //# sourceMappingURL=build-static.remotes.js.map
@@ -14,12 +14,11 @@ function collectDependencies(projectGraph, name, dependencies = {
14
14
  workspaceLibraries: new Map(),
15
15
  npmPackages: new Set(),
16
16
  }, seen = new Set()) {
17
- var _a;
18
17
  if (seen.has(name)) {
19
18
  return dependencies;
20
19
  }
21
20
  seen.add(name);
22
- ((_a = projectGraph.dependencies[name]) !== null && _a !== void 0 ? _a : []).forEach((dependency) => {
21
+ (projectGraph.dependencies[name] ?? []).forEach((dependency) => {
23
22
  if (dependency.target.startsWith('npm:')) {
24
23
  dependencies.npmPackages.add(dependency.target.replace('npm:', ''));
25
24
  }
@@ -55,4 +54,3 @@ function getLibraryImportPath(library, projectGraph) {
55
54
  }
56
55
  return undefined;
57
56
  }
58
- //# sourceMappingURL=dependencies.js.map
@@ -10,7 +10,6 @@ const fs_1 = require("fs");
10
10
  const find_matching_projects_1 = require("nx/src/utils/find-matching-projects");
11
11
  const path_1 = require("path");
12
12
  function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
13
- var _a, _b;
14
13
  const remotes = [];
15
14
  const dynamicRemotes = [];
16
15
  if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
@@ -26,13 +25,12 @@ function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
26
25
  }
27
26
  }
28
27
  }
29
- const staticRemotes = (_b = (_a = config.remotes) === null || _a === void 0 ? void 0 : _a.map((r) => (Array.isArray(r) ? r[0] : r))) !== null && _b !== void 0 ? _b : [];
28
+ const staticRemotes = config.remotes?.map((r) => (Array.isArray(r) ? r[0] : r)) ?? [];
30
29
  remotes.push(...staticRemotes);
31
30
  return { remotes, dynamicRemotes };
32
31
  }
33
32
  function collectRemoteProjects(remote, collected, context) {
34
- var _a;
35
- const remoteProject = (_a = context.projectGraph.nodes[remote]) === null || _a === void 0 ? void 0 : _a.data;
33
+ const remoteProject = context.projectGraph.nodes[remote]?.data;
36
34
  if (!context.projectGraph.nodes[remote] || collected.has(remote)) {
37
35
  return;
38
36
  }
@@ -44,11 +42,10 @@ function collectRemoteProjects(remote, collected, context) {
44
42
  remoteProjectRemotes.forEach((r) => collectRemoteProjects(r, collected, context));
45
43
  }
46
44
  function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile) {
47
- var _a;
48
45
  const collectedRemotes = new Set();
49
46
  const { remotes, dynamicRemotes } = extractRemoteProjectsFromConfig(config, pathToManifestFile);
50
47
  remotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, context));
51
- const remotesToSkip = new Set((_a = (0, find_matching_projects_1.findMatchingProjects)(skipRemotes, context.projectGraph.nodes)) !== null && _a !== void 0 ? _a : []);
48
+ const remotesToSkip = new Set((0, find_matching_projects_1.findMatchingProjects)(skipRemotes, context.projectGraph.nodes) ?? []);
52
49
  if (remotesToSkip.size > 0) {
53
50
  devkit_1.logger.info(`Remotes not served automatically: ${[...remotesToSkip.values()].join(', ')}`);
54
51
  }
@@ -96,8 +93,7 @@ function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot, plu
96
93
  cleanupTranspiler();
97
94
  return config.default || config;
98
95
  }
99
- catch (_a) {
96
+ catch {
100
97
  throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/${pluginName}:host"?\nSee: https://nx.dev/concepts/more-concepts/faster-builds-with-module-federation`);
101
98
  }
102
99
  }
103
- //# sourceMappingURL=get-remotes-for-host.js.map
@@ -7,4 +7,3 @@ tslib_1.__exportStar(require("./package-json"), exports);
7
7
  tslib_1.__exportStar(require("./remotes"), exports);
8
8
  tslib_1.__exportStar(require("./models"), exports);
9
9
  tslib_1.__exportStar(require("./get-remotes-for-host"), exports);
10
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=index.js.map
@@ -10,4 +10,3 @@ function readRootPackageJson() {
10
10
  }
11
11
  return (0, devkit_1.readJsonFile)(pkgJsonPath);
12
12
  }
13
- //# sourceMappingURL=package-json.js.map
@@ -4,7 +4,7 @@ exports.parseStaticRemotesConfig = parseStaticRemotesConfig;
4
4
  exports.parseStaticSsrRemotesConfig = parseStaticSsrRemotesConfig;
5
5
  const path_1 = require("path");
6
6
  function parseStaticRemotesConfig(staticRemotes, context) {
7
- if (!(staticRemotes === null || staticRemotes === void 0 ? void 0 : staticRemotes.length)) {
7
+ if (!staticRemotes?.length) {
8
8
  return { remotes: [], config: undefined };
9
9
  }
10
10
  const config = {};
@@ -18,7 +18,7 @@ function parseStaticRemotesConfig(staticRemotes, context) {
18
18
  return { remotes: staticRemotes, config };
19
19
  }
20
20
  function parseStaticSsrRemotesConfig(staticRemotes, context) {
21
- if (!(staticRemotes === null || staticRemotes === void 0 ? void 0 : staticRemotes.length)) {
21
+ if (!staticRemotes?.length) {
22
22
  return { remotes: [], config: undefined };
23
23
  }
24
24
  const config = {};
@@ -32,4 +32,3 @@ function parseStaticSsrRemotesConfig(staticRemotes, context) {
32
32
  }
33
33
  return { remotes: staticRemotes, config };
34
34
  }
35
- //# sourceMappingURL=parse-static-remotes-config.js.map
@@ -43,7 +43,7 @@ const nxRuntimeLibraryControlPlugin = function () {
43
43
  shareScopeMap[scope][pkgName][version] = remotePkgInfo;
44
44
  return remotePkgInfo;
45
45
  }
46
- catch (_a) {
46
+ catch {
47
47
  return originalResolver();
48
48
  }
49
49
  };
@@ -52,4 +52,3 @@ const nxRuntimeLibraryControlPlugin = function () {
52
52
  };
53
53
  };
54
54
  exports.default = nxRuntimeLibraryControlPlugin;
55
- //# sourceMappingURL=runtime-library-control.plugin.js.map