@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,23 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withReact = withReact;
4
- const with_web_1 = require("./with-web");
5
- const apply_react_config_1 = require("../plugins/utils/apply-react-config");
6
4
  const deprecation_1 = require("./deprecation");
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
7
6
  /**
8
- * @deprecated Will be removed in Nx v24. Use `NxReactRspackPlugin` from
9
- * `@nx/rspack/react-plugin` in a standard rspack config and run
10
- * `nx g @nx/rspack:convert-to-inferred`. See
11
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
7
+ * @deprecated Use `NxReactRspackPlugin` from `@nx/rspack/react-plugin`.
8
+ * This inert stub will be removed in Nx v25.
12
9
  */
13
- function withReact(opts = {}) {
10
+ function withReact(_options = {}) {
14
11
  (0, deprecation_1.warnRspackComposeHelpersDeprecation)();
15
- return function makeConfig(config, { options, context }) {
16
- config = (0, with_web_1.withWeb)({ ...opts, cssModules: true })(config, {
17
- options,
18
- context,
19
- });
20
- (0, apply_react_config_1.applyReactConfig)({}, config);
21
- return config;
22
- };
12
+ return (config) => config;
23
13
  }
@@ -1,6 +1,5 @@
1
- import type { Configuration } from '@rspack/core';
2
- import { ExtraEntryPointClass } from './model';
3
- import { NxRspackExecutionContext } from './config';
1
+ import type { NxComposableRspackPlugin } from './config';
2
+ import type { ExtraEntryPointClass } from './model';
4
3
  export interface WithWebOptions {
5
4
  baseHref?: string;
6
5
  deployUrl?: string;
@@ -28,9 +27,7 @@ export interface WithWebOptions {
28
27
  templateParameters?: Record<string, string> | boolean | ((params: Record<string, any>) => Record<string, any> | Promise<Record<string, any>>);
29
28
  }
30
29
  /**
31
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
32
- * `@nx/rspack/app-plugin` in a standard rspack config and run
33
- * `nx g @nx/rspack:convert-to-inferred`. See
34
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
30
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
31
+ * This inert stub will be removed in Nx v25.
35
32
  */
36
- export declare function withWeb(pluginOptions?: WithWebOptions): (config: Configuration, { options, context }: NxRspackExecutionContext) => Configuration;
33
+ export declare function withWeb(_options?: WithWebOptions): NxComposableRspackPlugin;
@@ -1,52 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withWeb = withWeb;
4
- const apply_web_config_1 = require("../plugins/utils/apply-web-config");
5
4
  const deprecation_1 = require("./deprecation");
6
- const processed = new Set();
5
+ // TODO(v25): remove the inert config-helper stubs in this file.
7
6
  /**
8
- * @deprecated Will be removed in Nx v24. Use `NxAppRspackPlugin` from
9
- * `@nx/rspack/app-plugin` in a standard rspack config and run
10
- * `nx g @nx/rspack:convert-to-inferred`. See
11
- * https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.
7
+ * @deprecated Use `NxAppRspackPlugin` from `@nx/rspack/app-plugin`.
8
+ * This inert stub will be removed in Nx v25.
12
9
  */
13
- function withWeb(pluginOptions = {}) {
10
+ function withWeb(_options = {}) {
14
11
  (0, deprecation_1.warnRspackComposeHelpersDeprecation)();
15
- return function makeConfig(config, { options, context }) {
16
- if (processed.has(config)) {
17
- return config;
18
- }
19
- (0, apply_web_config_1.applyWebConfig)({
20
- ...options,
21
- ...pluginOptions,
22
- root: context.root,
23
- projectName: context.projectName,
24
- targetName: context.targetName,
25
- configurationName: context.configurationName,
26
- projectGraph: context.projectGraph,
27
- useLegacyHtmlPlugin: pluginOptions.useLegacyHtmlPlugin ?? false,
28
- }, config);
29
- processed.add(config);
30
- return config;
31
- };
32
- }
33
- function getClientEnvironment(mode) {
34
- // Grab NODE_ENV and NX_PUBLIC_* environment variables and prepare them to be
35
- // injected into the application via DefinePlugin in rspack configuration.
36
- const nxPublicKeyRegex = /^NX_PUBLIC_/i;
37
- const raw = Object.keys(process.env)
38
- .filter((key) => nxPublicKeyRegex.test(key))
39
- .reduce((env, key) => {
40
- env[key] = process.env[key];
41
- return env;
42
- }, {});
43
- // Stringify all values so we can feed into rspack DefinePlugin
44
- const stringified = Object.keys(raw).reduce((env, key) => {
45
- env[`process.env.${key}`] = JSON.stringify(raw[key]);
46
- return env;
47
- },
48
- // Provide a fallback for process.env itself to handle cases where code
49
- // accesses process.env directly (e.g., in Cypress component testing)
50
- { 'process.env': '({})' });
51
- return { stringified };
12
+ return (config) => config;
52
13
  }
package/executors.json CHANGED
@@ -1,35 +1,10 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "executors": {
4
- "rspack": {
5
- "implementation": "./dist/src/executors/rspack/rspack.impl",
6
- "schema": "./dist/src/executors/rspack/schema.json",
7
- "description": "Run Rspack via an executor for a project."
8
- },
9
- "dev-server": {
10
- "implementation": "./dist/src/executors/dev-server/dev-server.impl",
11
- "schema": "./dist/src/executors/dev-server/schema.json",
12
- "description": "Run @rspack/dev-server to serve a project."
13
- },
14
4
  "ssr-dev-server": {
15
5
  "implementation": "./dist/src/executors/ssr-dev-server/ssr-dev-server.impl",
16
6
  "schema": "./dist/src/executors/ssr-dev-server/schema.json",
17
7
  "description": "Serve a SSR application."
18
- },
19
- "module-federation-dev-server": {
20
- "implementation": "./dist/src/executors/module-federation-dev-server/module-federation-dev-server.impl",
21
- "schema": "./dist/src/executors/module-federation-dev-server/schema.json",
22
- "description": "Serve a host or remote application."
23
- },
24
- "module-federation-ssr-dev-server": {
25
- "implementation": "./dist/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl",
26
- "schema": "./dist/src/executors/module-federation-ssr-dev-server/schema.json",
27
- "description": "Serve a host application along with it's known remotes."
28
- },
29
- "module-federation-static-server": {
30
- "implementation": "./dist/src/executors/module-federation-static-server/module-federation-static-server.impl",
31
- "schema": "./dist/src/executors/module-federation-static-server/schema.json",
32
- "description": "Serve a host and its remotes statically."
33
8
  }
34
9
  }
35
10
  }
package/migrations.json CHANGED
@@ -36,6 +36,19 @@
36
36
  "requires": {
37
37
  "@rspack/core": ">=2.0.0"
38
38
  }
39
+ },
40
+ "remove-deprecated-executors": {
41
+ "version": "24.0.0-beta.3",
42
+ "description": "Converts targets using the removed `@nx/rspack` executors to inferred tasks; an AI prompt finishes the targets the converter cannot convert safely and validates the project graph.",
43
+ "implementation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors",
44
+ "prompt": "./dist/src/migrations/update-24-0-0/finish-inferred-conversion.md",
45
+ "documentation": "./dist/src/migrations/update-24-0-0/remove-deprecated-executors.md"
46
+ },
47
+ "update-24-0-0-migrate-compose-plugins": {
48
+ "version": "24.0.0-beta.3",
49
+ "description": "Converts Rspack configs that use the removed `composePlugins`, `withNx`, `withWeb` and `withReact` helpers with `@nx/rspack:convert-config-to-rspack-plugin`, then hands an AI prompt the projects it could not convert and the `.old` configs it left behind.",
50
+ "implementation": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins",
51
+ "prompt": "./dist/src/migrations/update-24-0-0/migrate-compose-plugins.md"
39
52
  }
40
53
  },
41
54
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/rspack",
3
3
  "description": "The Nx Plugin for Rspack contains executors and generators that support building applications using Rspack.",
4
- "version": "24.0.0-beta.1",
4
+ "version": "24.0.0-beta.3",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -37,12 +37,6 @@
37
37
  "app-plugin.js": [
38
38
  "dist/app-plugin.d.ts"
39
39
  ],
40
- "module-federation": [
41
- "dist/module-federation.d.ts"
42
- ],
43
- "module-federation.js": [
44
- "dist/module-federation.d.ts"
45
- ],
46
40
  "plugin": [
47
41
  "dist/plugin.d.ts"
48
42
  ],
@@ -85,16 +79,6 @@
85
79
  "types": "./dist/app-plugin.d.ts",
86
80
  "default": "./dist/app-plugin.js"
87
81
  },
88
- "./module-federation": {
89
- "@nx/nx-source": "./module-federation.ts",
90
- "types": "./dist/module-federation.d.ts",
91
- "default": "./dist/module-federation.js"
92
- },
93
- "./module-federation.js": {
94
- "@nx/nx-source": "./module-federation.ts",
95
- "types": "./dist/module-federation.d.ts",
96
- "default": "./dist/module-federation.js"
97
- },
98
82
  "./plugin": {
99
83
  "@nx/nx-source": "./plugin.ts",
100
84
  "types": "./dist/plugin.d.ts",
@@ -127,16 +111,13 @@
127
111
  }
128
112
  },
129
113
  "dependencies": {
130
- "@nx/devkit": "24.0.0-beta.1",
131
- "@nx/js": "24.0.0-beta.1",
132
- "@nx/module-federation": "24.0.0-beta.1",
133
- "@nx/web": "24.0.0-beta.1",
114
+ "@nx/devkit": "24.0.0-beta.3",
115
+ "@nx/js": "24.0.0-beta.3",
116
+ "@nx/web": "24.0.0-beta.3",
134
117
  "@phenomnomnominal/tsquery": "~6.2.0",
135
118
  "autoprefixer": "^10.4.9",
136
119
  "browserslist": "^4.26.0",
137
120
  "css-loader": "^7.1.4",
138
- "express": "^4.21.2",
139
- "http-proxy-middleware": "^3.0.7",
140
121
  "less-loader": "^12.2.0",
141
122
  "license-webpack-plugin": "^4.0.2",
142
123
  "loader-utils": "^2.0.3",
@@ -157,8 +138,8 @@
157
138
  "webpack-node-externals": "^3.0.0"
158
139
  },
159
140
  "devDependencies": {
160
- "nx": "24.0.0-beta.1",
161
- "@nx/nest": "24.0.0-beta.1",
141
+ "nx": "24.0.0-beta.3",
142
+ "@nx/nest": "24.0.0-beta.3",
162
143
  "@rspack/cli": "^2.0.4"
163
144
  },
164
145
  "peerDependencies": {
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated Use `@nx/module-federation/rspack` instead. This will be removed in Nx v22.
3
- */
4
- export { withModuleFederation, withModuleFederationForSSR, } from '@nx/module-federation/rspack';
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
4
- /**
5
- * @deprecated Use `@nx/module-federation/rspack` instead. This will be removed in Nx v22.
6
- */
7
- var rspack_1 = require("@nx/module-federation/rspack");
8
- Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return rspack_1.withModuleFederation; } });
9
- Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return rspack_1.withModuleFederationForSSR; } });
@@ -1,2 +0,0 @@
1
- export * from './normalize-options';
2
- export * from './start-remotes';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./normalize-options"), exports);
5
- tslib_1.__exportStar(require("./start-remotes"), exports);
@@ -1,4 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { ModuleFederationDevServerOptions, NormalizedModuleFederationDevServerOptions } from '../schema';
3
- export declare function getBuildOptions(buildTarget: string, context: ExecutorContext): any;
4
- export declare function normalizeOptions(options: ModuleFederationDevServerOptions): NormalizedModuleFederationDevServerOptions;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBuildOptions = getBuildOptions;
4
- exports.normalizeOptions = normalizeOptions;
5
- const devkit_1 = require("@nx/devkit");
6
- function getBuildOptions(buildTarget, context) {
7
- const target = (0, devkit_1.parseTargetString)(buildTarget, context);
8
- const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
9
- return {
10
- ...buildOptions,
11
- };
12
- }
13
- function normalizeOptions(options) {
14
- return {
15
- ...options,
16
- devRemotes: options.devRemotes ?? [],
17
- verbose: options.verbose ?? false,
18
- };
19
- }
@@ -1,5 +0,0 @@
1
- import { ModuleFederationDevServerOptions } from '../schema';
2
- import { ProjectConfiguration, ExecutorContext } from '@nx/devkit';
3
- export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Partial<Pick<ModuleFederationDevServerOptions, 'devRemotes' | 'host' | 'ssl' | 'sslCert' | 'sslKey' | 'verbose'>>, context: ExecutorContext, target?: 'serve' | 'serve-static'): Promise<AsyncIterable<{
4
- success: boolean;
5
- }>[]>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startRemotes = startRemotes;
4
- const devkit_1 = require("@nx/devkit");
5
- async function startRemotes(remotes, workspaceProjects, options, context, target = 'serve') {
6
- const remoteIters = [];
7
- for (const app of remotes) {
8
- const remoteProjectServeTarget = workspaceProjects[app].targets[target];
9
- const isUsingModuleFederationDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-dev-server');
10
- const configurationOverride = options.devRemotes?.find((r) => typeof r !== 'string' && r.remoteName === app)?.configuration;
11
- const defaultOverrides = {
12
- ...(options.host ? { host: options.host } : {}),
13
- ...(options.ssl ? { ssl: options.ssl } : {}),
14
- ...(options.sslCert ? { sslCert: options.sslCert } : {}),
15
- ...(options.sslKey ? { sslKey: options.sslKey } : {}),
16
- };
17
- const overrides = target === 'serve'
18
- ? {
19
- watch: true,
20
- ...(isUsingModuleFederationDevServerExecutor
21
- ? { isInitialHost: false }
22
- : {}),
23
- ...defaultOverrides,
24
- }
25
- : { ...defaultOverrides };
26
- remoteIters.push(await (0, devkit_1.runExecutor)({
27
- project: app,
28
- target,
29
- configuration: configurationOverride ?? context.configurationName,
30
- }, overrides, context));
31
- }
32
- return remoteIters;
33
- }
@@ -1,6 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { ModuleFederationDevServerOptions } from './schema';
3
- export default function moduleFederationDevServer(schema: ModuleFederationDevServerOptions, context: ExecutorContext): AsyncIterableIterator<{
4
- success: boolean;
5
- baseUrl?: string;
6
- }>;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = moduleFederationDevServer;
4
- const tslib_1 = require("tslib");
5
- const devkit_1 = require("@nx/devkit");
6
- const internal_1 = require("@nx/devkit/internal");
7
- const internal_2 = require("@nx/js/internal");
8
- const internal_3 = require("@nx/module-federation/internal");
9
- const internal_4 = require("@nx/web/internal");
10
- const fs_1 = require("fs");
11
- const path_1 = require("path");
12
- const dev_server_impl_1 = tslib_1.__importDefault(require("../dev-server/dev-server.impl"));
13
- const lib_1 = require("./lib");
14
- const module_federation_deprecation_1 = require("../../utils/module-federation-deprecation");
15
- async function* moduleFederationDevServer(schema, context) {
16
- (0, module_federation_deprecation_1.warnRspackMfDevServerExecutorDeprecation)();
17
- const options = (0, lib_1.normalizeOptions)(schema);
18
- const currIter = options.static
19
- ? (0, internal_4.fileServerExecutor)({
20
- ...options,
21
- parallel: false,
22
- withDeps: false,
23
- spa: false,
24
- cors: true,
25
- cacheSeconds: -1,
26
- }, context)
27
- : (0, dev_server_impl_1.default)(options, context);
28
- const p = context.projectsConfigurations.projects[context.projectName];
29
- let pathToManifestFile = (0, path_1.join)(context.root, (0, internal_2.getProjectSourceRoot)(p), 'assets/module-federation.manifest.json');
30
- if (options.pathToManifestFile) {
31
- const userPathToManifestFile = (0, path_1.join)(context.root, options.pathToManifestFile);
32
- if (!(0, fs_1.existsSync)(userPathToManifestFile)) {
33
- throw new Error(`The provided Module Federation manifest file path does not exist. Please check the file exists at "${userPathToManifestFile}".`);
34
- }
35
- else if ((0, path_1.extname)(options.pathToManifestFile) !== '.json') {
36
- throw new Error(`The Module Federation manifest file must be a JSON. Please ensure the file at ${userPathToManifestFile} is a JSON.`);
37
- }
38
- pathToManifestFile = userPathToManifestFile;
39
- }
40
- if (!options.isInitialHost) {
41
- return yield* currIter;
42
- }
43
- const { staticRemotesIter, devRemoteIters, remotes } = await (0, internal_3.startRemoteIterators)(options, context, lib_1.startRemotes, pathToManifestFile, 'react');
44
- return yield* (0, internal_1.combineAsyncIterables)(currIter, ...devRemoteIters, ...(staticRemotesIter ? [staticRemotesIter] : []), (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
45
- if (!options.isInitialHost) {
46
- done();
47
- return;
48
- }
49
- if (remotes.remotePorts.length === 0) {
50
- done();
51
- return;
52
- }
53
- try {
54
- const host = options.host ?? 'localhost';
55
- const baseUrl = `http${options.ssl ? 's' : ''}://${host}:${options.port}`;
56
- const portsToWaitFor = staticRemotesIter && options.staticRemotesPort
57
- ? [options.staticRemotesPort, ...remotes.remotePorts]
58
- : [...remotes.remotePorts];
59
- await Promise.all(portsToWaitFor.map((port) => (0, internal_4.waitForPortOpen)(port, {
60
- retries: 480,
61
- retryDelay: 2500,
62
- host: host,
63
- })));
64
- devkit_1.logger.info(`NX All remotes started, server ready at ${baseUrl}`);
65
- next({ success: true, baseUrl: baseUrl });
66
- }
67
- catch (err) {
68
- throw new Error(`Failed to start remotes. Check above for any errors.`);
69
- }
70
- finally {
71
- done();
72
- }
73
- }));
74
- }
@@ -1,25 +0,0 @@
1
- import { DevServerExecutorSchema } from '../dev-server/schema';
2
-
3
- export type ModuleFederationDevServerOptions = DevServerExecutorSchema & {
4
- // Module Federation Specific Options
5
- devRemotes?: (
6
- | string
7
- | {
8
- remoteName: string;
9
- configuration: string;
10
- }
11
- )[];
12
- skipRemotes?: string[];
13
- static?: boolean;
14
- isInitialHost?: boolean;
15
- parallel?: number;
16
- staticRemotesPort?: number;
17
- pathToManifestFile?: string;
18
- verbose?: boolean;
19
- };
20
-
21
- export type NormalizedModuleFederationDevServerOptions =
22
- ModuleFederationDevServerOptions & {
23
- devRemotes: DevServerExecutorSchema['devRemotes'];
24
- verbose: boolean;
25
- };
@@ -1,104 +0,0 @@
1
- {
2
- "version": 2,
3
- "continuous": true,
4
- "outputCapture": "direct-nodejs",
5
- "title": "Rspack Module Federation Dev Server",
6
- "x-deprecated": "The `@nx/rspack:module-federation-dev-server` executor is deprecated. Dynamic federation in `@nx/react:consumer` removes the need for host-orchestrated remote serving. Removed in Nx v24.",
7
- "description": "Serve a module federation application.",
8
- "cli": "nx",
9
- "type": "object",
10
- "properties": {
11
- "devRemotes": {
12
- "type": "array",
13
- "items": {
14
- "oneOf": [
15
- {
16
- "type": "string"
17
- },
18
- {
19
- "type": "object",
20
- "properties": {
21
- "remoteName": {
22
- "type": "string"
23
- },
24
- "configuration": {
25
- "type": "string"
26
- }
27
- },
28
- "required": ["remoteName"],
29
- "additionalProperties": false
30
- }
31
- ]
32
- },
33
- "description": "List of Producer (remote) applications to run in development mode (i.e. using serve target).",
34
- "x-priority": "important",
35
- "alias": "devProducers"
36
- },
37
- "skipRemotes": {
38
- "type": "array",
39
- "items": {
40
- "type": "string"
41
- },
42
- "description": "List of Producer (remote) applications to not automatically serve, either statically or in development mode. This will not remove the Producers (remotes) from the `module-federation.config` file, and therefore the application may still try to fetch these Producers (remotes).\nThis option is useful if you have other means for serving the Producer (remote) application(s).\n**NOTE:** Producers (remotes) that are not in the workspace will be skipped automatically.",
43
- "x-priority": "important",
44
- "alias": "skipProducers"
45
- },
46
- "buildTarget": {
47
- "type": "string",
48
- "description": "Target which builds the application.",
49
- "x-priority": "important"
50
- },
51
- "port": {
52
- "type": "number",
53
- "description": "Port to listen on.",
54
- "default": 4200,
55
- "x-priority": "important"
56
- },
57
- "host": {
58
- "type": "string",
59
- "description": "Host to listen on.",
60
- "default": "localhost"
61
- },
62
- "ssl": {
63
- "type": "boolean",
64
- "description": "Serve using `HTTPS`.",
65
- "default": false
66
- },
67
- "sslKey": {
68
- "type": "string",
69
- "description": "SSL key to use for serving `HTTPS`."
70
- },
71
- "sslCert": {
72
- "type": "string",
73
- "description": "SSL certificate to use for serving `HTTPS`."
74
- },
75
- "publicHost": {
76
- "type": "string",
77
- "description": "Public URL where the application will be served."
78
- },
79
- "static": {
80
- "type": "boolean",
81
- "description": "Whether to use a static file server instead of the rspack-dev-server. This should be used for Producer (remote) applications that are also Consumer (host) applications."
82
- },
83
- "isInitialHost": {
84
- "type": "boolean",
85
- "description": "Whether the Consumer (host) that is running this executor is the first in the project tree to do so.",
86
- "default": true,
87
- "x-priority": "internal",
88
- "alias": "isInitialConsumer"
89
- },
90
- "parallel": {
91
- "type": "number",
92
- "description": "Max number of parallel processes for building static Producers (remotes)."
93
- },
94
- "staticRemotesPort": {
95
- "type": "number",
96
- "description": "The port at which to serve the file-server for the static Producers (remotes).",
97
- "alias": "staticProducersPort"
98
- },
99
- "pathToManifestFile": {
100
- "type": "string",
101
- "description": "Path to a Module Federation manifest file (e.g. `my/path/to/module-federation.manifest.json`) containing the dynamic Producer (remote) applications relative to the workspace root."
102
- }
103
- }
104
- }
@@ -1,2 +0,0 @@
1
- export * from './normalize-options';
2
- export * from './start-remotes';
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./normalize-options"), exports);
5
- tslib_1.__exportStar(require("./start-remotes"), exports);
@@ -1,4 +0,0 @@
1
- import { ModuleFederationSsrDevServerOptions, NormalizedModuleFederationSsrDevServerOptions } from '../schema';
2
- import { ExecutorContext } from '@nx/devkit';
3
- export declare function normalizeOptions(options: ModuleFederationSsrDevServerOptions): NormalizedModuleFederationSsrDevServerOptions;
4
- export declare function getBuildOptions(buildTarget: string, context: ExecutorContext): any;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptions = normalizeOptions;
4
- exports.getBuildOptions = getBuildOptions;
5
- const path_1 = require("path");
6
- const devkit_1 = require("@nx/devkit");
7
- function normalizeOptions(options) {
8
- return {
9
- ...options,
10
- devRemotes: options.devRemotes ?? [],
11
- verbose: options.verbose ?? false,
12
- ssl: options.ssl ?? false,
13
- sslCert: options.sslCert ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslCert) : undefined,
14
- sslKey: options.sslKey ? (0, path_1.join)(devkit_1.workspaceRoot, options.sslKey) : undefined,
15
- };
16
- }
17
- function getBuildOptions(buildTarget, context) {
18
- const target = (0, devkit_1.parseTargetString)(buildTarget, context);
19
- const buildOptions = (0, devkit_1.readTargetOptions)(target, context);
20
- return {
21
- ...buildOptions,
22
- };
23
- }
@@ -1,5 +0,0 @@
1
- import { ModuleFederationSsrDevServerOptions } from '../schema';
2
- import { ExecutorContext, ProjectConfiguration } from '@nx/devkit';
3
- export declare function startRemotes(remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: Partial<Pick<ModuleFederationSsrDevServerOptions, 'devRemotes' | 'host' | 'ssl' | 'sslCert' | 'sslKey' | 'verbose'>>, context: ExecutorContext): Promise<AsyncIterable<{
4
- success: boolean;
5
- }>[]>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startRemotes = startRemotes;
4
- const devkit_1 = require("@nx/devkit");
5
- async function startRemotes(remotes, workspaceProjects, options, context) {
6
- const remoteIters = [];
7
- const target = 'serve';
8
- for (const app of remotes) {
9
- const remoteProjectServeTarget = workspaceProjects[app].targets[target];
10
- const isUsingModuleFederationSsrDevServerExecutor = remoteProjectServeTarget.executor.includes('module-federation-ssr-dev-server');
11
- const configurationOverride = options.devRemotes?.find((remote) => typeof remote !== 'string' && remote.remoteName === app)?.configuration;
12
- {
13
- const defaultOverrides = {
14
- ...(options.host ? { host: options.host } : {}),
15
- ...(options.ssl ? { ssl: options.ssl } : {}),
16
- ...(options.sslCert ? { sslCert: options.sslCert } : {}),
17
- ...(options.sslKey ? { sslKey: options.sslKey } : {}),
18
- };
19
- const overrides = {
20
- watch: true,
21
- ...defaultOverrides,
22
- ...(isUsingModuleFederationSsrDevServerExecutor
23
- ? { isInitialHost: false }
24
- : {}),
25
- };
26
- remoteIters.push(await (0, devkit_1.runExecutor)({
27
- project: app,
28
- target,
29
- configuration: configurationOverride ?? context.configurationName,
30
- }, overrides, context));
31
- }
32
- }
33
- return remoteIters;
34
- }
@@ -1,5 +0,0 @@
1
- import { ExecutorContext } from '@nx/devkit';
2
- import { ModuleFederationSsrDevServerOptions } from './schema';
3
- export default function moduleFederationSsrDevServer(ssrDevServerOptions: ModuleFederationSsrDevServerOptions, context: ExecutorContext): AsyncGenerator<{
4
- success: boolean;
5
- }, any, any>;