@nx/react 0.0.0-pr-22870-d31b9b7 → 0.0.0-pr-26816-51699f9

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.
package/migrations.json CHANGED
@@ -202,6 +202,15 @@
202
202
  "alwaysAddToPackageJson": false
203
203
  }
204
204
  }
205
+ },
206
+ "19.4.0-module-federation": {
207
+ "version": "19.4.0-rc.2",
208
+ "packages": {
209
+ "@module-federation/node": {
210
+ "version": "^2.3.0",
211
+ "alwaysAddToPackageJson": false
212
+ }
213
+ }
205
214
  }
206
215
  }
207
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-22870-d31b9b7",
3
+ "version": "0.0.0-pr-26816-51699f9",
4
4
  "private": false,
5
5
  "description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -38,11 +38,12 @@
38
38
  "file-loader": "^6.2.0",
39
39
  "minimatch": "9.0.3",
40
40
  "tslib": "^2.3.0",
41
- "@nx/devkit": "0.0.0-pr-22870-d31b9b7",
42
- "@nx/js": "0.0.0-pr-22870-d31b9b7",
43
- "@nx/eslint": "0.0.0-pr-22870-d31b9b7",
44
- "@nx/web": "0.0.0-pr-22870-d31b9b7",
45
- "@nrwl/react": "0.0.0-pr-22870-d31b9b7"
41
+ "@module-federation/enhanced": "~0.2.3",
42
+ "@nx/devkit": "0.0.0-pr-26816-51699f9",
43
+ "@nx/js": "0.0.0-pr-26816-51699f9",
44
+ "@nx/eslint": "0.0.0-pr-26816-51699f9",
45
+ "@nx/web": "0.0.0-pr-26816-51699f9",
46
+ "@nrwl/react": "0.0.0-pr-26816-51699f9"
46
47
  },
47
48
  "publishConfig": {
48
49
  "access": "public"
@@ -188,6 +188,8 @@ async function* moduleFederationDevServer(options, context) {
188
188
  projectGraph: context.projectGraph,
189
189
  root: context.root,
190
190
  }, pathToManifestFile);
191
+ // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
192
+ process.env.NX_MF_DEV_REMOTES = JSON.stringify(remotes.devRemotes.map((r) => (typeof r === 'string' ? r : r.remoteName)));
191
193
  if (remotes.devRemotes.length > 0 && !initialStaticRemotesPorts) {
192
194
  options.staticRemotesPort = options.devRemotes.reduce((portToUse, r) => {
193
195
  const remoteName = typeof r === 'string' ? r : r.remoteName;
@@ -65,6 +65,8 @@ async function* moduleFederationSsrDevServer(options, context) {
65
65
  : Array.isArray(options.devRemotes)
66
66
  ? options.devRemotes
67
67
  : [options.devRemotes];
68
+ // Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
69
+ process.env.NX_MF_DEV_REMOTES = JSON.stringify(devServeApps);
68
70
  for (const app of knownRemotes) {
69
71
  const [appName] = Array.isArray(app) ? app : [app];
70
72
  const isDev = devServeApps.includes(appName);
@@ -13,6 +13,7 @@ const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
13
13
  const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
14
14
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
15
  const js_1 = require("@nx/js");
16
+ const versions_1 = require("../../utils/versions");
16
17
  async function hostGenerator(host, schema) {
17
18
  return hostGeneratorInternal(host, {
18
19
  projectNameAndRootFormat: 'derived',
@@ -97,6 +98,8 @@ async function hostGeneratorInternal(host, schema) {
97
98
  host.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.lint.json'));
98
99
  }
99
100
  (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
101
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion });
102
+ tasks.push(installTask);
100
103
  if (!options.skipFormat) {
101
104
  await (0, devkit_1.formatFiles)(host);
102
105
  }
@@ -90,7 +90,7 @@
90
90
  "x-priority": "internal"
91
91
  },
92
92
  "skipNxJson": {
93
- "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
93
+ "description": "Skip updating nx.json with default options based on values provided to this app (e.g. babel, style).",
94
94
  "type": "boolean",
95
95
  "default": false,
96
96
  "x-priority": "internal"
@@ -14,6 +14,7 @@ const add_remote_to_dynamic_host_1 = require("./lib/add-remote-to-dynamic-host")
14
14
  const add_mf_env_to_inputs_1 = require("../../utils/add-mf-env-to-inputs");
15
15
  const maybe_js_1 = require("../../utils/maybe-js");
16
16
  const js_1 = require("@nx/js");
17
+ const versions_1 = require("../../utils/versions");
17
18
  function addModuleFederationFiles(host, options) {
18
19
  const templateVariables = {
19
20
  ...(0, devkit_1.names)(options.name),
@@ -104,6 +105,8 @@ async function remoteGeneratorInternal(host, schema) {
104
105
  (0, add_remote_to_dynamic_host_1.addRemoteToDynamicHost)(host, options.name, options.devServerPort, pathToMFManifest);
105
106
  }
106
107
  (0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
108
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion });
109
+ tasks.push(installTask);
107
110
  if (!options.skipFormat) {
108
111
  await (0, devkit_1.formatFiles)(host);
109
112
  }
@@ -96,7 +96,7 @@
96
96
  "x-priority": "internal"
97
97
  },
98
98
  "skipNxJson": {
99
- "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
99
+ "description": "Skip updating nx.json with default options based on values provided to this app (e.g. babel, style).",
100
100
  "type": "boolean",
101
101
  "default": false,
102
102
  "x-priority": "internal"
@@ -1,2 +1,2 @@
1
- import { ModuleFederationConfig } from '@nx/webpack/src/utils/module-federation';
2
- export declare function withModuleFederationForSSR(options: ModuleFederationConfig): Promise<(config: any) => any>;
1
+ import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '@nx/webpack/src/utils/module-federation';
2
+ export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any) => any>;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederationForSSR = void 0;
4
4
  const utils_1 = require("./utils");
5
- async function withModuleFederationForSSR(options) {
5
+ async function withModuleFederationForSSR(options, configOverride) {
6
6
  if (global.NX_GRAPH_CREATION) {
7
7
  return (config) => config;
8
8
  }
9
+ options.useNxLibraryControlPlugin ??= true;
9
10
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
10
11
  isServer: true,
11
12
  });
@@ -27,7 +28,24 @@ async function withModuleFederationForSSR(options) {
27
28
  type: 'commonjs-module',
28
29
  },
29
30
  isServer: true,
31
+ /**
32
+ * Apply user-defined config overrides
33
+ */
34
+ ...(configOverride ? configOverride : {}),
35
+ runtimePlugins: process.env.NX_MF_DEV_REMOTES && options.useNxLibraryControlPlugin
36
+ ? [
37
+ ...(configOverride?.runtimePlugins ?? []),
38
+ require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
39
+ ]
40
+ : configOverride?.runtimePlugins,
30
41
  }, {}), sharedLibraries.getReplacementPlugin());
42
+ if (process.env.NX_MF_DEV_REMOTES && options.useNxLibraryControlPlugin) {
43
+ // The env var is only set from the module-federation-dev-server
44
+ // Attach the runtime plugin
45
+ config.plugins.push(new (require('webpack').DefinePlugin)({
46
+ 'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
47
+ }));
48
+ }
31
49
  return config;
32
50
  };
33
51
  }
@@ -1,7 +1,7 @@
1
- import { ModuleFederationConfig } from '@nx/webpack/src/utils/module-federation';
1
+ import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '@nx/webpack/src/utils/module-federation';
2
2
  import type { AsyncNxComposableWebpackPlugin } from '@nx/webpack';
3
3
  /**
4
4
  * @param {ModuleFederationConfig} options
5
5
  * @return {Promise<AsyncNxComposableWebpackPlugin>}
6
6
  */
7
- export declare function withModuleFederation(options: ModuleFederationConfig): Promise<AsyncNxComposableWebpackPlugin>;
7
+ export declare function withModuleFederation(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<AsyncNxComposableWebpackPlugin>;
@@ -2,16 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withModuleFederation = void 0;
4
4
  const utils_1 = require("./utils");
5
- const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
5
+ const webpack_1 = require("@module-federation/enhanced/webpack");
6
6
  const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
7
7
  /**
8
8
  * @param {ModuleFederationConfig} options
9
9
  * @return {Promise<AsyncNxComposableWebpackPlugin>}
10
10
  */
11
- async function withModuleFederation(options) {
11
+ async function withModuleFederation(options, configOverride) {
12
12
  if (global.NX_GRAPH_CREATION) {
13
13
  return (config) => config;
14
14
  }
15
+ options.useNxLibraryControlPlugin ??= true;
15
16
  const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
16
17
  const isGlobal = isVarOrWindow(options.library?.type);
17
18
  return (config, ctx) => {
@@ -32,7 +33,7 @@ async function withModuleFederation(options) {
32
33
  ...config.experiments,
33
34
  outputModule: !isGlobal,
34
35
  };
35
- config.plugins.push(new ModuleFederationPlugin({
36
+ config.plugins.push(new webpack_1.ModuleFederationPlugin({
36
37
  name: options.name,
37
38
  library: options.library ?? { type: 'module' },
38
39
  filename: 'remoteEntry.js',
@@ -48,7 +49,24 @@ async function withModuleFederation(options) {
48
49
  * { appY: 'appY@http://localhost:3002/remoteEntry.js' }
49
50
  */
50
51
  ...(isGlobal ? { remoteType: 'script' } : {}),
52
+ /**
53
+ * Apply user-defined config overrides
54
+ */
55
+ ...(configOverride ? configOverride : {}),
56
+ runtimePlugins: process.env.NX_MF_DEV_REMOTES && options.useNxLibraryControlPlugin
57
+ ? [
58
+ ...(configOverride?.runtimePlugins ?? []),
59
+ require.resolve('@nx/webpack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
60
+ ]
61
+ : configOverride?.runtimePlugins,
51
62
  }), sharedLibraries.getReplacementPlugin());
63
+ if (process.env.NX_MF_DEV_REMOTES && options.useNxLibraryControlPlugin) {
64
+ // The env var is only set from the module-federation-dev-server
65
+ // Attach the runtime plugin
66
+ config.plugins.push(new (require('webpack').DefinePlugin)({
67
+ 'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
68
+ }));
69
+ }
52
70
  return config;
53
71
  };
54
72
  }
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  function addMfEnvToTargetDefaultInputs(tree) {
6
6
  const nxJson = (0, devkit_1.readNxJson)(tree);
7
7
  const webpackExecutor = '@nx/webpack:webpack';
8
- const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
8
+ const mfEnvVar = 'NX_MF_DEV_REMOTES';
9
9
  nxJson.targetDefaults ??= {};
10
10
  nxJson.targetDefaults[webpackExecutor] ??= {};
11
11
  nxJson.targetDefaults[webpackExecutor].inputs ??= [
@@ -36,7 +36,8 @@ export declare const typesExpressVersion = "4.17.17";
36
36
  export declare const isbotVersion = "^3.6.5";
37
37
  export declare const corsVersion = "~2.8.5";
38
38
  export declare const typesCorsVersion = "~2.8.12";
39
- export declare const moduleFederationNodeVersion = "~0.9.9";
39
+ export declare const moduleFederationNodeVersion = "^2.3.0";
40
+ export declare const moduleFederationEnhancedVersion = "~0.2.3";
40
41
  export declare const lessVersion = "3.12.2";
41
42
  export declare const sassVersion = "^1.55.0";
42
43
  export declare const rollupPluginUrlVersion = "^8.0.2";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactTestRendererVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxRspackVersion = exports.nxVersion = void 0;
3
+ exports.swcPluginStyledComponentsVersion = exports.swcPluginEmotionVersion = exports.swcPluginStyledJsxVersion = exports.svgrRollupVersion = exports.rollupPluginUrlVersion = exports.sassVersion = exports.lessVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.typesCorsVersion = exports.corsVersion = exports.isbotVersion = exports.typesExpressVersion = exports.expressVersion = exports.autoprefixerVersion = exports.tailwindcssVersion = exports.postcssVersion = exports.tsLibVersion = exports.babelPluginStyledComponentsVersion = exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.reactTestRendererVersion = exports.reactReduxVersion = exports.reduxjsToolkitVersion = exports.testingLibraryReactVersion = exports.reactRouterDomVersion = exports.styledJsxVersion = exports.emotionBabelPlugin = exports.emotionReactVersion = exports.emotionStyledVersion = exports.typesStyledComponentsVersion = exports.styledComponentsVersion = exports.babelCoreVersion = exports.babelPresetReactVersion = exports.typesNodeVersion = exports.typesReactIsVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.babelLoaderVersion = exports.swcLoaderVersion = exports.reactIsVersion = exports.reactDomVersion = exports.reactVersion = exports.nxRspackVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  // Always pull the latest version until we merge rspack plugin into the repo.
6
6
  exports.nxRspackVersion = '*';
@@ -42,7 +42,8 @@ exports.typesExpressVersion = '4.17.17';
42
42
  exports.isbotVersion = '^3.6.5';
43
43
  exports.corsVersion = '~2.8.5';
44
44
  exports.typesCorsVersion = '~2.8.12';
45
- exports.moduleFederationNodeVersion = '~0.9.9';
45
+ exports.moduleFederationNodeVersion = '^2.3.0';
46
+ exports.moduleFederationEnhancedVersion = '~0.2.3';
46
47
  // style preprocessors
47
48
  exports.lessVersion = '3.12.2';
48
49
  exports.sassVersion = '^1.55.0';