@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
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_NPM_PACKAGES_TO_AVOID = exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE = void 0;
|
|
4
|
-
exports.applyDefaultEagerPackages = applyDefaultEagerPackages;
|
|
5
|
-
exports.getFunctionDeterminateRemoteUrl = getFunctionDeterminateRemoteUrl;
|
|
6
|
-
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
7
|
-
exports.getModuleFederationConfigSync = getModuleFederationConfigSync;
|
|
8
|
-
const module_federation_config_1 = require("../../utils/module-federation-config");
|
|
9
|
-
/**
|
|
10
|
-
* Default npm packages to share for Angular projects, each shared only when the
|
|
11
|
-
* workspace declares it in the root package.json.
|
|
12
|
-
*/
|
|
13
|
-
exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE = [
|
|
14
|
-
'@angular/core',
|
|
15
|
-
'@angular/animations',
|
|
16
|
-
'@angular/common',
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
|
-
* npm packages to avoid sharing in Angular projects.
|
|
20
|
-
*/
|
|
21
|
-
exports.DEFAULT_NPM_PACKAGES_TO_AVOID = [
|
|
22
|
-
'zone.js',
|
|
23
|
-
'@nx/angular/mf',
|
|
24
|
-
'@nrwl/angular/mf',
|
|
25
|
-
'@nx/angular-rspack',
|
|
26
|
-
];
|
|
27
|
-
/**
|
|
28
|
-
* Applies eager loading to default Angular packages.
|
|
29
|
-
* Exported for backward compatibility.
|
|
30
|
-
*/
|
|
31
|
-
function applyDefaultEagerPackages(sharedConfig, useRspack = false) {
|
|
32
|
-
const DEFAULT_PACKAGES_TO_LOAD_EAGERLY = [
|
|
33
|
-
'@angular/localize',
|
|
34
|
-
'@angular/localize/init',
|
|
35
|
-
...(useRspack
|
|
36
|
-
? [
|
|
37
|
-
'@angular/core',
|
|
38
|
-
'@angular/core/primitives/signals',
|
|
39
|
-
'@angular/core/primitives/di',
|
|
40
|
-
'@angular/core/event-dispatch',
|
|
41
|
-
'@angular/core/rxjs-interop',
|
|
42
|
-
'@angular/common',
|
|
43
|
-
'@angular/common/http',
|
|
44
|
-
'@angular/platform-browser',
|
|
45
|
-
]
|
|
46
|
-
: []),
|
|
47
|
-
];
|
|
48
|
-
for (const pkg of DEFAULT_PACKAGES_TO_LOAD_EAGERLY) {
|
|
49
|
-
if (!sharedConfig[pkg]) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
sharedConfig[pkg] = { ...sharedConfig[pkg], eager: true };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Creates the default remote URL resolver for Angular.
|
|
57
|
-
* Kept for backward compatibility with existing configs.
|
|
58
|
-
*/
|
|
59
|
-
function getFunctionDeterminateRemoteUrl(isServer = false, useRspack = false) {
|
|
60
|
-
return (0, module_federation_config_1.createDefaultRemoteUrlResolver)(isServer, useRspack ? 'js' : 'mjs');
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Creates framework config for Angular projects.
|
|
64
|
-
*/
|
|
65
|
-
function getAngularFrameworkConfig(bundler, useRspack) {
|
|
66
|
-
return {
|
|
67
|
-
bundler,
|
|
68
|
-
remoteEntryExt: useRspack ? 'js' : 'mjs',
|
|
69
|
-
mapRemotesExpose: false,
|
|
70
|
-
defaultPackagesToShare: exports.DEFAULT_ANGULAR_PACKAGES_TO_SHARE,
|
|
71
|
-
packagesToAvoid: exports.DEFAULT_NPM_PACKAGES_TO_AVOID,
|
|
72
|
-
applyEagerPackages: (sharedConfig) => {
|
|
73
|
-
applyDefaultEagerPackages(sharedConfig, useRspack);
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
async function getModuleFederationConfig(mfConfig, options = { isServer: false }, bundler = 'rspack') {
|
|
78
|
-
// Angular async uses 'mjs' extension (webpack), not rspack
|
|
79
|
-
return (0, module_federation_config_1.getModuleFederationConfigAsync)(mfConfig, options, getAngularFrameworkConfig(bundler, false));
|
|
80
|
-
}
|
|
81
|
-
function getModuleFederationConfigSync(mfConfig, options = { isServer: false }, useRspack = false) {
|
|
82
|
-
return (0, module_federation_config_1.getModuleFederationConfigSync)(mfConfig, options, getAngularFrameworkConfig('rspack', useRspack));
|
|
83
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const utils_2 = require("./utils");
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
8
|
-
async function withModuleFederationForSSR(options, configOverride) {
|
|
9
|
-
if (global.NX_GRAPH_CREATION) {
|
|
10
|
-
return (config) => config;
|
|
11
|
-
}
|
|
12
|
-
const isDevServer = (0, is_serve_mode_1.isServeMode)();
|
|
13
|
-
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
|
|
14
|
-
isServer: true,
|
|
15
|
-
}, 'webpack');
|
|
16
|
-
return (config) => {
|
|
17
|
-
const updatedConfig = {
|
|
18
|
-
...(config ?? {}),
|
|
19
|
-
target: 'async-node',
|
|
20
|
-
output: {
|
|
21
|
-
...(config.output ?? {}),
|
|
22
|
-
uniqueName: options.name,
|
|
23
|
-
},
|
|
24
|
-
optimization: {
|
|
25
|
-
...(config.optimization ?? {}),
|
|
26
|
-
runtimeChunk: isDevServer
|
|
27
|
-
? (config.optimization?.runtimeChunk ?? undefined)
|
|
28
|
-
: false,
|
|
29
|
-
},
|
|
30
|
-
resolve: {
|
|
31
|
-
...(config.resolve ?? {}),
|
|
32
|
-
modules: [
|
|
33
|
-
...(config.resolve?.modules ?? ['node_modules']),
|
|
34
|
-
devkit_1.workspaceRoot,
|
|
35
|
-
],
|
|
36
|
-
alias: {
|
|
37
|
-
...(config.resolve?.alias ?? {}),
|
|
38
|
-
...sharedLibraries.getAliases(),
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
plugins: [
|
|
42
|
-
...(config.plugins ?? []),
|
|
43
|
-
new (require('@module-federation/enhanced').ModuleFederationPlugin)({
|
|
44
|
-
name: (0, utils_1.normalizeProjectName)(options.name),
|
|
45
|
-
filename: 'remoteEntry.js',
|
|
46
|
-
exposes: options.exposes,
|
|
47
|
-
remotes: mappedRemotes,
|
|
48
|
-
shared: {
|
|
49
|
-
...sharedDependencies,
|
|
50
|
-
},
|
|
51
|
-
remoteType: 'script',
|
|
52
|
-
library: {
|
|
53
|
-
type: 'commonjs-module',
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Apply user-defined config override
|
|
57
|
-
*/
|
|
58
|
-
...(configOverride ? configOverride : {}),
|
|
59
|
-
experiments: {
|
|
60
|
-
asyncStartup: true,
|
|
61
|
-
// We should allow users to override experiments
|
|
62
|
-
...(configOverride?.experiments ?? {}),
|
|
63
|
-
},
|
|
64
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
65
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
66
|
-
? [
|
|
67
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
68
|
-
require.resolve('@module-federation/node/runtimePlugin'),
|
|
69
|
-
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
70
|
-
]
|
|
71
|
-
: [
|
|
72
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
73
|
-
require.resolve('@module-federation/node/runtimePlugin'),
|
|
74
|
-
],
|
|
75
|
-
}, {}),
|
|
76
|
-
sharedLibraries.getReplacementPlugin(),
|
|
77
|
-
],
|
|
78
|
-
};
|
|
79
|
-
// The env var is only set from the module-federation-dev-server
|
|
80
|
-
// Attach the runtime plugin
|
|
81
|
-
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
|
82
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
83
|
-
}));
|
|
84
|
-
return updatedConfig;
|
|
85
|
-
};
|
|
86
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederation = withModuleFederation;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const utils_2 = require("./utils");
|
|
6
|
-
const webpack_1 = require("@module-federation/enhanced/webpack");
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
9
|
-
async function withModuleFederation(options, configOverride) {
|
|
10
|
-
if (global.NX_GRAPH_CREATION) {
|
|
11
|
-
return (config) => config;
|
|
12
|
-
}
|
|
13
|
-
// This is required to ensure that the webpack version used by the Angular CLI is used
|
|
14
|
-
process.env['FEDERATION_WEBPACK_PATH'] = require.resolve('webpack', {
|
|
15
|
-
paths: [require.resolve('@angular-devkit/build-angular')],
|
|
16
|
-
});
|
|
17
|
-
const isDevServer = (0, is_serve_mode_1.isServeMode)();
|
|
18
|
-
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, undefined, 'webpack');
|
|
19
|
-
return (config) => {
|
|
20
|
-
const updatedConfig = {
|
|
21
|
-
...(config ?? {}),
|
|
22
|
-
output: {
|
|
23
|
-
...(config.output ?? {}),
|
|
24
|
-
uniqueName: options.name,
|
|
25
|
-
publicPath: 'auto',
|
|
26
|
-
},
|
|
27
|
-
optimization: {
|
|
28
|
-
...(config.optimization ?? {}),
|
|
29
|
-
runtimeChunk: isDevServer && !options.exposes
|
|
30
|
-
? (config.optimization?.runtimeChunk ?? undefined)
|
|
31
|
-
: false,
|
|
32
|
-
},
|
|
33
|
-
resolve: {
|
|
34
|
-
...(config.resolve ?? {}),
|
|
35
|
-
// Ensure workspace root is in resolve.modules so that expose paths
|
|
36
|
-
// like "apps/remote/src/..." resolve correctly without baseUrl.
|
|
37
|
-
modules: [
|
|
38
|
-
...(config.resolve?.modules ?? ['node_modules']),
|
|
39
|
-
devkit_1.workspaceRoot,
|
|
40
|
-
],
|
|
41
|
-
alias: {
|
|
42
|
-
...(config.resolve?.alias ?? {}),
|
|
43
|
-
...sharedLibraries.getAliases(),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
experiments: {
|
|
47
|
-
...(config.experiments ?? {}),
|
|
48
|
-
outputModule: true,
|
|
49
|
-
},
|
|
50
|
-
plugins: [
|
|
51
|
-
...(config.plugins ?? []),
|
|
52
|
-
new webpack_1.ModuleFederationPlugin({
|
|
53
|
-
name: (0, utils_1.normalizeProjectName)(options.name),
|
|
54
|
-
filename: 'remoteEntry.mjs',
|
|
55
|
-
exposes: options.exposes,
|
|
56
|
-
remotes: mappedRemotes,
|
|
57
|
-
shared: {
|
|
58
|
-
...sharedDependencies,
|
|
59
|
-
},
|
|
60
|
-
library: {
|
|
61
|
-
type: 'module',
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
* Apply user-defined config override
|
|
65
|
-
*/
|
|
66
|
-
...(configOverride ? configOverride : {}),
|
|
67
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
68
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
69
|
-
? [
|
|
70
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
71
|
-
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
72
|
-
]
|
|
73
|
-
: configOverride?.runtimePlugins,
|
|
74
|
-
}),
|
|
75
|
-
sharedLibraries.getReplacementPlugin(),
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
// The env var is only set from the module-federation-dev-server
|
|
79
|
-
// Attach the runtime plugin
|
|
80
|
-
updatedConfig.plugins.push(new (require('webpack').DefinePlugin)({
|
|
81
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
82
|
-
}));
|
|
83
|
-
return updatedConfig;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyDefaultEagerPackages = applyDefaultEagerPackages;
|
|
4
|
-
function applyDefaultEagerPackages(sharedConfig) {
|
|
5
|
-
const DEFAULT_REACT_PACKAGES_TO_LOAD_EAGERLY = [
|
|
6
|
-
'react',
|
|
7
|
-
'react-dom',
|
|
8
|
-
'react-router-dom',
|
|
9
|
-
'react-router',
|
|
10
|
-
];
|
|
11
|
-
for (const pkg of DEFAULT_REACT_PACKAGES_TO_LOAD_EAGERLY) {
|
|
12
|
-
if (!sharedConfig[pkg]) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
sharedConfig[pkg] = { ...sharedConfig[pkg], eager: true };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ModuleFederationConfig } from '../../utils';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the default remote URL resolver for rspack.
|
|
4
|
-
* Kept for backward compatibility with existing configs.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean): (remote: string) => string;
|
|
7
|
-
export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
|
|
8
|
-
isServer: boolean;
|
|
9
|
-
determineRemoteUrl?: (remote: string) => string;
|
|
10
|
-
}): import("../../utils/module-federation-config").ModuleFederationConfigResult;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFunctionDeterminateRemoteUrl = getFunctionDeterminateRemoteUrl;
|
|
4
|
-
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
5
|
-
const module_federation_config_1 = require("../../utils/module-federation-config");
|
|
6
|
-
const utils_1 = require("../react/utils");
|
|
7
|
-
const framework_detection_1 = require("../../utils/framework-detection");
|
|
8
|
-
/**
|
|
9
|
-
* Creates the default remote URL resolver for rspack.
|
|
10
|
-
* Kept for backward compatibility with existing configs.
|
|
11
|
-
*/
|
|
12
|
-
function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
13
|
-
return (0, module_federation_config_1.createDefaultRemoteUrlResolver)(isServer, 'js');
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Framework config for rspack projects (React).
|
|
17
|
-
*/
|
|
18
|
-
function getRspackFrameworkConfig() {
|
|
19
|
-
return {
|
|
20
|
-
bundler: 'rspack',
|
|
21
|
-
remoteEntryExt: 'js',
|
|
22
|
-
mapRemotesExpose: true,
|
|
23
|
-
applyEagerPackages: (sharedConfig, projectGraph, projectName) => {
|
|
24
|
-
if ((0, framework_detection_1.isReactProject)(projectName, projectGraph)) {
|
|
25
|
-
(0, utils_1.applyDefaultEagerPackages)(sharedConfig);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function getModuleFederationConfig(mfConfig, options = { isServer: false }) {
|
|
31
|
-
return (0, module_federation_config_1.getModuleFederationConfigSync)(mfConfig, options, getRspackFrameworkConfig());
|
|
32
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../utils';
|
|
2
|
-
export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any, { context }: {
|
|
3
|
-
context: any;
|
|
4
|
-
}) => any>;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const utils_2 = require("./utils");
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
8
|
-
async function withModuleFederationForSSR(options, configOverride) {
|
|
9
|
-
if (global.NX_GRAPH_CREATION) {
|
|
10
|
-
return (config) => config;
|
|
11
|
-
}
|
|
12
|
-
const isDevServer = (0, is_serve_mode_1.isServeMode)();
|
|
13
|
-
const { sharedLibraries, sharedDependencies, mappedRemotes } = (0, utils_2.getModuleFederationConfig)(options, {
|
|
14
|
-
isServer: true,
|
|
15
|
-
});
|
|
16
|
-
const { DefinePlugin } = require('@rspack/core');
|
|
17
|
-
return (config, { context }) => {
|
|
18
|
-
config.target = 'async-node';
|
|
19
|
-
config.output.uniqueName = options.name;
|
|
20
|
-
config.output.library = {
|
|
21
|
-
type: 'commonjs-module',
|
|
22
|
-
};
|
|
23
|
-
config.resolve ??= {};
|
|
24
|
-
config.resolve.modules = [
|
|
25
|
-
...(config.resolve.modules ?? ['node_modules']),
|
|
26
|
-
devkit_1.workspaceRoot,
|
|
27
|
-
];
|
|
28
|
-
config.optimization = {
|
|
29
|
-
...(config.optimization ?? {}),
|
|
30
|
-
runtimeChunk: isDevServer
|
|
31
|
-
? (config.optimization?.runtimeChunk ?? undefined)
|
|
32
|
-
: false,
|
|
33
|
-
};
|
|
34
|
-
config.plugins.push(new (require('@module-federation/enhanced/rspack').ModuleFederationPlugin)({
|
|
35
|
-
name: (0, utils_1.normalizeProjectName)(options.name),
|
|
36
|
-
filename: 'remoteEntry.js',
|
|
37
|
-
exposes: options.exposes,
|
|
38
|
-
remotes: mappedRemotes,
|
|
39
|
-
shared: {
|
|
40
|
-
...sharedDependencies,
|
|
41
|
-
},
|
|
42
|
-
isServer: true,
|
|
43
|
-
library: {
|
|
44
|
-
type: 'commonjs-module',
|
|
45
|
-
},
|
|
46
|
-
remoteType: 'script',
|
|
47
|
-
/**
|
|
48
|
-
* Apply user-defined config overrides
|
|
49
|
-
*/
|
|
50
|
-
...(configOverride ? configOverride : {}),
|
|
51
|
-
experiments: {
|
|
52
|
-
asyncStartup: true,
|
|
53
|
-
// We should allow users to override experiments
|
|
54
|
-
...(configOverride?.experiments ?? {}),
|
|
55
|
-
},
|
|
56
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
57
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
58
|
-
? [
|
|
59
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
60
|
-
require.resolve('@module-federation/node/runtimePlugin'),
|
|
61
|
-
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
62
|
-
]
|
|
63
|
-
: [
|
|
64
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
65
|
-
require.resolve('@module-federation/node/runtimePlugin'),
|
|
66
|
-
],
|
|
67
|
-
}, {}), sharedLibraries.getReplacementPlugin());
|
|
68
|
-
// The env var is only set from the module-federation-dev-server
|
|
69
|
-
// Attach the runtime plugin
|
|
70
|
-
config.plugins.push(new DefinePlugin({
|
|
71
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
72
|
-
}));
|
|
73
|
-
return config;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Configuration } from '@rspack/core';
|
|
2
|
-
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../utils';
|
|
3
|
-
/**
|
|
4
|
-
* @param {ModuleFederationConfig} options
|
|
5
|
-
* @param {NxModuleFederationConfigOverride} configOverride
|
|
6
|
-
*/
|
|
7
|
-
export declare function withModuleFederation(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: Configuration, { context }: {
|
|
8
|
-
context: any;
|
|
9
|
-
}) => Configuration>;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederation = withModuleFederation;
|
|
4
|
-
const rspack_1 = require("@module-federation/enhanced/rspack");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
const utils_2 = require("./utils");
|
|
7
|
-
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
9
|
-
const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
|
|
10
|
-
/**
|
|
11
|
-
* @param {ModuleFederationConfig} options
|
|
12
|
-
* @param {NxModuleFederationConfigOverride} configOverride
|
|
13
|
-
*/
|
|
14
|
-
async function withModuleFederation(options, configOverride) {
|
|
15
|
-
if (global.NX_GRAPH_CREATION) {
|
|
16
|
-
return function makeConfig(config) {
|
|
17
|
-
return config;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const isDevServer = (0, is_serve_mode_1.isServeMode)();
|
|
21
|
-
const { sharedDependencies, sharedLibraries, mappedRemotes } = (0, utils_2.getModuleFederationConfig)(options);
|
|
22
|
-
const isGlobal = isVarOrWindow(options.library?.type);
|
|
23
|
-
const { DefinePlugin } = require('@rspack/core');
|
|
24
|
-
return function makeConfig(config, { context }) {
|
|
25
|
-
config.output.uniqueName = options.name;
|
|
26
|
-
config.output.publicPath = 'auto';
|
|
27
|
-
// rspack-cli dev mode defaults this on; it breaks module federation.
|
|
28
|
-
config.lazyCompilation ??= false;
|
|
29
|
-
if (isGlobal) {
|
|
30
|
-
config.output.scriptType = 'text/javascript';
|
|
31
|
-
}
|
|
32
|
-
config.resolve ??= {};
|
|
33
|
-
config.resolve.modules = [
|
|
34
|
-
...(config.resolve.modules ?? ['node_modules']),
|
|
35
|
-
devkit_1.workspaceRoot,
|
|
36
|
-
];
|
|
37
|
-
config.optimization = {
|
|
38
|
-
...(config.optimization ?? {}),
|
|
39
|
-
runtimeChunk: isDevServer && !options.exposes
|
|
40
|
-
? (config.optimization?.runtimeChunk ?? undefined)
|
|
41
|
-
: false,
|
|
42
|
-
};
|
|
43
|
-
if (config.mode === 'development' &&
|
|
44
|
-
Object.keys(mappedRemotes).length > 1 &&
|
|
45
|
-
!options.exposes) {
|
|
46
|
-
config.optimization.runtimeChunk = 'single';
|
|
47
|
-
}
|
|
48
|
-
config.plugins.push(new rspack_1.ModuleFederationPlugin({
|
|
49
|
-
name: (0, utils_1.normalizeProjectName)(options.name),
|
|
50
|
-
filename: 'remoteEntry.js',
|
|
51
|
-
exposes: options.exposes,
|
|
52
|
-
remotes: mappedRemotes,
|
|
53
|
-
shared: {
|
|
54
|
-
...sharedDependencies,
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* remoteType: 'script' is required for the remote to be loaded as a script tag.
|
|
58
|
-
* remotes will need to be defined as:
|
|
59
|
-
* { appX: 'appX@http://localhost:3001/remoteEntry.js' }
|
|
60
|
-
* { appY: 'appY@http://localhost:3002/remoteEntry.js' }
|
|
61
|
-
*/
|
|
62
|
-
...(isGlobal ? { remoteType: 'script' } : {}),
|
|
63
|
-
/**
|
|
64
|
-
* Apply user-defined config overrides
|
|
65
|
-
*/
|
|
66
|
-
...(configOverride ? configOverride : {}),
|
|
67
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
68
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
69
|
-
? [
|
|
70
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
71
|
-
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
72
|
-
]
|
|
73
|
-
: configOverride?.runtimePlugins,
|
|
74
|
-
}), sharedLibraries.getReplacementPlugin());
|
|
75
|
-
// The env var is only set from the module-federation-dev-server
|
|
76
|
-
// Attach the runtime plugin
|
|
77
|
-
config.plugins.push(new DefinePlugin({
|
|
78
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
79
|
-
}));
|
|
80
|
-
return config;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ModuleFederationConfig } from '../../utils';
|
|
2
|
-
/**
|
|
3
|
-
* Creates the default remote URL resolver for webpack.
|
|
4
|
-
* Kept for backward compatibility with existing configs.
|
|
5
|
-
*/
|
|
6
|
-
export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean): (remote: string) => string;
|
|
7
|
-
export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
|
|
8
|
-
isServer: boolean;
|
|
9
|
-
determineRemoteUrl?: (remote: string) => string;
|
|
10
|
-
}, bundler?: 'rspack' | 'webpack'): Promise<import("../../utils/module-federation-config").ModuleFederationConfigResult>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFunctionDeterminateRemoteUrl = getFunctionDeterminateRemoteUrl;
|
|
4
|
-
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
5
|
-
const module_federation_config_1 = require("../../utils/module-federation-config");
|
|
6
|
-
const utils_1 = require("../react/utils");
|
|
7
|
-
const framework_detection_1 = require("../../utils/framework-detection");
|
|
8
|
-
/**
|
|
9
|
-
* Creates the default remote URL resolver for webpack.
|
|
10
|
-
* Kept for backward compatibility with existing configs.
|
|
11
|
-
*/
|
|
12
|
-
function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
13
|
-
return (0, module_federation_config_1.createDefaultRemoteUrlResolver)(isServer, 'js');
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Framework config for webpack projects (React).
|
|
17
|
-
*/
|
|
18
|
-
function getWebpackFrameworkConfig(bundler = 'rspack') {
|
|
19
|
-
return {
|
|
20
|
-
bundler,
|
|
21
|
-
remoteEntryExt: 'js',
|
|
22
|
-
mapRemotesExpose: true,
|
|
23
|
-
applyEagerPackages: (sharedConfig, projectGraph, projectName) => {
|
|
24
|
-
if ((0, framework_detection_1.isReactProject)(projectName, projectGraph)) {
|
|
25
|
-
(0, utils_1.applyDefaultEagerPackages)(sharedConfig);
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async function getModuleFederationConfig(mfConfig, options = { isServer: false }, bundler = 'rspack') {
|
|
31
|
-
return (0, module_federation_config_1.getModuleFederationConfigAsync)(mfConfig, options, getWebpackFrameworkConfig(bundler));
|
|
32
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
4
|
-
const utils_1 = require("../../utils");
|
|
5
|
-
const utils_2 = require("./utils");
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const is_serve_mode_1 = require("../../utils/is-serve-mode");
|
|
8
|
-
async function withModuleFederationForSSR(options, configOverride) {
|
|
9
|
-
if (global.NX_GRAPH_CREATION) {
|
|
10
|
-
return (config) => config;
|
|
11
|
-
}
|
|
12
|
-
const isDevServer = (0, is_serve_mode_1.isServeMode)();
|
|
13
|
-
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_2.getModuleFederationConfig)(options, {
|
|
14
|
-
isServer: true,
|
|
15
|
-
}, 'webpack');
|
|
16
|
-
return (config) => {
|
|
17
|
-
config.target = 'async-node';
|
|
18
|
-
config.output.uniqueName = options.name;
|
|
19
|
-
config.resolve ??= {};
|
|
20
|
-
config.resolve.modules = [
|
|
21
|
-
...(config.resolve.modules ?? ['node_modules']),
|
|
22
|
-
devkit_1.workspaceRoot,
|
|
23
|
-
];
|
|
24
|
-
config.optimization = {
|
|
25
|
-
...(config.optimization ?? {}),
|
|
26
|
-
runtimeChunk: isDevServer
|
|
27
|
-
? (config.optimization?.runtimeChunk ?? undefined)
|
|
28
|
-
: false,
|
|
29
|
-
};
|
|
30
|
-
config.plugins.push(new (require('@module-federation/enhanced').ModuleFederationPlugin)({
|
|
31
|
-
name: (0, utils_1.normalizeProjectName)(options.name),
|
|
32
|
-
filename: 'remoteEntry.js',
|
|
33
|
-
exposes: options.exposes,
|
|
34
|
-
remotes: mappedRemotes,
|
|
35
|
-
shared: {
|
|
36
|
-
...sharedDependencies,
|
|
37
|
-
},
|
|
38
|
-
remoteType: 'script',
|
|
39
|
-
library: {
|
|
40
|
-
type: 'commonjs-module',
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Apply user-defined config overrides
|
|
44
|
-
*/
|
|
45
|
-
...(configOverride ? configOverride : {}),
|
|
46
|
-
experiments: {
|
|
47
|
-
asyncStartup: true,
|
|
48
|
-
// We should allow users to override experiments
|
|
49
|
-
...(configOverride?.experiments ?? {}),
|
|
50
|
-
},
|
|
51
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
52
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
53
|
-
? [
|
|
54
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
55
|
-
require.resolve('@nx/module-federation/runtime-library-control-plugin'),
|
|
56
|
-
]
|
|
57
|
-
: [
|
|
58
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
59
|
-
require.resolve('@module-federation/node/runtimePlugin'),
|
|
60
|
-
],
|
|
61
|
-
}, {}), sharedLibraries.getReplacementPlugin());
|
|
62
|
-
// The env var is only set from the module-federation-dev-server
|
|
63
|
-
// Attach the runtime plugin
|
|
64
|
-
config.plugins.push(new (require('webpack').DefinePlugin)({
|
|
65
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
66
|
-
}));
|
|
67
|
-
return config;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../../utils';
|
|
2
|
-
/**
|
|
3
|
-
* @param {ModuleFederationConfig} options
|
|
4
|
-
*/
|
|
5
|
-
export declare function withModuleFederation(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any, ctx: any) => any>;
|