@nx/module-federation 20.2.0-beta.2 → 20.2.0-beta.4
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/angular.d.ts +2 -0
- package/angular.js +5 -0
- package/index.d.ts +1 -0
- package/index.js +4 -0
- package/package.json +12 -11
- package/rspack.d.ts +2 -0
- package/rspack.js +5 -0
- package/src/utils/dependencies.d.ts +6 -0
- package/src/utils/dependencies.js +56 -0
- package/src/utils/get-remotes-for-host.d.ts +16 -0
- package/src/utils/get-remotes-for-host.js +97 -0
- package/src/utils/index.d.ts +9 -0
- package/src/utils/index.js +12 -0
- package/src/utils/models/index.d.ts +47 -0
- package/src/utils/models/index.js +2 -0
- package/src/utils/package-json.d.ts +8 -0
- package/src/utils/package-json.js +12 -0
- package/src/utils/parse-static-remotes-config.d.ts +13 -0
- package/src/utils/parse-static-remotes-config.js +34 -0
- package/src/utils/plugins/runtime-library-control.plugin.d.ts +3 -0
- package/src/utils/plugins/runtime-library-control.plugin.js +54 -0
- package/src/utils/public-api.d.ts +6 -0
- package/src/utils/public-api.js +16 -0
- package/src/utils/remotes.d.ts +19 -0
- package/src/utils/remotes.js +89 -0
- package/src/utils/secondary-entry-points.d.ts +12 -0
- package/src/utils/secondary-entry-points.js +125 -0
- package/src/utils/share.d.ts +49 -0
- package/src/utils/share.js +246 -0
- package/src/utils/start-remote-proxies.d.ts +5 -0
- package/src/utils/start-remote-proxies.js +38 -0
- package/src/utils/start-ssr-remote-proxies.d.ts +5 -0
- package/src/utils/start-ssr-remote-proxies.js +52 -0
- package/src/utils/typescript.d.ts +4 -0
- package/src/utils/typescript.js +53 -0
- package/src/with-module-federation/angular/utils.d.ts +15 -0
- package/src/with-module-federation/angular/utils.js +101 -0
- package/src/with-module-federation/angular/with-module-federation-ssr.d.ts +2 -0
- package/src/with-module-federation/angular/with-module-federation-ssr.js +77 -0
- package/src/with-module-federation/angular/with-module-federation.d.ts +2 -0
- package/src/with-module-federation/angular/with-module-federation.js +70 -0
- package/src/with-module-federation/rspack/utils.d.ts +12 -0
- package/src/with-module-federation/rspack/utils.js +74 -0
- package/src/with-module-federation/rspack/with-module-federation-ssr.d.ts +4 -0
- package/src/with-module-federation/rspack/with-module-federation-ssr.js +67 -0
- package/src/with-module-federation/rspack/with-module-federation.d.ts +9 -0
- package/src/with-module-federation/rspack/with-module-federation.js +70 -0
- package/src/with-module-federation/webpack/utils.d.ts +12 -0
- package/src/with-module-federation/webpack/utils.js +75 -0
- package/src/with-module-federation/webpack/with-module-federation-ssr.d.ts +2 -0
- package/src/with-module-federation/webpack/with-module-federation-ssr.js +59 -0
- package/src/with-module-federation/webpack/with-module-federation.d.ts +5 -0
- package/src/with-module-federation/webpack/with-module-federation.js +62 -0
- package/webpack.d.ts +2 -0
- package/webpack.js +5 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederation = withModuleFederation;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const webpack_1 = require("@module-federation/enhanced/webpack");
|
|
6
|
+
/**
|
|
7
|
+
* @param {ModuleFederationConfig} options
|
|
8
|
+
*/
|
|
9
|
+
async function withModuleFederation(options, configOverride) {
|
|
10
|
+
if (global.NX_GRAPH_CREATION) {
|
|
11
|
+
return (config) => config;
|
|
12
|
+
}
|
|
13
|
+
const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
|
14
|
+
return (config, ctx) => {
|
|
15
|
+
config.output.uniqueName = options.name;
|
|
16
|
+
config.output.publicPath = 'auto';
|
|
17
|
+
config.output.scriptType = 'text/javascript';
|
|
18
|
+
config.optimization = {
|
|
19
|
+
...(config.optimization ?? {}),
|
|
20
|
+
runtimeChunk: false,
|
|
21
|
+
};
|
|
22
|
+
if (config.mode === 'development' &&
|
|
23
|
+
Object.keys(mappedRemotes).length > 1 &&
|
|
24
|
+
!options.exposes) {
|
|
25
|
+
config.optimization.runtimeChunk = 'single';
|
|
26
|
+
}
|
|
27
|
+
config.plugins.push(new webpack_1.ModuleFederationPlugin({
|
|
28
|
+
name: options.name.replace(/-/g, '_'),
|
|
29
|
+
filename: 'remoteEntry.js',
|
|
30
|
+
exposes: options.exposes,
|
|
31
|
+
remotes: mappedRemotes,
|
|
32
|
+
shared: {
|
|
33
|
+
...sharedDependencies,
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* remoteType: 'script' is required for the remote to be loaded as a script tag.
|
|
37
|
+
* remotes will need to be defined as:
|
|
38
|
+
* { appX: 'appX@http://localhost:3001/remoteEntry.js' }
|
|
39
|
+
* { appY: 'appY@http://localhost:3002/remoteEntry.js' }
|
|
40
|
+
*/
|
|
41
|
+
remoteType: 'script',
|
|
42
|
+
/**
|
|
43
|
+
* Apply user-defined config overrides
|
|
44
|
+
*/
|
|
45
|
+
...(configOverride ? configOverride : {}),
|
|
46
|
+
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
47
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
|
48
|
+
? [
|
|
49
|
+
...(configOverride?.runtimePlugins ?? []),
|
|
50
|
+
require.resolve('@nx/module-federation/src/utils/plugins/runtime-library-control.plugin.js'),
|
|
51
|
+
]
|
|
52
|
+
: configOverride?.runtimePlugins,
|
|
53
|
+
virtualRuntimeEntry: true,
|
|
54
|
+
}), sharedLibraries.getReplacementPlugin());
|
|
55
|
+
// The env var is only set from the module-federation-dev-server
|
|
56
|
+
// Attach the runtime plugin
|
|
57
|
+
config.plugins.push(new (require('webpack').DefinePlugin)({
|
|
58
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
59
|
+
}));
|
|
60
|
+
return config;
|
|
61
|
+
};
|
|
62
|
+
}
|
package/webpack.d.ts
ADDED
package/webpack.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./src/with-module-federation/webpack/with-module-federation"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./src/with-module-federation/webpack/with-module-federation-ssr"), exports);
|