@nx/module-federation 23.0.0-rc.4 → 23.1.0-beta.0

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 (27) hide show
  1. package/README.md +1 -2
  2. package/dist/src/executors/utils/build-static-remotes.js +2 -5
  3. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.d.ts +1 -1
  4. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.js +3 -4
  5. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.d.ts +1 -1
  6. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.js +9 -6
  7. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.d.ts +1 -1
  8. package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.js +3 -4
  9. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.d.ts +1 -1
  10. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.js +3 -4
  11. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.d.ts +1 -1
  12. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.d.ts +1 -1
  13. package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.js +3 -4
  14. package/dist/src/plugins/utils/build-static-remotes.js +2 -4
  15. package/dist/src/utils/is-serve-mode.d.ts +2 -0
  16. package/dist/src/utils/is-serve-mode.js +19 -0
  17. package/dist/src/utils/models/index.d.ts +1 -1
  18. package/dist/src/utils/rspack-version.d.ts +3 -0
  19. package/dist/src/utils/rspack-version.js +11 -0
  20. package/dist/src/utils/share.js +10 -9
  21. package/dist/src/with-module-federation/angular/with-module-federation-ssr.js +2 -1
  22. package/dist/src/with-module-federation/angular/with-module-federation.js +2 -1
  23. package/dist/src/with-module-federation/rspack/with-module-federation-ssr.js +4 -3
  24. package/dist/src/with-module-federation/rspack/with-module-federation.js +6 -3
  25. package/dist/src/with-module-federation/webpack/with-module-federation-ssr.js +2 -1
  26. package/dist/src/with-module-federation/webpack/with-module-federation.js +2 -1
  27. package/package.json +6 -6
package/README.md CHANGED
@@ -7,13 +7,12 @@
7
7
 
8
8
  <div style="text-align: center;">
9
9
 
10
- [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
10
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
11
  [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
12
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
13
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
- [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
14
  [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
15
+ [![Nx Sandboxing](https://staging.nx.app/workspaces/62d013ea0852fe0a2df74438/sandbox-badge.svg)](https://nx.dev/docs/features/ci-features/sandboxing)
17
16
 
18
17
  </div>
19
18
 
@@ -6,6 +6,7 @@ const node_child_process_1 = require("node:child_process");
6
6
  const path_1 = require("path");
7
7
  const cache_directory_1 = require("nx/src/utils/cache-directory");
8
8
  const fs_1 = require("fs");
9
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
9
10
  async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options, buildTarget = 'build') {
10
11
  if (!staticRemotesConfig.remotes.length) {
11
12
  return;
@@ -27,11 +28,7 @@ async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options,
27
28
  ], {
28
29
  cwd: context.root,
29
30
  stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
30
- env: {
31
- ...process.env,
32
- // Ensure that webpack serve env var is not passed to static remotes
33
- WEBPACK_SERVE: 'false',
34
- },
31
+ env: (0, is_serve_mode_1.childBuildEnv)(),
35
32
  });
36
33
  // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
37
34
  const remoteBuildLogFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig } from '../../../utils/models';
3
3
  import { NxModuleFederationDevServerConfig } from '../../models';
4
4
  export declare class NxModuleFederationDevServerPlugin implements RspackPluginInstance {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NxModuleFederationDevServerPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const core_1 = require("@rspack/core");
5
+ const is_serve_mode_1 = require("../../../utils/is-serve-mode");
6
6
  const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const path_1 = require("path");
@@ -18,8 +18,7 @@ class NxModuleFederationDevServerPlugin {
18
18
  };
19
19
  }
20
20
  apply(compiler) {
21
- const isDevServer = process.env['WEBPACK_SERVE'];
22
- if (!isDevServer) {
21
+ if (!(0, is_serve_mode_1.isServeMode)()) {
23
22
  return;
24
23
  }
25
24
  let initialized = false;
@@ -34,7 +33,7 @@ class NxModuleFederationDevServerPlugin {
34
33
  pathToCert: this._options.devServerConfig.sslCert,
35
34
  pathToKey: this._options.devServerConfig.sslKey,
36
35
  }, false, this._options.devServerConfig.host);
37
- new core_1.DefinePlugin({
36
+ new compiler.rspack.DefinePlugin({
38
37
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
39
38
  }).apply(compiler);
40
39
  }
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../../utils/models';
3
3
  export declare class NxModuleFederationPlugin implements RspackPluginInstance {
4
4
  private _options;
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NxModuleFederationPlugin = void 0;
4
4
  const utils_1 = require("../../../with-module-federation/angular/utils");
5
5
  const utils_2 = require("../../../utils");
6
+ const rspack_version_1 = require("../../../utils/rspack-version");
7
+ const is_serve_mode_1 = require("../../../utils/is-serve-mode");
6
8
  const devkit_1 = require("@nx/devkit");
7
9
  class NxModuleFederationPlugin {
8
10
  constructor(_options, configOverride) {
@@ -16,7 +18,7 @@ class NxModuleFederationPlugin {
16
18
  // This is required to ensure Module Federation will build the project correctly
17
19
  compiler.options.optimization ??= {};
18
20
  compiler.options.optimization.runtimeChunk =
19
- process.env['WEBPACK_SERVE'] && !this._options.config.exposes
21
+ (0, is_serve_mode_1.isServeMode)() && !this._options.config.exposes
20
22
  ? (compiler.options.optimization?.runtimeChunk ?? undefined)
21
23
  : false;
22
24
  if (compiler.options.optimization.splitChunks) {
@@ -43,12 +45,13 @@ class NxModuleFederationPlugin {
43
45
  compiler.options.output.library.type = 'commonjs-module';
44
46
  }
45
47
  else {
46
- // Ensure ESM output is enabled when using library type 'module'.
47
- // Without these, remoteEntry.js emits `export` statements but the
48
- // runtime loads it as a classic script, causing "Unexpected token 'export'".
49
- compiler.options.experiments ??= {};
50
- compiler.options.experiments.outputModule = true;
48
+ // Required so remoteEntry.js loads as a module, not a classic script.
49
+ // v2 folded experiments.outputModule into output.module.
51
50
  compiler.options.output.module = true;
51
+ if (!(0, rspack_version_1.isRspackV2)(compiler)) {
52
+ compiler.options.experiments ??= {};
53
+ compiler.options.experiments.outputModule = true;
54
+ }
52
55
  }
53
56
  const config = (0, utils_1.getModuleFederationConfigSync)(this._options.config, {
54
57
  isServer: this._options.isServer,
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig } from '../../../utils/models';
3
3
  import { NxModuleFederationDevServerConfig } from '../../models';
4
4
  export declare class NxModuleFederationSSRDevServerPlugin implements RspackPluginInstance {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NxModuleFederationSSRDevServerPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const core_1 = require("@rspack/core");
5
+ const is_serve_mode_1 = require("../../../utils/is-serve-mode");
6
6
  const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const path_1 = require("path");
@@ -19,8 +19,7 @@ class NxModuleFederationSSRDevServerPlugin {
19
19
  };
20
20
  }
21
21
  apply(compiler) {
22
- const isDevServer = process.env['WEBPACK_SERVE'];
23
- if (!isDevServer) {
22
+ if (!(0, is_serve_mode_1.isServeMode)()) {
24
23
  return;
25
24
  }
26
25
  compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
@@ -33,7 +32,7 @@ class NxModuleFederationSSRDevServerPlugin {
33
32
  pathToCert: this._options.devServerConfig.sslCert,
34
33
  pathToKey: this._options.devServerConfig.sslKey,
35
34
  }, true, this._options.devServerConfig.host);
36
- new core_1.DefinePlugin({
35
+ new compiler.rspack.DefinePlugin({
37
36
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
38
37
  }).apply(compiler);
39
38
  await this.startServer(compiler);
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig } from '../../../utils/models';
3
3
  import { NxModuleFederationDevServerConfig } from '../../models';
4
4
  export declare class NxModuleFederationDevServerPlugin implements RspackPluginInstance {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NxModuleFederationDevServerPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const core_1 = require("@rspack/core");
5
+ const is_serve_mode_1 = require("../../../utils/is-serve-mode");
6
6
  const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const path_1 = require("path");
@@ -18,8 +18,7 @@ class NxModuleFederationDevServerPlugin {
18
18
  };
19
19
  }
20
20
  apply(compiler) {
21
- const isDevServer = process.env['WEBPACK_SERVE'];
22
- if (!isDevServer) {
21
+ if (!(0, is_serve_mode_1.isServeMode)()) {
23
22
  return;
24
23
  }
25
24
  let initialized = false;
@@ -34,7 +33,7 @@ class NxModuleFederationDevServerPlugin {
34
33
  pathToCert: this._options.devServerConfig.sslCert,
35
34
  pathToKey: this._options.devServerConfig.sslKey,
36
35
  }, false, this._options.devServerConfig.host);
37
- new core_1.DefinePlugin({
36
+ new compiler.rspack.DefinePlugin({
38
37
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
39
38
  }).apply(compiler);
40
39
  }
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../../utils/models';
3
3
  export declare class NxModuleFederationPlugin implements RspackPluginInstance {
4
4
  private _options;
@@ -1,4 +1,4 @@
1
- import { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { ModuleFederationConfig } from '../../../utils/models';
3
3
  import { NxModuleFederationDevServerConfig } from '../../models';
4
4
  export declare class NxModuleFederationSSRDevServerPlugin implements RspackPluginInstance {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NxModuleFederationSSRDevServerPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const core_1 = require("@rspack/core");
5
+ const is_serve_mode_1 = require("../../../utils/is-serve-mode");
6
6
  const pc = tslib_1.__importStar(require("picocolors"));
7
7
  const devkit_1 = require("@nx/devkit");
8
8
  const path_1 = require("path");
@@ -19,8 +19,7 @@ class NxModuleFederationSSRDevServerPlugin {
19
19
  };
20
20
  }
21
21
  apply(compiler) {
22
- const isDevServer = process.env['WEBPACK_SERVE'];
23
- if (!isDevServer) {
22
+ if (!(0, is_serve_mode_1.isServeMode)()) {
24
23
  return;
25
24
  }
26
25
  compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, async (compiler, callback) => {
@@ -33,7 +32,7 @@ class NxModuleFederationSSRDevServerPlugin {
33
32
  pathToCert: this._options.devServerConfig.sslCert,
34
33
  pathToKey: this._options.devServerConfig.sslKey,
35
34
  }, true, this._options.devServerConfig.host);
36
- new core_1.DefinePlugin({
35
+ new compiler.rspack.DefinePlugin({
37
36
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
38
37
  }).apply(compiler);
39
38
  await this.startServer(compiler);
@@ -6,6 +6,7 @@ const path_1 = require("path");
6
6
  const node_fs_1 = require("node:fs");
7
7
  const cache_directory_1 = require("nx/src/utils/cache-directory");
8
8
  const devkit_1 = require("@nx/devkit");
9
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
9
10
  async function buildStaticRemotes(staticRemotesConfig, options, nxBin) {
10
11
  const remotes = Object.keys(staticRemotesConfig);
11
12
  if (!remotes.length) {
@@ -25,10 +26,7 @@ async function buildStaticRemotes(staticRemotesConfig, options, nxBin) {
25
26
  ], {
26
27
  cwd: devkit_1.workspaceRoot,
27
28
  stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
28
- env: {
29
- ...process.env,
30
- WEBPACK_SERVE: 'false',
31
- },
29
+ env: (0, is_serve_mode_1.childBuildEnv)(),
32
30
  });
33
31
  // File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
34
32
  const remoteBuildLogFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
@@ -0,0 +1,2 @@
1
+ export declare function isServeMode(): boolean;
2
+ export declare function childBuildEnv(): NodeJS.ProcessEnv;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isServeMode = isServeMode;
4
+ exports.childBuildEnv = childBuildEnv;
5
+ // v1 dev-server sets WEBPACK_SERVE on module load; v2 sets RSPACK_SERVE.
6
+ // rspack-cli imports the dev-server before loading the user config.
7
+ function isServeMode() {
8
+ return !!process.env['WEBPACK_SERVE'] || !!process.env['RSPACK_SERVE'];
9
+ }
10
+ function childBuildEnv() {
11
+ const { WEBPACK_SERVE, RSPACK_SERVE, ...rest } = process.env;
12
+ return {
13
+ ...rest,
14
+ // Static remotes for a dev-server session are development builds.
15
+ // angular-rspack picks production when no serve signal is present, which
16
+ // would enforce bundle budgets and optimization on a dev workflow.
17
+ NGRS_CONFIG: rest.NGRS_CONFIG ?? 'development',
18
+ };
19
+ }
@@ -1,5 +1,5 @@
1
1
  import type { moduleFederationPlugin } from '@module-federation/enhanced';
2
- import { NormalModuleReplacementPlugin as RspackNormalModuleReplacementPlugin } from '@rspack/core';
2
+ import type { NormalModuleReplacementPlugin as RspackNormalModuleReplacementPlugin } from '@rspack/core';
3
3
  export type ModuleFederationLibrary = {
4
4
  type: string;
5
5
  name: string;
@@ -0,0 +1,3 @@
1
+ import type { Compiler } from '@rspack/core';
2
+ export declare function getRspackMajorVersion(compiler: Compiler): number;
3
+ export declare function isRspackV2(compiler: Compiler): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRspackMajorVersion = getRspackMajorVersion;
4
+ exports.isRspackV2 = isRspackV2;
5
+ // Read from compiler.rspack to avoid a value import of the (pure-ESM) v2 package.
6
+ function getRspackMajorVersion(compiler) {
7
+ return parseInt(compiler.rspack.rspackVersion ?? '1', 10);
8
+ }
9
+ function isRspackV2(compiler) {
10
+ return getRspackMajorVersion(compiler) >= 2;
11
+ }
@@ -11,7 +11,14 @@ const typescript_1 = require("./typescript");
11
11
  const secondary_entry_points_1 = require("./secondary-entry-points");
12
12
  const devkit_1 = require("@nx/devkit");
13
13
  const fs_1 = require("fs");
14
- const core_1 = require("@rspack/core");
14
+ // Deferred so a top-level import of @rspack/core (pure ESM in v2) doesn't
15
+ // crash Jest's CJS loading of any test that imports this module.
16
+ function loadNormalModuleReplacementPlugin(bundler) {
17
+ if (bundler === 'rspack') {
18
+ return require('@rspack/core').NormalModuleReplacementPlugin;
19
+ }
20
+ return require('webpack').NormalModuleReplacementPlugin;
21
+ }
15
22
  /**
16
23
  * Checks if a version string is a workspace protocol version that needs normalization.
17
24
  * This includes pnpm workspace protocol (workspace:*), file: protocol, or bare *.
@@ -97,9 +104,6 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
97
104
  }
98
105
  }
99
106
  }
100
- const normalModuleReplacementPluginImpl = bundler === 'rspack'
101
- ? core_1.NormalModuleReplacementPlugin
102
- : require('webpack').NormalModuleReplacementPlugin;
103
107
  return {
104
108
  getAliases: () => pathMappings.reduce((aliases, library) => ({
105
109
  ...aliases,
@@ -161,7 +165,7 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
161
165
  }
162
166
  return libraries;
163
167
  },
164
- getReplacementPlugin: () => new normalModuleReplacementPluginImpl(/./, (req) => {
168
+ getReplacementPlugin: () => new (loadNormalModuleReplacementPlugin(bundler))(/./, (req) => {
165
169
  if (!req.request.startsWith('.')) {
166
170
  return;
167
171
  }
@@ -306,12 +310,9 @@ function addStringDependencyToSharedConfig(sharedConfig, dependency, projectGrap
306
310
  }
307
311
  }
308
312
  function getEmptySharedLibrariesConfig(bundler = 'rspack') {
309
- const normalModuleReplacementPluginImpl = bundler === 'rspack'
310
- ? core_1.NormalModuleReplacementPlugin
311
- : require('webpack').NormalModuleReplacementPlugin;
312
313
  return {
313
314
  getAliases: () => ({}),
314
315
  getLibraries: () => ({}),
315
- getReplacementPlugin: () => new normalModuleReplacementPluginImpl(/./, () => { }),
316
+ getReplacementPlugin: () => new (loadNormalModuleReplacementPlugin(bundler))(/./, () => { }),
316
317
  };
317
318
  }
@@ -4,11 +4,12 @@ exports.withModuleFederationForSSR = withModuleFederationForSSR;
4
4
  const utils_1 = require("../../utils");
5
5
  const utils_2 = require("./utils");
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
7
8
  async function withModuleFederationForSSR(options, configOverride) {
8
9
  if (global.NX_GRAPH_CREATION) {
9
10
  return (config) => config;
10
11
  }
11
- const isDevServer = process.env['WEBPACK_SERVE'];
12
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
12
13
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
13
14
  isServer: true,
14
15
  }, 'webpack');
@@ -5,6 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const utils_2 = require("./utils");
6
6
  const webpack_1 = require("@module-federation/enhanced/webpack");
7
7
  const devkit_1 = require("@nx/devkit");
8
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
8
9
  async function withModuleFederation(options, configOverride) {
9
10
  if (global.NX_GRAPH_CREATION) {
10
11
  return (config) => config;
@@ -13,7 +14,7 @@ async function withModuleFederation(options, configOverride) {
13
14
  process.env['FEDERATION_WEBPACK_PATH'] = require.resolve('webpack', {
14
15
  paths: [require.resolve('@angular-devkit/build-angular')],
15
16
  });
16
- const isDevServer = process.env['WEBPACK_SERVE'];
17
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
17
18
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
18
19
  return (config) => {
19
20
  const updatedConfig = {
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederationForSSR = withModuleFederationForSSR;
4
- const core_1 = require("@rspack/core");
5
4
  const utils_1 = require("../../utils");
6
5
  const utils_2 = require("./utils");
7
6
  const devkit_1 = require("@nx/devkit");
7
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
8
8
  async function withModuleFederationForSSR(options, configOverride) {
9
9
  if (global.NX_GRAPH_CREATION) {
10
10
  return (config) => config;
11
11
  }
12
- const isDevServer = process.env['WEBPACK_SERVE'];
12
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
13
13
  const { sharedLibraries, sharedDependencies, mappedRemotes } = (0, utils_2.getModuleFederationConfig)(options, {
14
14
  isServer: true,
15
15
  });
16
+ const { DefinePlugin } = require('@rspack/core');
16
17
  return (config, { context }) => {
17
18
  config.target = 'async-node';
18
19
  config.output.uniqueName = options.name;
@@ -66,7 +67,7 @@ async function withModuleFederationForSSR(options, configOverride) {
66
67
  }, {}), sharedLibraries.getReplacementPlugin());
67
68
  // The env var is only set from the module-federation-dev-server
68
69
  // Attach the runtime plugin
69
- config.plugins.push(new core_1.DefinePlugin({
70
+ config.plugins.push(new DefinePlugin({
70
71
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
71
72
  }));
72
73
  return config;
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederation = withModuleFederation;
4
4
  const rspack_1 = require("@module-federation/enhanced/rspack");
5
- const core_1 = require("@rspack/core");
6
5
  const utils_1 = require("../../utils");
7
6
  const utils_2 = require("./utils");
8
7
  const devkit_1 = require("@nx/devkit");
8
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
9
9
  const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
10
10
  /**
11
11
  * @param {ModuleFederationConfig} options
@@ -17,12 +17,15 @@ async function withModuleFederation(options, configOverride) {
17
17
  return config;
18
18
  };
19
19
  }
20
- const isDevServer = process.env['WEBPACK_SERVE'];
20
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
21
21
  const { sharedDependencies, sharedLibraries, mappedRemotes } = (0, utils_2.getModuleFederationConfig)(options);
22
22
  const isGlobal = isVarOrWindow(options.library?.type);
23
+ const { DefinePlugin } = require('@rspack/core');
23
24
  return function makeConfig(config, { context }) {
24
25
  config.output.uniqueName = options.name;
25
26
  config.output.publicPath = 'auto';
27
+ // rspack-cli dev mode defaults this on; it breaks module federation.
28
+ config.lazyCompilation ??= false;
26
29
  if (isGlobal) {
27
30
  config.output.scriptType = 'text/javascript';
28
31
  }
@@ -71,7 +74,7 @@ async function withModuleFederation(options, configOverride) {
71
74
  }), sharedLibraries.getReplacementPlugin());
72
75
  // The env var is only set from the module-federation-dev-server
73
76
  // Attach the runtime plugin
74
- config.plugins.push(new core_1.DefinePlugin({
77
+ config.plugins.push(new DefinePlugin({
75
78
  'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
76
79
  }));
77
80
  return config;
@@ -4,11 +4,12 @@ exports.withModuleFederationForSSR = withModuleFederationForSSR;
4
4
  const utils_1 = require("../../utils");
5
5
  const utils_2 = require("./utils");
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
7
8
  async function withModuleFederationForSSR(options, configOverride) {
8
9
  if (global.NX_GRAPH_CREATION) {
9
10
  return (config) => config;
10
11
  }
11
- const isDevServer = process.env['WEBPACK_SERVE'];
12
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
12
13
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
13
14
  isServer: true,
14
15
  }, 'webpack');
@@ -5,6 +5,7 @@ const utils_1 = require("../../utils");
5
5
  const utils_2 = require("./utils");
6
6
  const webpack_1 = require("@module-federation/enhanced/webpack");
7
7
  const devkit_1 = require("@nx/devkit");
8
+ const is_serve_mode_1 = require("../../utils/is-serve-mode");
8
9
  /**
9
10
  * @param {ModuleFederationConfig} options
10
11
  */
@@ -12,7 +13,7 @@ async function withModuleFederation(options, configOverride) {
12
13
  if (global.NX_GRAPH_CREATION) {
13
14
  return (config) => config;
14
15
  }
15
- const isDevServer = process.env['WEBPACK_SERVE'];
16
+ const isDevServer = (0, is_serve_mode_1.isServeMode)();
16
17
  const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
17
18
  return (config, ctx) => {
18
19
  config.output.uniqueName = options.name;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nx/module-federation",
3
3
  "description": "The Nx Plugin for Module Federation contains executors and utilities that support building applications using Module Federation.",
4
- "version": "23.0.0-rc.4",
4
+ "version": "23.1.0-beta.0",
5
5
  "type": "commonjs",
6
6
  "files": [
7
7
  "dist",
@@ -124,15 +124,15 @@
124
124
  },
125
125
  "executors": "./executors.json",
126
126
  "dependencies": {
127
- "@rspack/core": "1.6.8",
127
+ "@rspack/core": "^2.0.4",
128
128
  "express": "^4.21.2",
129
129
  "http-proxy-middleware": "^3.0.5",
130
130
  "picocolors": "^1.1.0",
131
131
  "tslib": "^2.3.0",
132
132
  "webpack": "5.105.2",
133
- "@nx/devkit": "23.0.0-rc.4",
134
- "@nx/js": "23.0.0-rc.4",
135
- "@nx/web": "23.0.0-rc.4"
133
+ "@nx/devkit": "23.1.0-beta.0",
134
+ "@nx/js": "23.1.0-beta.0",
135
+ "@nx/web": "23.1.0-beta.0"
136
136
  },
137
137
  "peerDependencies": {
138
138
  "@module-federation/enhanced": "^2.0.0",
@@ -147,7 +147,7 @@
147
147
  }
148
148
  },
149
149
  "devDependencies": {
150
- "nx": "23.0.0-rc.4"
150
+ "nx": "23.1.0-beta.0"
151
151
  },
152
152
  "nx-migrations": {
153
153
  "migrations": "./migrations.json",