@nx/module-federation 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.
- package/README.md +1 -3
- package/dist/angular.d.ts +1 -5
- package/dist/angular.js +7 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -2
- package/dist/rspack.d.ts +1 -5
- package/dist/rspack.js +7 -6
- package/dist/src/migrations/update-24-0-0/inventory.d.ts +11 -0
- package/dist/src/migrations/update-24-0-0/inventory.js +139 -0
- package/dist/src/migrations/update-24-0-0/migrate-angular-module-federation.d.ts +5 -0
- package/dist/src/migrations/update-24-0-0/migrate-angular-module-federation.js +18 -0
- package/dist/src/migrations/update-24-0-0/migrate-module-federation.d.ts +10 -0
- package/dist/src/migrations/update-24-0-0/migrate-module-federation.js +26 -0
- package/dist/src/migrations/update-24-0-0/migrate-module-federation.md +1931 -0
- package/dist/src/migrations/update-24-0-0/migrate-react-module-federation.d.ts +5 -0
- package/dist/src/migrations/update-24-0-0/migrate-react-module-federation.js +18 -0
- package/dist/src/stubs/models.d.ts +26 -0
- package/dist/src/stubs/stubs.d.ts +19 -0
- package/dist/src/stubs/stubs.js +43 -0
- package/dist/webpack.d.ts +1 -2
- package/dist/webpack.js +4 -3
- package/migrations.json +6 -0
- package/package.json +5 -60
- package/readme-template.md +1 -3
- package/dist/internal.d.ts +0 -2
- package/dist/internal.js +0 -13
- package/dist/src/executors/utils/build-static-remotes.d.ts +0 -4
- package/dist/src/executors/utils/build-static-remotes.js +0 -67
- package/dist/src/executors/utils/index.d.ts +0 -4
- package/dist/src/executors/utils/index.js +0 -6
- package/dist/src/executors/utils/models.d.ts +0 -30
- package/dist/src/executors/utils/start-remote-iterators.d.ts +0 -25
- package/dist/src/executors/utils/start-remote-iterators.js +0 -52
- package/dist/src/executors/utils/start-static-remotes-file-server.d.ts +0 -15
- package/dist/src/executors/utils/start-static-remotes-file-server.js +0 -61
- package/dist/src/plugins/models/index.d.ts +0 -14
- package/dist/src/plugins/models/index.js +0 -2
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.d.ts +0 -13
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-dev-server-plugin.js +0 -75
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.d.ts +0 -11
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-plugin.js +0 -93
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -15
- package/dist/src/plugins/nx-module-federation-plugin/angular/nx-module-federation-ssr-dev-server-plugin.js +0 -107
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.d.ts +0 -13
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-dev-server-plugin.js +0 -75
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.d.ts +0 -11
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-plugin.js +0 -80
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.d.ts +0 -15
- package/dist/src/plugins/nx-module-federation-plugin/rspack/nx-module-federation-ssr-dev-server-plugin.js +0 -107
- package/dist/src/plugins/utils/build-static-remotes.d.ts +0 -3
- package/dist/src/plugins/utils/build-static-remotes.js +0 -65
- package/dist/src/plugins/utils/get-dynamic-manifest-file.d.ts +0 -2
- package/dist/src/plugins/utils/get-dynamic-manifest-file.js +0 -18
- package/dist/src/plugins/utils/get-remotes.d.ts +0 -7
- package/dist/src/plugins/utils/get-remotes.js +0 -68
- package/dist/src/plugins/utils/get-static-remotes.d.ts +0 -3
- package/dist/src/plugins/utils/get-static-remotes.js +0 -27
- package/dist/src/plugins/utils/index.d.ts +0 -7
- package/dist/src/plugins/utils/index.js +0 -10
- package/dist/src/plugins/utils/parse-remotes-config.d.ts +0 -6
- package/dist/src/plugins/utils/parse-remotes-config.js +0 -35
- package/dist/src/plugins/utils/start-remote-proxies.d.ts +0 -5
- package/dist/src/plugins/utils/start-remote-proxies.js +0 -65
- package/dist/src/plugins/utils/start-static-remotes-file-server.d.ts +0 -2
- package/dist/src/plugins/utils/start-static-remotes-file-server.js +0 -46
- package/dist/src/utils/dependencies.d.ts +0 -6
- package/dist/src/utils/dependencies.js +0 -70
- package/dist/src/utils/framework-detection.d.ts +0 -2
- package/dist/src/utils/framework-detection.js +0 -20
- package/dist/src/utils/get-remotes-for-host.d.ts +0 -17
- package/dist/src/utils/get-remotes-for-host.js +0 -154
- package/dist/src/utils/index.d.ts +0 -11
- package/dist/src/utils/index.js +0 -14
- package/dist/src/utils/is-serve-mode.d.ts +0 -2
- package/dist/src/utils/is-serve-mode.js +0 -19
- package/dist/src/utils/models/index.d.ts +0 -47
- package/dist/src/utils/models/index.js +0 -2
- package/dist/src/utils/module-federation-config.d.ts +0 -57
- package/dist/src/utils/module-federation-config.js +0 -144
- package/dist/src/utils/normalize-project-name.d.ts +0 -1
- package/dist/src/utils/normalize-project-name.js +0 -10
- package/dist/src/utils/package-json.d.ts +0 -2
- package/dist/src/utils/package-json.js +0 -12
- package/dist/src/utils/parse-static-remotes-config.d.ts +0 -13
- package/dist/src/utils/parse-static-remotes-config.js +0 -62
- package/dist/src/utils/plugins/runtime-library-control.plugin.d.ts +0 -3
- package/dist/src/utils/plugins/runtime-library-control.plugin.js +0 -54
- package/dist/src/utils/port-utils.d.ts +0 -7
- package/dist/src/utils/port-utils.js +0 -22
- package/dist/src/utils/public-api.d.ts +0 -7
- package/dist/src/utils/public-api.js +0 -18
- package/dist/src/utils/remotes.d.ts +0 -19
- package/dist/src/utils/remotes.js +0 -75
- package/dist/src/utils/rspack-version.d.ts +0 -3
- package/dist/src/utils/rspack-version.js +0 -11
- package/dist/src/utils/secondary-entry-points.d.ts +0 -12
- package/dist/src/utils/secondary-entry-points.js +0 -125
- package/dist/src/utils/share.d.ts +0 -58
- package/dist/src/utils/share.js +0 -334
- package/dist/src/utils/start-remote-proxies.d.ts +0 -5
- package/dist/src/utils/start-remote-proxies.js +0 -55
- package/dist/src/utils/start-ssr-remote-proxies.d.ts +0 -5
- package/dist/src/utils/start-ssr-remote-proxies.js +0 -69
- package/dist/src/utils/typescript.d.ts +0 -4
- package/dist/src/utils/typescript.js +0 -53
- package/dist/src/utils/url-helpers.d.ts +0 -13
- package/dist/src/utils/url-helpers.js +0 -70
- package/dist/src/with-module-federation/angular/utils.d.ts +0 -28
- package/dist/src/with-module-federation/angular/utils.js +0 -83
- package/dist/src/with-module-federation/angular/with-module-federation-ssr.d.ts +0 -2
- package/dist/src/with-module-federation/angular/with-module-federation-ssr.js +0 -86
- package/dist/src/with-module-federation/angular/with-module-federation.d.ts +0 -2
- package/dist/src/with-module-federation/angular/with-module-federation.js +0 -85
- package/dist/src/with-module-federation/react/utils.d.ts +0 -2
- package/dist/src/with-module-federation/react/utils.js +0 -17
- package/dist/src/with-module-federation/rspack/utils.d.ts +0 -10
- package/dist/src/with-module-federation/rspack/utils.js +0 -32
- package/dist/src/with-module-federation/rspack/with-module-federation-ssr.d.ts +0 -4
- package/dist/src/with-module-federation/rspack/with-module-federation-ssr.js +0 -75
- package/dist/src/with-module-federation/rspack/with-module-federation.d.ts +0 -9
- package/dist/src/with-module-federation/rspack/with-module-federation.js +0 -82
- package/dist/src/with-module-federation/webpack/utils.d.ts +0 -10
- package/dist/src/with-module-federation/webpack/utils.js +0 -32
- package/dist/src/with-module-federation/webpack/with-module-federation-ssr.d.ts +0 -2
- package/dist/src/with-module-federation/webpack/with-module-federation-ssr.js +0 -69
- package/dist/src/with-module-federation/webpack/with-module-federation.d.ts +0 -5
- package/dist/src/with-module-federation/webpack/with-module-federation.js +0 -72
- package/dist/url-helpers.d.ts +0 -13
- package/dist/url-helpers.js +0 -78
- package/executors.json +0 -4
- /package/dist/src/{executors/utils → stubs}/models.js +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactModuleFederationSteps = reactModuleFederationSteps;
|
|
4
|
+
const inventory_1 = require("./inventory");
|
|
5
|
+
function reactModuleFederationSteps(inventory) {
|
|
6
|
+
const usages = inventory.react;
|
|
7
|
+
if (usages.length === 0)
|
|
8
|
+
return null;
|
|
9
|
+
return {
|
|
10
|
+
nextSteps: [
|
|
11
|
+
`Migrate ${usages.length} React project(s) off Nx Module Federation. See https://nx.dev/docs/kb/migrate-from-nx-module-federation`,
|
|
12
|
+
],
|
|
13
|
+
agentContext: [
|
|
14
|
+
'React projects that use Nx Module Federation, with the files that reference it:',
|
|
15
|
+
...usages.map(inventory_1.describeUsage),
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ModuleFederationLibrary = {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export type Remotes = Array<string | [remoteName: string, remoteUrl: string]>;
|
|
6
|
+
export interface SharedLibraryConfig {
|
|
7
|
+
singleton?: boolean;
|
|
8
|
+
strictVersion?: boolean;
|
|
9
|
+
requiredVersion?: false | string;
|
|
10
|
+
eager?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type SharedFunction = (libraryName: string, sharedConfig: SharedLibraryConfig) => undefined | false | SharedLibraryConfig;
|
|
13
|
+
export type AdditionalSharedConfig = Array<string | [libraryName: string, sharedConfig: SharedLibraryConfig] | {
|
|
14
|
+
libraryName: string;
|
|
15
|
+
sharedConfig: SharedLibraryConfig;
|
|
16
|
+
}>;
|
|
17
|
+
export interface ModuleFederationConfig {
|
|
18
|
+
name: string;
|
|
19
|
+
remotes?: Remotes;
|
|
20
|
+
library?: ModuleFederationLibrary;
|
|
21
|
+
exposes?: Record<string, string>;
|
|
22
|
+
shared?: SharedFunction;
|
|
23
|
+
additionalShared?: AdditionalSharedConfig;
|
|
24
|
+
disableNxRuntimeLibraryControlPlugin?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type NxModuleFederationConfigOverride = Record<string, unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type IdentityConfigFn = <T>(config: T, ...rest: unknown[]) => T;
|
|
2
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
3
|
+
export declare function withModuleFederation(..._args: unknown[]): Promise<IdentityConfigFn>;
|
|
4
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
5
|
+
export declare function withModuleFederationForSSR(..._args: unknown[]): Promise<IdentityConfigFn>;
|
|
6
|
+
declare class RemovedPlugin {
|
|
7
|
+
constructor(..._args: unknown[]);
|
|
8
|
+
apply(): void;
|
|
9
|
+
}
|
|
10
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
11
|
+
export declare class NxModuleFederationPlugin extends RemovedPlugin {
|
|
12
|
+
}
|
|
13
|
+
/** @deprecated Removed in Nx v24. Serve hosts and remotes with their own serve targets. This stub will be removed in Nx v25. */
|
|
14
|
+
export declare class NxModuleFederationDevServerPlugin extends RemovedPlugin {
|
|
15
|
+
}
|
|
16
|
+
/** @deprecated Removed in Nx v24. Serve hosts and remotes with their own serve targets. This stub will be removed in Nx v25. */
|
|
17
|
+
export declare class NxModuleFederationSSRDevServerPlugin extends RemovedPlugin {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxModuleFederationSSRDevServerPlugin = exports.NxModuleFederationDevServerPlugin = exports.NxModuleFederationPlugin = void 0;
|
|
4
|
+
exports.withModuleFederation = withModuleFederation;
|
|
5
|
+
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
// TODO(v25): Delete @nx/module-federation. It only ships so `nx migrate` can run its v24 migrations.
|
|
8
|
+
const REMOVED_MESSAGE = 'Nx Module Federation was removed in Nx v24. `@nx/module-federation` only exports stubs that keep old configs loadable; they do not configure Module Federation. Run `nx migrate` to get the Module Federation migration, or follow https://nx.dev/docs/kb/migrate-from-nx-module-federation (React) or https://nx.dev/docs/kb/migrate-angular-module-federation (Angular).';
|
|
9
|
+
let warned = false;
|
|
10
|
+
function warnRemoved() {
|
|
11
|
+
if (warned)
|
|
12
|
+
return;
|
|
13
|
+
warned = true;
|
|
14
|
+
devkit_1.logger.warn(REMOVED_MESSAGE);
|
|
15
|
+
}
|
|
16
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
17
|
+
async function withModuleFederation(..._args) {
|
|
18
|
+
warnRemoved();
|
|
19
|
+
return (config) => config;
|
|
20
|
+
}
|
|
21
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
22
|
+
async function withModuleFederationForSSR(..._args) {
|
|
23
|
+
warnRemoved();
|
|
24
|
+
return (config) => config;
|
|
25
|
+
}
|
|
26
|
+
class RemovedPlugin {
|
|
27
|
+
constructor(..._args) {
|
|
28
|
+
warnRemoved();
|
|
29
|
+
}
|
|
30
|
+
apply() { }
|
|
31
|
+
}
|
|
32
|
+
/** @deprecated Removed in Nx v24. Use `ModuleFederationPlugin` from `@module-federation/enhanced`. This stub will be removed in Nx v25. */
|
|
33
|
+
class NxModuleFederationPlugin extends RemovedPlugin {
|
|
34
|
+
}
|
|
35
|
+
exports.NxModuleFederationPlugin = NxModuleFederationPlugin;
|
|
36
|
+
/** @deprecated Removed in Nx v24. Serve hosts and remotes with their own serve targets. This stub will be removed in Nx v25. */
|
|
37
|
+
class NxModuleFederationDevServerPlugin extends RemovedPlugin {
|
|
38
|
+
}
|
|
39
|
+
exports.NxModuleFederationDevServerPlugin = NxModuleFederationDevServerPlugin;
|
|
40
|
+
/** @deprecated Removed in Nx v24. Serve hosts and remotes with their own serve targets. This stub will be removed in Nx v25. */
|
|
41
|
+
class NxModuleFederationSSRDevServerPlugin extends RemovedPlugin {
|
|
42
|
+
}
|
|
43
|
+
exports.NxModuleFederationSSRDevServerPlugin = NxModuleFederationSSRDevServerPlugin;
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './src/with-module-federation/webpack/with-module-federation-ssr';
|
|
1
|
+
export { withModuleFederation, withModuleFederationForSSR, } from './src/stubs/stubs';
|
package/dist/webpack.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.withModuleFederationForSSR = exports.withModuleFederation = void 0;
|
|
4
|
+
var stubs_1 = require("./src/stubs/stubs");
|
|
5
|
+
Object.defineProperty(exports, "withModuleFederation", { enumerable: true, get: function () { return stubs_1.withModuleFederation; } });
|
|
6
|
+
Object.defineProperty(exports, "withModuleFederationForSSR", { enumerable: true, get: function () { return stubs_1.withModuleFederationForSSR; } });
|
package/migrations.json
CHANGED
|
@@ -131,6 +131,12 @@
|
|
|
131
131
|
"version": "23.0.0-beta.25",
|
|
132
132
|
"description": "Rewrites `@nx/module-federation/src/*` subpath imports now that the `./src/*` subpath is no longer exposed by `@nx/module-federation`'s exports map. Named imports/exports of public symbols are routed to `@nx/module-federation` and the rest to the new `@nx/module-federation/internal` entry; `require`, dynamic `import` and `jest.mock` calls reference the whole module and are routed to `@nx/module-federation/internal`.",
|
|
133
133
|
"implementation": "./dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports"
|
|
134
|
+
},
|
|
135
|
+
"update-24-0-0-migrate-module-federation": {
|
|
136
|
+
"version": "24.0.0-beta.0",
|
|
137
|
+
"description": "Moves React and Angular apps off Nx Module Federation, removed in Nx v24, onto the official Module Federation plugins. Lists the projects that use it and hands them to an AI prompt; removes `@nx/module-federation` directly when nothing uses it.",
|
|
138
|
+
"implementation": "./dist/src/migrations/update-24-0-0/migrate-module-federation",
|
|
139
|
+
"prompt": "./dist/src/migrations/update-24-0-0/migrate-module-federation.md"
|
|
134
140
|
}
|
|
135
141
|
}
|
|
136
142
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/module-federation",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "24.0.0-beta.
|
|
3
|
+
"description": "Migrations that move workspaces off Nx Module Federation, which was removed in Nx v24.",
|
|
4
|
+
"version": "24.0.0-beta.3",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"!dist/tsconfig.tsbuildinfo",
|
|
9
|
-
"migrations.json"
|
|
10
|
-
"executors.json"
|
|
9
|
+
"migrations.json"
|
|
11
10
|
],
|
|
12
11
|
"repository": {
|
|
13
12
|
"type": "git",
|
|
@@ -40,9 +39,6 @@
|
|
|
40
39
|
"webpack": [
|
|
41
40
|
"dist/webpack.d.ts"
|
|
42
41
|
],
|
|
43
|
-
"url-helpers": [
|
|
44
|
-
"dist/url-helpers.d.ts"
|
|
45
|
-
],
|
|
46
42
|
"angular.js": [
|
|
47
43
|
"dist/angular.d.ts"
|
|
48
44
|
],
|
|
@@ -51,12 +47,6 @@
|
|
|
51
47
|
],
|
|
52
48
|
"webpack.js": [
|
|
53
49
|
"dist/webpack.d.ts"
|
|
54
|
-
],
|
|
55
|
-
"url-helpers.js": [
|
|
56
|
-
"dist/url-helpers.d.ts"
|
|
57
|
-
],
|
|
58
|
-
"internal": [
|
|
59
|
-
"dist/internal.d.ts"
|
|
60
50
|
]
|
|
61
51
|
}
|
|
62
52
|
},
|
|
@@ -68,9 +58,7 @@
|
|
|
68
58
|
},
|
|
69
59
|
"./package.json": "./package.json",
|
|
70
60
|
"./package": "./package.json",
|
|
71
|
-
"./executors.json": "./executors.json",
|
|
72
61
|
"./migrations.json": "./migrations.json",
|
|
73
|
-
"./executors": "./executors.json",
|
|
74
62
|
"./migrations": "./migrations.json",
|
|
75
63
|
"./angular": {
|
|
76
64
|
"@nx/nx-source": "./angular.ts",
|
|
@@ -101,57 +89,14 @@
|
|
|
101
89
|
"@nx/nx-source": "./webpack.ts",
|
|
102
90
|
"types": "./dist/webpack.d.ts",
|
|
103
91
|
"default": "./dist/webpack.js"
|
|
104
|
-
},
|
|
105
|
-
"./url-helpers": {
|
|
106
|
-
"@nx/nx-source": "./url-helpers.ts",
|
|
107
|
-
"types": "./dist/url-helpers.d.ts",
|
|
108
|
-
"default": "./dist/url-helpers.js"
|
|
109
|
-
},
|
|
110
|
-
"./url-helpers.js": {
|
|
111
|
-
"@nx/nx-source": "./url-helpers.ts",
|
|
112
|
-
"types": "./dist/url-helpers.d.ts",
|
|
113
|
-
"default": "./dist/url-helpers.js"
|
|
114
|
-
},
|
|
115
|
-
"./internal": {
|
|
116
|
-
"@nx/nx-source": "./internal.ts",
|
|
117
|
-
"types": "./dist/internal.d.ts",
|
|
118
|
-
"default": "./dist/internal.js"
|
|
119
|
-
},
|
|
120
|
-
"./runtime-library-control-plugin": {
|
|
121
|
-
"@nx/nx-source": "./src/utils/plugins/runtime-library-control.plugin.ts",
|
|
122
|
-
"default": "./dist/src/utils/plugins/runtime-library-control.plugin.js"
|
|
123
92
|
}
|
|
124
93
|
},
|
|
125
|
-
"executors": "./executors.json",
|
|
126
94
|
"dependencies": {
|
|
127
|
-
"@nx/devkit": "24.0.0-beta.
|
|
128
|
-
"@nx/js": "24.0.0-beta.1",
|
|
129
|
-
"@nx/web": "24.0.0-beta.1",
|
|
130
|
-
"@rspack/core": "^2.0.4",
|
|
131
|
-
"express": "^4.21.2",
|
|
132
|
-
"http-proxy-middleware": "^3.0.7",
|
|
133
|
-
"picocolors": "^1.1.0",
|
|
95
|
+
"@nx/devkit": "24.0.0-beta.3",
|
|
134
96
|
"tslib": "^2.3.0"
|
|
135
97
|
},
|
|
136
|
-
"peerDependencies": {
|
|
137
|
-
"@module-federation/enhanced": "^2.0.0",
|
|
138
|
-
"@module-federation/node": "^2.0.0",
|
|
139
|
-
"webpack": "^5.0.0"
|
|
140
|
-
},
|
|
141
|
-
"peerDependenciesMeta": {
|
|
142
|
-
"@module-federation/enhanced": {
|
|
143
|
-
"optional": true
|
|
144
|
-
},
|
|
145
|
-
"@module-federation/node": {
|
|
146
|
-
"optional": true
|
|
147
|
-
},
|
|
148
|
-
"webpack": {
|
|
149
|
-
"optional": true
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
98
|
"devDependencies": {
|
|
153
|
-
"nx": "24.0.0-beta.
|
|
154
|
-
"webpack": "5.109.2"
|
|
99
|
+
"nx": "24.0.0-beta.3"
|
|
155
100
|
},
|
|
156
101
|
"nx-migrations": {
|
|
157
102
|
"migrations": "./migrations.json",
|
package/readme-template.md
CHANGED
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
|
|
14
14
|
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.
|
|
15
15
|
|
|
16
|
-
This package
|
|
17
|
-
Module Federation allows developers to share code between deployed applications easier and makes team collaboration more efficient.
|
|
18
|
-
To learn more about Module Federation, check out the [official documentation](https://module-federation.io/).
|
|
16
|
+
Nx Module Federation was removed in Nx v24. This package only ships the migrations that move a workspace to the official [Module Federation](https://module-federation.io/) plugins. See the [React](https://nx.dev/docs/kb/migrate-from-nx-module-federation) and [Angular](https://nx.dev/docs/kb/migrate-angular-module-federation) migration guides.
|
|
19
17
|
|
|
20
18
|
{{content}}
|
package/dist/internal.d.ts
DELETED
package/dist/internal.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseStaticRemotesConfig = exports.getRemotes = exports.getModuleFederationConfig = exports.startRemoteIterators = exports.buildStaticRemotes = void 0;
|
|
4
|
-
// Curated internal API surface for other first-party Nx plugins (e.g. @nx/react,
|
|
5
|
-
// @nx/angular, @nx/rspack). Prefer this over deep `@nx/module-federation/src/*`
|
|
6
|
-
// imports — those are not part of the public API.
|
|
7
|
-
var utils_1 = require("./src/executors/utils");
|
|
8
|
-
Object.defineProperty(exports, "buildStaticRemotes", { enumerable: true, get: function () { return utils_1.buildStaticRemotes; } });
|
|
9
|
-
Object.defineProperty(exports, "startRemoteIterators", { enumerable: true, get: function () { return utils_1.startRemoteIterators; } });
|
|
10
|
-
var utils_2 = require("./src/utils");
|
|
11
|
-
Object.defineProperty(exports, "getModuleFederationConfig", { enumerable: true, get: function () { return utils_2.getModuleFederationConfig; } });
|
|
12
|
-
Object.defineProperty(exports, "getRemotes", { enumerable: true, get: function () { return utils_2.getRemotes; } });
|
|
13
|
-
Object.defineProperty(exports, "parseStaticRemotesConfig", { enumerable: true, get: function () { return utils_2.parseStaticRemotesConfig; } });
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type StaticRemotesConfig } from '../../utils';
|
|
3
|
-
import { type BuildStaticRemotesOptions } from './models';
|
|
4
|
-
export declare function buildStaticRemotes(staticRemotesConfig: StaticRemotesConfig, nxBin: any, context: ExecutorContext, options: BuildStaticRemotesOptions, buildTarget?: 'build' | 'server'): Promise<Record<string, string>>;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildStaticRemotes = buildStaticRemotes;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const node_child_process_1 = require("node:child_process");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
9
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
10
|
-
async function buildStaticRemotes(staticRemotesConfig, nxBin, context, options, buildTarget = 'build') {
|
|
11
|
-
if (!staticRemotesConfig.remotes.length) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
devkit_1.logger.info(`NX Building ${staticRemotesConfig.remotes.length} static remotes...`);
|
|
15
|
-
const mappedLocationOfRemotes = {};
|
|
16
|
-
for (const app of staticRemotesConfig.remotes) {
|
|
17
|
-
mappedLocationOfRemotes[app] = `http${options.ssl ? 's' : ''}://${options.host}:${options.staticRemotesPort}/${staticRemotesConfig.config[app].urlSegment}`;
|
|
18
|
-
}
|
|
19
|
-
await new Promise((res, rej) => {
|
|
20
|
-
const staticProcess = (0, node_child_process_1.fork)(nxBin, [
|
|
21
|
-
'run-many',
|
|
22
|
-
`--target=${buildTarget}`,
|
|
23
|
-
`--projects=${staticRemotesConfig.remotes.join(',')}`,
|
|
24
|
-
...(context.configurationName
|
|
25
|
-
? [`--configuration=${context.configurationName}`]
|
|
26
|
-
: []),
|
|
27
|
-
...(options.parallel ? [`--parallel=${options.parallel}`] : []),
|
|
28
|
-
], {
|
|
29
|
-
cwd: context.root,
|
|
30
|
-
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
31
|
-
env: (0, is_serve_mode_1.childBuildEnv)(),
|
|
32
|
-
});
|
|
33
|
-
// File to debug build failures e.g. 2024-01-01T00_00_0_0Z-build.log'
|
|
34
|
-
const remoteBuildLogFile = (0, path_1.join)(internal_1.workspaceDataDirectory, `${new Date().toISOString().replace(/[:\.]/g, '_')}-build.log`);
|
|
35
|
-
const stdoutStream = (0, fs_1.createWriteStream)(remoteBuildLogFile);
|
|
36
|
-
staticProcess.stdout.on('data', (data) => {
|
|
37
|
-
const ANSII_CODE_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
|
38
|
-
const stdoutString = data.toString().replace(ANSII_CODE_REGEX, '');
|
|
39
|
-
stdoutStream.write(stdoutString);
|
|
40
|
-
// in addition to writing into the stdout stream, also show error directly in console
|
|
41
|
-
// so the error is easily discoverable. 'ERROR in' is the key word to search in webpack output.
|
|
42
|
-
if (stdoutString.includes('ERROR in')) {
|
|
43
|
-
devkit_1.logger.log(stdoutString);
|
|
44
|
-
}
|
|
45
|
-
if (stdoutString.includes(`Successfully ran target ${buildTarget}`)) {
|
|
46
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
47
|
-
devkit_1.logger.info(`NX Built ${staticRemotesConfig.remotes.length} static remotes`);
|
|
48
|
-
res();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
staticProcess.stderr.on('data', (data) => devkit_1.logger.info(data.toString()));
|
|
52
|
-
staticProcess.once('exit', (code) => {
|
|
53
|
-
stdoutStream.end();
|
|
54
|
-
staticProcess.stdout.removeAllListeners('data');
|
|
55
|
-
staticProcess.stderr.removeAllListeners('data');
|
|
56
|
-
if (code !== 0) {
|
|
57
|
-
rej(`Remote failed to start. A complete log can be found in: ${remoteBuildLogFile}`);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
res();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
process.on('SIGTERM', () => staticProcess.kill('SIGTERM'));
|
|
64
|
-
process.on('exit', () => staticProcess.kill('SIGTERM'));
|
|
65
|
-
});
|
|
66
|
-
return mappedLocationOfRemotes;
|
|
67
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./start-static-remotes-file-server"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./build-static-remotes"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./start-remote-iterators"), exports);
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ProjectConfiguration, ExecutorContext } from '@nx/devkit';
|
|
2
|
-
export type DevRemoteDefinition = string | {
|
|
3
|
-
remoteName: string;
|
|
4
|
-
configuration: string;
|
|
5
|
-
};
|
|
6
|
-
export type StartRemoteFn = (remotes: string[], workspaceProjects: Record<string, ProjectConfiguration>, options: {
|
|
7
|
-
devRemotes: DevRemoteDefinition[];
|
|
8
|
-
verbose: boolean;
|
|
9
|
-
}, context: ExecutorContext, target: 'serve' | 'serve-static') => Promise<AsyncIterable<{
|
|
10
|
-
success: boolean;
|
|
11
|
-
}>[]>;
|
|
12
|
-
export interface StaticRemotesOptions {
|
|
13
|
-
staticRemotesPort?: number;
|
|
14
|
-
host?: string;
|
|
15
|
-
ssl?: boolean;
|
|
16
|
-
sslCert?: string;
|
|
17
|
-
sslKey?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface BuildStaticRemotesOptions extends StaticRemotesOptions {
|
|
20
|
-
parallel?: number;
|
|
21
|
-
}
|
|
22
|
-
export interface StartRemoteIteratorsOptions extends BuildStaticRemotesOptions {
|
|
23
|
-
devRemotes: DevRemoteDefinition[];
|
|
24
|
-
skipRemotes?: string[];
|
|
25
|
-
buildTarget?: string;
|
|
26
|
-
liveReload?: boolean;
|
|
27
|
-
open?: boolean;
|
|
28
|
-
ssl?: boolean;
|
|
29
|
-
verbose: boolean;
|
|
30
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { StartRemoteFn, type StartRemoteIteratorsOptions } from './models';
|
|
2
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
3
|
-
export declare function startRemoteIterators(options: StartRemoteIteratorsOptions, context: ExecutorContext, startRemoteFn: StartRemoteFn, pathToManifestFile: string | undefined, pluginName?: 'react' | 'angular', isServer?: boolean): Promise<{
|
|
4
|
-
remotes: {
|
|
5
|
-
staticRemotes: string[];
|
|
6
|
-
devRemotes: any[];
|
|
7
|
-
dynamicRemotes: any[];
|
|
8
|
-
remotePorts: number[];
|
|
9
|
-
staticRemotePort: number;
|
|
10
|
-
};
|
|
11
|
-
devRemoteIters: AsyncIterable<{
|
|
12
|
-
success: boolean;
|
|
13
|
-
}>[];
|
|
14
|
-
staticRemotesIter: AsyncGenerator<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
baseUrl: string;
|
|
17
|
-
}, {
|
|
18
|
-
success: boolean;
|
|
19
|
-
}, unknown> | AsyncGenerator<{
|
|
20
|
-
success: boolean;
|
|
21
|
-
baseUrl: string;
|
|
22
|
-
} | {
|
|
23
|
-
success: boolean;
|
|
24
|
-
}, void, unknown>;
|
|
25
|
-
}>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startRemoteIterators = startRemoteIterators;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const build_static_remotes_1 = require("./build-static-remotes");
|
|
6
|
-
const start_static_remotes_file_server_1 = require("./start-static-remotes-file-server");
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
async function startRemoteIterators(options, context, startRemoteFn, pathToManifestFile, pluginName = 'react', isServer = false) {
|
|
9
|
-
const nxBin = require.resolve('nx/bin/nx');
|
|
10
|
-
const { projects: workspaceProjects } = (0, devkit_1.readProjectsConfigurationFromProjectGraph)(context.projectGraph);
|
|
11
|
-
const project = workspaceProjects[context.projectName];
|
|
12
|
-
const buildTargetName = (0, utils_1.getBuildTargetNameFromMFDevServer)(project, context.projectGraph);
|
|
13
|
-
const moduleFederationConfig = (0, utils_1.getModuleFederationConfig)(project.targets?.[buildTargetName]?.options?.tsConfig, context.root, project.root, pluginName);
|
|
14
|
-
const remoteNames = options.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName);
|
|
15
|
-
const remotes = (0, utils_1.getRemotes)(remoteNames, options.skipRemotes, moduleFederationConfig, {
|
|
16
|
-
projectName: project.name,
|
|
17
|
-
projectGraph: context.projectGraph,
|
|
18
|
-
root: context.root,
|
|
19
|
-
}, pathToManifestFile);
|
|
20
|
-
options.staticRemotesPort ??= remotes.staticRemotePort;
|
|
21
|
-
// Set NX_MF_DEV_REMOTES for the Nx Runtime Library Control Plugin
|
|
22
|
-
process.env.NX_MF_DEV_REMOTES = JSON.stringify([
|
|
23
|
-
...(remotes.devRemotes.map((r) => typeof r === 'string' ? r : r.remoteName) ?? []).map((r) => (0, utils_1.normalizeProjectName)(r)),
|
|
24
|
-
(0, utils_1.normalizeProjectName)(project.name),
|
|
25
|
-
]);
|
|
26
|
-
const staticRemotesConfig = isServer
|
|
27
|
-
? (0, utils_1.parseStaticSsrRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context)
|
|
28
|
-
: (0, utils_1.parseStaticRemotesConfig)([...remotes.staticRemotes, ...remotes.dynamicRemotes], context);
|
|
29
|
-
const mappedLocationsOfStaticRemotes = await (0, build_static_remotes_1.buildStaticRemotes)(staticRemotesConfig, nxBin, context, options, isServer ? 'server' : 'build');
|
|
30
|
-
const devRemoteIters = await startRemoteFn(remotes.devRemotes, workspaceProjects, options, context, 'serve');
|
|
31
|
-
const staticRemotesIter = isServer
|
|
32
|
-
? (0, start_static_remotes_file_server_1.startSsrStaticRemotesFileServer)(staticRemotesConfig, context, options)
|
|
33
|
-
: (0, start_static_remotes_file_server_1.startStaticRemotesFileServer)(staticRemotesConfig, context, options);
|
|
34
|
-
isServer
|
|
35
|
-
? await (0, utils_1.startSsrRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
36
|
-
? {
|
|
37
|
-
pathToCert: options.sslCert,
|
|
38
|
-
pathToKey: options.sslKey,
|
|
39
|
-
}
|
|
40
|
-
: undefined, options.host)
|
|
41
|
-
: await (0, utils_1.startRemoteProxies)(staticRemotesConfig, mappedLocationsOfStaticRemotes, options.ssl
|
|
42
|
-
? {
|
|
43
|
-
pathToCert: options.sslCert,
|
|
44
|
-
pathToKey: options.sslKey,
|
|
45
|
-
}
|
|
46
|
-
: undefined, options.host);
|
|
47
|
-
return {
|
|
48
|
-
remotes,
|
|
49
|
-
devRemoteIters,
|
|
50
|
-
staticRemotesIter,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { type StaticRemotesOptions } from './models';
|
|
3
|
-
import type { StaticRemotesConfig } from '../../utils';
|
|
4
|
-
export declare function startStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: StaticRemotesOptions, forceMoveToCommonLocation?: boolean): AsyncGenerator<{
|
|
5
|
-
success: boolean;
|
|
6
|
-
baseUrl: string;
|
|
7
|
-
}, {
|
|
8
|
-
success: boolean;
|
|
9
|
-
}, unknown>;
|
|
10
|
-
export declare function startSsrStaticRemotesFileServer(staticRemotesConfig: StaticRemotesConfig, context: ExecutorContext, options: StaticRemotesOptions): AsyncGenerator<{
|
|
11
|
-
success: boolean;
|
|
12
|
-
baseUrl: string;
|
|
13
|
-
} | {
|
|
14
|
-
success: boolean;
|
|
15
|
-
}, void, unknown>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startStaticRemotesFileServer = startStaticRemotesFileServer;
|
|
4
|
-
exports.startSsrStaticRemotesFileServer = startSsrStaticRemotesFileServer;
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const internal_1 = require("@nx/web/internal");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
function startStaticRemotesFileServer(staticRemotesConfig, context, options, forceMoveToCommonLocation = false) {
|
|
10
|
-
if (!staticRemotesConfig.remotes ||
|
|
11
|
-
staticRemotesConfig.remotes.length === 0) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
let shouldMoveToCommonLocation = forceMoveToCommonLocation || false;
|
|
15
|
-
let commonOutputDirectory;
|
|
16
|
-
if (!forceMoveToCommonLocation) {
|
|
17
|
-
for (const app of staticRemotesConfig.remotes) {
|
|
18
|
-
const remoteBasePath = staticRemotesConfig.config[app].basePath;
|
|
19
|
-
if (!commonOutputDirectory) {
|
|
20
|
-
commonOutputDirectory = remoteBasePath;
|
|
21
|
-
}
|
|
22
|
-
else if (commonOutputDirectory !== remoteBasePath) {
|
|
23
|
-
shouldMoveToCommonLocation = true;
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (shouldMoveToCommonLocation) {
|
|
29
|
-
commonOutputDirectory = (0, path_1.join)(devkit_1.workspaceRoot, 'tmp/static-remotes');
|
|
30
|
-
for (const app of staticRemotesConfig.remotes) {
|
|
31
|
-
const remoteConfig = staticRemotesConfig.config[app];
|
|
32
|
-
(0, fs_1.cpSync)(remoteConfig.outputPath, (0, path_1.join)(commonOutputDirectory, remoteConfig.urlSegment), {
|
|
33
|
-
force: true,
|
|
34
|
-
recursive: true,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const staticRemotesIter = (0, internal_1.fileServerExecutor)({
|
|
39
|
-
cors: true,
|
|
40
|
-
watch: false,
|
|
41
|
-
staticFilePath: commonOutputDirectory,
|
|
42
|
-
parallel: false,
|
|
43
|
-
spa: false,
|
|
44
|
-
withDeps: false,
|
|
45
|
-
host: options.host,
|
|
46
|
-
port: options.staticRemotesPort,
|
|
47
|
-
ssl: options.ssl,
|
|
48
|
-
sslCert: options.sslCert,
|
|
49
|
-
sslKey: options.sslKey,
|
|
50
|
-
cacheSeconds: -1,
|
|
51
|
-
}, context);
|
|
52
|
-
return staticRemotesIter;
|
|
53
|
-
}
|
|
54
|
-
async function* startSsrStaticRemotesFileServer(staticRemotesConfig, context, options) {
|
|
55
|
-
const staticRemotesIter = startStaticRemotesFileServer(staticRemotesConfig, context, options, true);
|
|
56
|
-
if (!staticRemotesIter) {
|
|
57
|
-
yield { success: true };
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
yield* staticRemotesIter;
|
|
61
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface NxModuleFederationDevServerConfig {
|
|
2
|
-
host?: string;
|
|
3
|
-
staticRemotesPort?: number;
|
|
4
|
-
pathToManifestFile?: string;
|
|
5
|
-
ssl?: boolean;
|
|
6
|
-
sslCert?: string;
|
|
7
|
-
sslKey?: string;
|
|
8
|
-
parallel?: number;
|
|
9
|
-
devRemoteFindOptions?: DevRemoteFindOptions;
|
|
10
|
-
}
|
|
11
|
-
export interface DevRemoteFindOptions {
|
|
12
|
-
retries?: number;
|
|
13
|
-
retryDelay?: number;
|
|
14
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
-
import { ModuleFederationConfig } from '../../../utils/models';
|
|
3
|
-
import { NxModuleFederationDevServerConfig } from '../../models';
|
|
4
|
-
export declare class NxModuleFederationDevServerPlugin implements RspackPluginInstance {
|
|
5
|
-
private _options;
|
|
6
|
-
private nxBin;
|
|
7
|
-
constructor(_options: {
|
|
8
|
-
config: ModuleFederationConfig;
|
|
9
|
-
devServerConfig?: NxModuleFederationDevServerConfig;
|
|
10
|
-
});
|
|
11
|
-
apply(compiler: Compiler): void;
|
|
12
|
-
private setup;
|
|
13
|
-
}
|