@nx/module-federation 0.0.0-pr-32490-e4fdfa9 → 0.0.0-pr-32868-a65a4a2

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/README.md CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # Nx: Smart Repos · Fast Builds
24
24
 
25
- An AI-first build platform that connects everything from your editor to CI. Helping you deliver fast, without breaking things.
25
+ Get to green PRs in half the time. Nx optimizes your builds, scales your CI, and fixes failed PRs. Built for developers and AI agents.
26
26
 
27
27
  This package is a [Module Federation plugin for Nx](https://nx.dev/nx-api/module-federation).
28
28
  Module Federation allows developers to share code between deployed applications easier and makes team collaboration more efficient.
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": "0.0.0-pr-32490-e4fdfa9",
4
+ "version": "0.0.0-pr-32868-a65a4a2",
5
5
  "type": "commonjs",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,21 +24,21 @@
24
24
  "main": "index.js",
25
25
  "executors": "./executors.json",
26
26
  "dependencies": {
27
- "tslib": "^2.3.0",
28
- "@nx/devkit": "0.0.0-pr-32490-e4fdfa9",
29
- "@nx/js": "0.0.0-pr-32490-e4fdfa9",
30
- "@nx/web": "0.0.0-pr-32490-e4fdfa9",
31
- "picocolors": "^1.1.0",
32
- "webpack": "^5.101.3",
33
- "@rspack/core": "^1.3.8",
34
27
  "@module-federation/enhanced": "^0.18.0",
35
28
  "@module-federation/node": "^2.7.11",
36
29
  "@module-federation/sdk": "^0.18.0",
30
+ "@nx/devkit": "0.0.0-pr-32868-a65a4a2",
31
+ "@nx/js": "0.0.0-pr-32868-a65a4a2",
32
+ "@nx/web": "0.0.0-pr-32868-a65a4a2",
33
+ "@rspack/core": "^1.3.8",
37
34
  "express": "^4.21.2",
38
- "http-proxy-middleware": "^3.0.5"
35
+ "http-proxy-middleware": "^3.0.5",
36
+ "picocolors": "^1.1.0",
37
+ "tslib": "^2.3.0",
38
+ "webpack": "^5.101.3"
39
39
  },
40
40
  "devDependencies": {
41
- "nx": "0.0.0-pr-32490-e4fdfa9"
41
+ "nx": "0.0.0-pr-32868-a65a4a2"
42
42
  },
43
43
  "nx-migrations": {
44
44
  "migrations": "./migrations.json"
@@ -1 +1 @@
1
- {"version":3,"file":"get-remotes.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/plugins/utils/get-remotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAiB,MAAM,YAAY,CAAC;AACjE,OAAO,EAA6B,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIhF,wBAAgB,UAAU,CACxB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,YAAY,EAC1B,kBAAkB,CAAC,EAAE,MAAM;;;;EAkC5B"}
1
+ {"version":3,"file":"get-remotes.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/plugins/utils/get-remotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAiB,MAAM,YAAY,CAAC;AACjE,OAAO,EAA6B,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAIhF,wBAAgB,UAAU,CACxB,MAAM,EAAE,sBAAsB,EAC9B,YAAY,EAAE,YAAY,EAC1B,kBAAkB,CAAC,EAAE,MAAM;;;;EAoC5B"}
@@ -19,6 +19,7 @@ function getRemotes(config, projectGraph, pathToManifestFile) {
19
19
  return r;
20
20
  });
21
21
  const knownDynamicRemotes = normalizedDynamicRemotes.filter((r) => projectGraph.nodes[r]);
22
+ knownDynamicRemotes.forEach((r) => collectRemoteProjects(r, collectedRemotes, projectGraph));
22
23
  const remotePorts = [...collectedRemotes, ...knownDynamicRemotes].map((r) => projectGraph.nodes[r].data.targets['serve'].options.port);
23
24
  const staticRemotePort = Math.max(...[...remotePorts]) + 1;
24
25
  return {
@@ -33,12 +34,16 @@ function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
33
34
  if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
34
35
  const moduleFederationManifestJson = (0, fs_1.readFileSync)(pathToManifestFile, 'utf-8');
35
36
  if (moduleFederationManifestJson) {
36
- // This should have shape of
37
- // {
38
- // "remoteName": "remoteLocation",
39
- // }
37
+ /**
38
+ *
39
+ * This should have shape of
40
+ * {
41
+ * "remoteName": "remoteLocation",
42
+ * }
43
+ * But users might have their own, enforce only that the key is the remote name
44
+ */
40
45
  const parsedManifest = JSON.parse(moduleFederationManifestJson);
41
- if (Object.keys(parsedManifest).every((key) => typeof key === 'string' && typeof parsedManifest[key] === 'string')) {
46
+ if (Object.keys(parsedManifest).every((key) => typeof key === 'string')) {
42
47
  dynamicRemotes.push(...Object.keys(parsedManifest));
43
48
  }
44
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-remotes-for-host.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/get-remotes-for-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,UAAU,+BAA+B;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAqCD,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,YAAY,UA0B3B;AAoCD,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,+BAA+B,EACxC,kBAAkB,CAAC,EAAE,MAAM;;;;;;EAkF5B;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,OAAO,GAAG,SAAmB,OAkD1C"}
1
+ {"version":3,"file":"get-remotes-for-host.d.ts","sourceRoot":"","sources":["../../../../../packages/module-federation/src/utils/get-remotes-for-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAElD,UAAU,+BAA+B;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAoCD,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,oBAAoB,EACnC,YAAY,EAAE,YAAY,UA0B3B;AAoCD,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,+BAA+B,EACxC,kBAAkB,CAAC,EAAE,MAAM;;;;;;EAkF5B;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,OAAO,GAAG,SAAmB,OAkD1C"}
@@ -15,12 +15,16 @@ function extractRemoteProjectsFromConfig(config, pathToManifestFile) {
15
15
  if (pathToManifestFile && (0, fs_1.existsSync)(pathToManifestFile)) {
16
16
  const moduleFederationManifestJson = (0, fs_1.readFileSync)(pathToManifestFile, 'utf-8');
17
17
  if (moduleFederationManifestJson) {
18
- // This should have shape of
19
- // {
20
- // "remoteName": "remoteLocation",
21
- // }
18
+ /**
19
+ *
20
+ * This should have shape of
21
+ * {
22
+ * "remoteName": "remoteLocation",
23
+ * }
24
+ * But users might have their own, enforce only that the key is the remote name
25
+ */
22
26
  const parsedManifest = JSON.parse(moduleFederationManifestJson);
23
- if (Object.keys(parsedManifest).every((key) => typeof key === 'string' && typeof parsedManifest[key] === 'string')) {
27
+ if (Object.keys(parsedManifest).every((key) => typeof key === 'string')) {
24
28
  dynamicRemotes.push(...Object.keys(parsedManifest));
25
29
  }
26
30
  }
@@ -6,7 +6,7 @@ export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean, useR
6
6
  export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
7
7
  isServer: boolean;
8
8
  determineRemoteUrl?: (remote: string) => string;
9
- }): Promise<{
9
+ }, bundler?: 'rspack' | 'webpack'): Promise<{
10
10
  sharedLibraries: import("../../utils").SharedWorkspaceLibraryConfig;
11
11
  sharedDependencies: {
12
12
  [x: string]: SharedLibraryConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/angular/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,sBAAsB,EACtB,mBAAmB,EAGpB,MAAM,aAAa,CAAC;AASrB,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACjD,SAAS,UAAQ,QAwBlB;AAED,eAAO,MAAM,6BAA6B,UAKzC,CAAC;AACF,eAAO,MAAM,iCAAiC,UAI7C,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,QAAQ,GAAE,OAAe,EACzB,SAAS,UAAQ,IASA,QAAQ,MAAM,YAkChC;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B;;;;;;GA0ExB;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B,EACvB,SAAS,UAAQ;;;;;;EAwElB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/angular/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,sBAAsB,EACtB,mBAAmB,EAGpB,MAAM,aAAa,CAAC;AASrB,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACjD,SAAS,UAAQ,QAwBlB;AAED,eAAO,MAAM,6BAA6B,UAKzC,CAAC;AACF,eAAO,MAAM,iCAAiC,UAI7C,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,QAAQ,GAAE,OAAe,EACzB,SAAS,UAAQ,IASA,QAAQ,MAAM,YAkChC;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B,EACvB,OAAO,GAAE,QAAQ,GAAG,SAAoB;;;;;;GA4EzC;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B,EACvB,SAAS,UAAQ;;;;;;EAwElB"}
@@ -75,7 +75,7 @@ function getFunctionDeterminateRemoteUrl(isServer = false, useRspack = false) {
75
75
  return `${useRspack ? `${remote}@` : ''}${host.endsWith('/') ? host.slice(0, -1) : host}:${port}/${remoteEntry}`;
76
76
  };
77
77
  }
78
- async function getModuleFederationConfig(mfConfig, options = { isServer: false }) {
78
+ async function getModuleFederationConfig(mfConfig, options = { isServer: false }, bundler = 'rspack') {
79
79
  let projectGraph;
80
80
  try {
81
81
  projectGraph = (0, devkit_1.readCachedProjectGraph)();
@@ -91,7 +91,7 @@ async function getModuleFederationConfig(mfConfig, options = { isServer: false }
91
91
  dependencies.workspaceLibraries = dependencies.workspaceLibraries.filter((lib) => mfConfig.shared(lib.importKey, {}) !== false);
92
92
  dependencies.npmPackages = dependencies.npmPackages.filter((pkg) => mfConfig.shared(pkg, {}) !== false);
93
93
  }
94
- const sharedLibraries = (0, utils_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
94
+ const sharedLibraries = (0, utils_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries, undefined, bundler);
95
95
  const npmPackages = (0, utils_1.sharePackages)(Array.from(new Set([
96
96
  ...exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE,
97
97
  ...dependencies.npmPackages.filter((pkg) => !exports.DEFAULT_NPM_PACKAGES_TO_AVOID.includes(pkg)),
@@ -1 +1 @@
1
- {"version":3,"file":"with-module-federation-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/angular/with-module-federation-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACtC,MAAM,aAAa,CAAC;AAGrB,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,gCAAgC,iCAwFlD"}
1
+ {"version":3,"file":"with-module-federation-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/angular/with-module-federation-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,gCAAgC,EACtC,MAAM,aAAa,CAAC;AAGrB,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,gCAAgC,iCA4FlD"}
@@ -10,7 +10,7 @@ async function withModuleFederationForSSR(options, configOverride) {
10
10
  const isDevServer = process.env['WEBPACK_SERVE'];
11
11
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
12
12
  isServer: true,
13
- });
13
+ }, 'webpack');
14
14
  return (config) => {
15
15
  const updatedConfig = {
16
16
  ...(config ?? {}),
@@ -13,7 +13,7 @@ async function withModuleFederation(options, configOverride) {
13
13
  paths: [require.resolve('@angular-devkit/build-angular')],
14
14
  });
15
15
  const isDevServer = process.env['WEBPACK_SERVE'];
16
- const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options);
16
+ const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
17
17
  return (config) => {
18
18
  const updatedConfig = {
19
19
  ...(config ?? {}),
@@ -3,7 +3,7 @@ export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean): (re
3
3
  export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
4
4
  isServer: boolean;
5
5
  determineRemoteUrl?: (remote: string) => string;
6
- }): Promise<{
6
+ }, bundler?: 'rspack' | 'webpack'): Promise<{
7
7
  sharedLibraries: import("../../utils").SharedWorkspaceLibraryConfig;
8
8
  sharedDependencies: {
9
9
  [x: string]: import("../../utils").SharedLibraryConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/webpack/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,sBAAsB,EAGvB,MAAM,aAAa,CAAC;AAWrB,wBAAgB,+BAA+B,CAAC,QAAQ,GAAE,OAAe,IAItD,QAAQ,MAAM,YAkChC;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B;;;;;;GA4ExB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/webpack/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,sBAAsB,EAGvB,MAAM,aAAa,CAAC;AAWrB,wBAAgB,+BAA+B,CAAC,QAAQ,GAAE,OAAe,IAItD,QAAQ,MAAM,YAkChC;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,GAAE;IACP,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC3B,EACvB,OAAO,GAAE,QAAQ,GAAG,SAAoB;;;;;;GA8EzC"}
@@ -36,7 +36,7 @@ function getFunctionDeterminateRemoteUrl(isServer = false) {
36
36
  return `${host.endsWith('/') ? host.slice(0, -1) : host}:${port}/${remoteEntry}`;
37
37
  };
38
38
  }
39
- async function getModuleFederationConfig(mfConfig, options = { isServer: false }) {
39
+ async function getModuleFederationConfig(mfConfig, options = { isServer: false }, bundler = 'rspack') {
40
40
  let projectGraph;
41
41
  try {
42
42
  projectGraph = (0, devkit_1.readCachedProjectGraph)();
@@ -53,7 +53,7 @@ async function getModuleFederationConfig(mfConfig, options = { isServer: false }
53
53
  dependencies.workspaceLibraries = dependencies.workspaceLibraries.filter((lib) => mfConfig.shared(lib.importKey, {}) !== false);
54
54
  dependencies.npmPackages = dependencies.npmPackages.filter((pkg) => mfConfig.shared(pkg, {}) !== false);
55
55
  }
56
- const sharedLibraries = (0, utils_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
56
+ const sharedLibraries = (0, utils_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries, undefined, bundler);
57
57
  const npmPackages = (0, utils_1.sharePackages)(dependencies.npmPackages);
58
58
  const sharedDependencies = {
59
59
  ...sharedLibraries.getLibraries(project.root),
@@ -1 +1 @@
1
- {"version":3,"file":"with-module-federation-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/webpack/with-module-federation-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,gCAAgC,EACjC,MAAM,aAAa,CAAC;AAIrB,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,gCAAgC,iCA0ElD"}
1
+ {"version":3,"file":"with-module-federation-ssr.d.ts","sourceRoot":"","sources":["../../../../../../packages/module-federation/src/with-module-federation/webpack/with-module-federation-ssr.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,gCAAgC,EACjC,MAAM,aAAa,CAAC;AAIrB,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,sBAAsB,EAC/B,cAAc,CAAC,EAAE,gCAAgC,iCA8ElD"}
@@ -10,7 +10,7 @@ async function withModuleFederationForSSR(options, configOverride) {
10
10
  const isDevServer = process.env['WEBPACK_SERVE'];
11
11
  const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
12
12
  isServer: true,
13
- });
13
+ }, 'webpack');
14
14
  return (config) => {
15
15
  config.target = 'async-node';
16
16
  config.output.uniqueName = options.name;
@@ -12,7 +12,7 @@ async function withModuleFederation(options, configOverride) {
12
12
  return (config) => config;
13
13
  }
14
14
  const isDevServer = process.env['WEBPACK_SERVE'];
15
- const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options);
15
+ const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
16
16
  return (config, ctx) => {
17
17
  config.output.uniqueName = options.name;
18
18
  config.output.publicPath = 'auto';