@module-federation/nextjs-mf 7.0.8 → 8.0.1-0
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/CHANGELOG.md +545 -411
- package/README.md +29 -15
- package/client/MFClient.js +1 -2
- package/client/MFClient.js.map +1 -1
- package/client/RemoteContainer.js +2 -1
- package/client/RemoteContainer.js.map +1 -1
- package/client/RemotePages.js +2 -1
- package/client/RemotePages.js.map +1 -1
- package/client/UrlNode.js +2 -10
- package/client/UrlNode.js.map +1 -1
- package/node.d.ts +1 -1
- package/node.js.map +1 -1
- package/package.json +7 -5
- package/src/default-delegate.js +64 -9
- package/src/default-delegate.js.map +1 -1
- package/src/federation-noop.js +13 -1
- package/src/federation-noop.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/internal.d.ts +18 -12
- package/src/internal.js +83 -71
- package/src/internal.js.map +1 -1
- package/src/loaders/delegateLoader.d.ts +5 -2
- package/src/loaders/delegateLoader.js +19 -9
- package/src/loaders/delegateLoader.js.map +1 -1
- package/src/loaders/fixImageLoader.d.ts +12 -11
- package/src/loaders/fixImageLoader.js +17 -13
- package/src/loaders/fixImageLoader.js.map +1 -1
- package/src/loaders/fixUrlLoader.d.ts +7 -7
- package/src/loaders/fixUrlLoader.js +11 -11
- package/src/loaders/fixUrlLoader.js.map +1 -1
- package/src/loaders/helpers.d.ts +10 -3
- package/src/loaders/helpers.js +22 -13
- package/src/loaders/helpers.js.map +1 -1
- package/src/loaders/inject-hoist.d.ts +11 -0
- package/src/loaders/inject-hoist.js +7 -0
- package/src/loaders/inject-hoist.js.map +1 -1
- package/src/loaders/nextPageMapLoader.d.ts +12 -3
- package/src/loaders/nextPageMapLoader.js +45 -29
- package/src/loaders/nextPageMapLoader.js.map +1 -1
- package/src/loaders/patchDefaultSharedLoader.d.ts +9 -0
- package/src/loaders/patchDefaultSharedLoader.js +11 -0
- package/src/loaders/patchDefaultSharedLoader.js.map +1 -1
- package/src/loaders/patchNextClientPageLoader.d.ts +4 -2
- package/src/loaders/patchNextClientPageLoader.js +36 -18
- package/src/loaders/patchNextClientPageLoader.js.map +1 -1
- package/src/plugins/CopyFederationPlugin.d.ts +13 -0
- package/src/plugins/CopyFederationPlugin.js +40 -19
- package/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +2 -3
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js +9 -6
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +17 -10
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js +35 -27
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/src/plugins/NextFederationPlugin/index.d.ts +18 -6
- package/src/plugins/NextFederationPlugin/index.js +108 -75
- package/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/src/plugins/NextFederationPlugin/next-fragments.d.ts +23 -17
- package/src/plugins/NextFederationPlugin/next-fragments.js +26 -18
- package/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/src/plugins/NextFederationPlugin/regex-equal.d.ts +8 -8
- package/src/plugins/NextFederationPlugin/regex-equal.js +7 -7
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +7 -0
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +20 -9
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -1
- package/src/plugins/NextFederationPlugin/set-options.d.ts +6 -6
- package/src/plugins/NextFederationPlugin/set-options.js +10 -6
- package/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/src/plugins/NextFederationPlugin/validate-options.d.ts +13 -14
- package/src/plugins/NextFederationPlugin/validate-options.js +15 -15
- package/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/src/plugins/container/EmbeddedContainerPlugin.d.ts +40 -0
- package/src/plugins/container/EmbeddedContainerPlugin.js +73 -0
- package/src/plugins/container/EmbeddedContainerPlugin.js.map +1 -0
- package/src/plugins/container/InvertedContainerPlugin.d.ts +21 -14
- package/src/plugins/container/InvertedContainerPlugin.js +21 -148
- package/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/src/plugins/container/InvertedContainerRuntimeModule.d.ts +3 -33
- package/src/plugins/container/InvertedContainerRuntimeModule.js +64 -518
- package/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/src/plugins/container/ModuleFederationPlugin.d.ts +17 -0
- package/src/plugins/container/ModuleFederationPlugin.js +97 -0
- package/src/plugins/container/ModuleFederationPlugin.js.map +1 -0
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +28 -6
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +34 -57
- package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -1
- package/src/plugins/container/types.d.ts +1 -1
- package/src/types.d.ts +3 -0
- package/utilities.js.map +1 -1
- package/utils/Template.d.ts +1 -1
- package/utils/Template.js +23 -15
- package/utils/Template.js.map +1 -1
- package/utils/build-utils.d.ts +9 -0
- package/utils/build-utils.js +9 -0
- package/utils/build-utils.js.map +1 -1
- package/utils/flushedChunks.d.ts +15 -0
- package/utils/flushedChunks.js +8 -0
- package/utils/flushedChunks.js.map +1 -1
- package/utils/index.d.ts +27 -3
- package/utils/index.js +45 -1
- package/utils/index.js.map +1 -1
- package/src/plugins/JsonpChunkLoading.d.ts +0 -7
- package/src/plugins/JsonpChunkLoading.js +0 -43
- package/src/plugins/JsonpChunkLoading.js.map +0 -1
- package/src/plugins/container/custom-jsonp.d.ts +0 -2
- package/src/plugins/container/custom-jsonp.js +0 -90
- package/src/plugins/container/custom-jsonp.js.map +0 -1
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { Compiler } from 'webpack';
|
|
2
2
|
import { ModuleFederationPluginOptions } from '@module-federation/utilities';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* This function applies server-specific plugins to the webpack compiler.
|
|
5
5
|
*
|
|
6
|
-
* @param compiler - The Webpack compiler instance.
|
|
7
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
6
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
7
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
8
8
|
*
|
|
9
|
+
* @returns {void}
|
|
9
10
|
*/
|
|
10
11
|
export declare function applyServerPlugins(compiler: Compiler, options: ModuleFederationPluginOptions): void;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* This function configures server-specific library and filename options.
|
|
13
14
|
*
|
|
14
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
15
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
16
|
+
*
|
|
17
|
+
* @returns {void}
|
|
15
18
|
*
|
|
16
19
|
* @remarks
|
|
17
20
|
* This function configures the library and filename options for server builds. The library option is
|
|
@@ -21,10 +24,12 @@ export declare function applyServerPlugins(compiler: Compiler, options: ModuleFe
|
|
|
21
24
|
*/
|
|
22
25
|
export declare function configureServerLibraryAndFilename(options: ModuleFederationPluginOptions): void;
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
27
|
+
* This function patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
|
|
28
|
+
*
|
|
29
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
30
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
25
31
|
*
|
|
26
|
-
* @
|
|
27
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
32
|
+
* @returns {void}
|
|
28
33
|
*
|
|
29
34
|
* @remarks
|
|
30
35
|
* In server builds, all node modules are treated as external, which prevents them from being shared
|
|
@@ -40,9 +45,11 @@ export declare function configureServerLibraryAndFilename(options: ModuleFederat
|
|
|
40
45
|
*/
|
|
41
46
|
export declare function handleServerExternals(compiler: Compiler, options: ModuleFederationPluginOptions): void;
|
|
42
47
|
/**
|
|
43
|
-
*
|
|
48
|
+
* This function configures server-specific compiler options.
|
|
49
|
+
*
|
|
50
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
44
51
|
*
|
|
45
|
-
* @
|
|
52
|
+
* @returns {void}
|
|
46
53
|
*
|
|
47
54
|
* @remarks
|
|
48
55
|
* This function configures the compiler options for server builds. It turns off the compiler target on node
|
|
@@ -7,18 +7,20 @@ exports.configureServerCompilerOptions = exports.handleServerExternals = exports
|
|
|
7
7
|
const DelegateModulesPlugin_1 = __importDefault(require("@module-federation/utilities/src/plugins/DelegateModulesPlugin"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
|
|
10
|
-
const
|
|
10
|
+
const enhanced_1 = require("@module-federation/enhanced");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* This function applies server-specific plugins to the webpack compiler.
|
|
13
13
|
*
|
|
14
|
-
* @param compiler - The Webpack compiler instance.
|
|
15
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
14
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
15
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
16
16
|
*
|
|
17
|
+
* @returns {void}
|
|
17
18
|
*/
|
|
18
19
|
function applyServerPlugins(compiler, options) {
|
|
19
20
|
// Import the StreamingTargetPlugin from @module-federation/node
|
|
20
21
|
const { StreamingTargetPlugin } = require('@module-federation/node');
|
|
21
|
-
new
|
|
22
|
+
new enhanced_1.ModuleInfoRuntimePlugin().apply(compiler);
|
|
23
|
+
// Apply the DelegatesModulePlugin to the compiler
|
|
22
24
|
new DelegateModulesPlugin_1.default({
|
|
23
25
|
runtime: 'webpack-runtime',
|
|
24
26
|
remotes: options.remotes,
|
|
@@ -26,21 +28,28 @@ function applyServerPlugins(compiler, options) {
|
|
|
26
28
|
}).apply(compiler);
|
|
27
29
|
// Add the StreamingTargetPlugin with the ModuleFederationPlugin from the webpack container
|
|
28
30
|
new StreamingTargetPlugin(options, {
|
|
29
|
-
ModuleFederationPlugin:
|
|
31
|
+
ModuleFederationPlugin: enhanced_1.ModuleFederationPlugin,
|
|
30
32
|
}).apply(compiler);
|
|
31
33
|
// Add a new commonjs chunk loading plugin to the compiler
|
|
32
34
|
new InvertedContainerPlugin_1.default({
|
|
33
35
|
runtime: 'webpack-runtime',
|
|
34
36
|
container: options.name,
|
|
37
|
+
chunkToEmbed: 'host_inner_ctn',
|
|
35
38
|
remotes: options.remotes,
|
|
39
|
+
shared: options.shared,
|
|
40
|
+
shareScope: 'default',
|
|
41
|
+
exposes: options.exposes,
|
|
36
42
|
debug: false,
|
|
43
|
+
//@ts-ignore
|
|
37
44
|
}).apply(compiler);
|
|
38
45
|
}
|
|
39
46
|
exports.applyServerPlugins = applyServerPlugins;
|
|
40
47
|
/**
|
|
41
|
-
*
|
|
48
|
+
* This function configures server-specific library and filename options.
|
|
42
49
|
*
|
|
43
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
50
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
51
|
+
*
|
|
52
|
+
* @returns {void}
|
|
44
53
|
*
|
|
45
54
|
* @remarks
|
|
46
55
|
* This function configures the library and filename options for server builds. The library option is
|
|
@@ -59,10 +68,12 @@ function configureServerLibraryAndFilename(options) {
|
|
|
59
68
|
}
|
|
60
69
|
exports.configureServerLibraryAndFilename = configureServerLibraryAndFilename;
|
|
61
70
|
/**
|
|
62
|
-
*
|
|
71
|
+
* This function patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
|
|
72
|
+
*
|
|
73
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
74
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
63
75
|
*
|
|
64
|
-
* @
|
|
65
|
-
* @param options - The ModuleFederationPluginOptions instance.
|
|
76
|
+
* @returns {void}
|
|
66
77
|
*
|
|
67
78
|
* @remarks
|
|
68
79
|
* In server builds, all node modules are treated as external, which prevents them from being shared
|
|
@@ -77,7 +88,11 @@ exports.configureServerLibraryAndFilename = configureServerLibraryAndFilename;
|
|
|
77
88
|
* function returns the original result. Otherwise, the function returns null.
|
|
78
89
|
*/
|
|
79
90
|
function handleServerExternals(compiler, options) {
|
|
80
|
-
//
|
|
91
|
+
// Use a regex to match the required external modules
|
|
92
|
+
// const crittersRegex = 'critters';
|
|
93
|
+
// const reactRegex = /^react$/;
|
|
94
|
+
// const reactDomRegex = /^react-dom$/;
|
|
95
|
+
// const nextCompiledRegex = /next\/dist\/compiled\/(?!server|client|shared).*/;
|
|
81
96
|
if (Array.isArray(compiler.options.externals) &&
|
|
82
97
|
compiler.options.externals[0]) {
|
|
83
98
|
// Retrieve the original externals function
|
|
@@ -98,12 +113,6 @@ function handleServerExternals(compiler, options) {
|
|
|
98
113
|
// If the module should not be treated as external, return without calling the original externals function
|
|
99
114
|
return;
|
|
100
115
|
}
|
|
101
|
-
// seems to cause build issues at lululemon
|
|
102
|
-
// nobody else seems to run into this issue
|
|
103
|
-
// #JobSecurity
|
|
104
|
-
if (ctx.request && ctx.request.includes('react/jsx-runtime')) {
|
|
105
|
-
return 'commonjs ' + ctx.request;
|
|
106
|
-
}
|
|
107
116
|
// Call the original externals function and retrieve the result
|
|
108
117
|
// @ts-ignore
|
|
109
118
|
const fromNext = await originalExternals(ctx, callback);
|
|
@@ -125,13 +134,19 @@ function handleServerExternals(compiler, options) {
|
|
|
125
134
|
// Otherwise, return (null) to treat the module as internalizable
|
|
126
135
|
return;
|
|
127
136
|
};
|
|
137
|
+
// compiler.options.externals.push(crittersRegex)
|
|
138
|
+
// compiler.options.externals.push(reactRegex)
|
|
139
|
+
// compiler.options.externals.push(reactDomRegex)
|
|
140
|
+
// compiler.options.externals.push(nextCompiledRegex)
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
exports.handleServerExternals = handleServerExternals;
|
|
131
144
|
/**
|
|
132
|
-
*
|
|
145
|
+
* This function configures server-specific compiler options.
|
|
146
|
+
*
|
|
147
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
133
148
|
*
|
|
134
|
-
* @
|
|
149
|
+
* @returns {void}
|
|
135
150
|
*
|
|
136
151
|
* @remarks
|
|
137
152
|
* This function configures the compiler options for server builds. It turns off the compiler target on node
|
|
@@ -142,17 +157,10 @@ exports.handleServerExternals = handleServerExternals;
|
|
|
142
157
|
function configureServerCompilerOptions(compiler) {
|
|
143
158
|
// Turn off the compiler target on node builds because we add our own chunk loading runtime module
|
|
144
159
|
// with NodeFederationPlugin and StreamingTargetPlugin
|
|
145
|
-
compiler.options.target = false;
|
|
146
160
|
compiler.options.node = {
|
|
147
161
|
...compiler.options.node,
|
|
148
162
|
global: false,
|
|
149
163
|
};
|
|
150
|
-
compiler.options.resolve.conditionNames = [
|
|
151
|
-
'node',
|
|
152
|
-
'import',
|
|
153
|
-
'require',
|
|
154
|
-
'default',
|
|
155
|
-
];
|
|
156
164
|
// no custom chunk rules
|
|
157
165
|
compiler.options.optimization.splitChunks = undefined;
|
|
158
166
|
// solves strange issues where next doesnt create a runtime chunk
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,2HAAmG;AACnG,gDAAwB;AACxB,mGAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,2HAAmG;AACnG,gDAAwB;AACxB,mGAA2E;AAC3E,0DAGqC;AACrC;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC;IAEtC,gE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AC,CAAC,CAAC,CAAC;YACnC,IACE,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;gBACtB,iEAAiE;gBACjE,sCAAsC;gBACtC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACxB,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;gBAC5B,GAAG,KAAK,OAAO;gBACf,GAAG,KAAK,WAAW,EACnB;gBACA,OAAO,QAAQ,CAAC;aACjB;YACD,iEAAiE;YACjE,OAAO;QACT,CAAC,CAAC;QACF,iDAAiD;QACjD,8CAA8C;QAC9C,iDAAiD;QACjD,qDAAqD;KACtD;AACH,CAAC;AApED,sDAoEC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,8BAA8B,CAAC,QAAkB;IAC/D,kGAAkG;IAClG,sDAAsD;IACtD,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG;QACtB,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI;QACxB,MAAM,EAAE,KAAK;KACd,CAAC;IACF,wBAAwB;IACxB,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,GAAG,SAAS,CAAC;IAEtD,iEAAiE;IACjE,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,GAAG;QAC3C,IAAI,EAAE,iBAAiB;KACxB,CAAC;AACJ,CAAC;AAfD,wEAeC"}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { NextFederationPluginOptions } from '@module-federation/utilities';
|
|
2
|
+
import type Compiler from 'webpack/lib/Compiler';
|
|
3
3
|
/**
|
|
4
|
-
* NextFederationPlugin is a webpack plugin that handles Next.js application
|
|
5
|
-
* federation using Module Federation.
|
|
4
|
+
* NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
|
|
6
5
|
*/
|
|
7
6
|
export declare class NextFederationPlugin {
|
|
8
|
-
_options
|
|
9
|
-
_extraOptions
|
|
7
|
+
private _options;
|
|
8
|
+
private _extraOptions;
|
|
10
9
|
/**
|
|
11
10
|
* Constructs the NextFederationPlugin with the provided options.
|
|
12
11
|
*
|
|
13
12
|
* @param options The options to configure the plugin.
|
|
14
13
|
*/
|
|
15
14
|
constructor(options: NextFederationPluginOptions);
|
|
15
|
+
/**
|
|
16
|
+
* The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
|
|
17
|
+
* @param compiler The webpack compiler object.
|
|
18
|
+
*/
|
|
16
19
|
apply(compiler: Compiler): void;
|
|
20
|
+
private validateOptions;
|
|
21
|
+
private isServerCompiler;
|
|
22
|
+
private applyConditionalPlugins;
|
|
23
|
+
private getNormalFederationPluginOptions;
|
|
24
|
+
private getNoopPath;
|
|
25
|
+
private createEmbeddedOptions;
|
|
26
|
+
private applyClientFederationPlugins;
|
|
27
|
+
private applyServerFederationPlugins;
|
|
28
|
+
private applyModuleFederationPlugins;
|
|
17
29
|
}
|
|
18
30
|
export default NextFederationPlugin;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
* Author Zackary Jackson @ScriptedAlchemy
|
|
4
|
+
* This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.
|
|
5
|
+
*/
|
|
5
6
|
'use strict';
|
|
6
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
9
|
};
|
|
9
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
11
|
exports.NextFederationPlugin = void 0;
|
|
11
|
-
const utilities_1 = require("@module-federation/utilities");
|
|
12
12
|
const CopyFederationPlugin_1 = __importDefault(require("../CopyFederationPlugin"));
|
|
13
|
-
const next_fragments_1 = require("./next-fragments");
|
|
14
|
-
const internal_1 = require("../../internal");
|
|
15
|
-
const AddRuntimeRequirementToPromiseExternalPlugin_1 = __importDefault(require("../AddRuntimeRequirementToPromiseExternalPlugin"));
|
|
16
13
|
const nextPageMapLoader_1 = require("../../loaders/nextPageMapLoader");
|
|
17
|
-
const
|
|
14
|
+
const next_fragments_1 = require("./next-fragments");
|
|
18
15
|
const set_options_1 = require("./set-options");
|
|
19
16
|
const validate_options_1 = require("./validate-options");
|
|
20
17
|
const apply_server_plugins_1 = require("./apply-server-plugins");
|
|
21
18
|
const apply_client_plugins_1 = require("./apply-client-plugins");
|
|
19
|
+
const ModuleFederationPlugin_1 = __importDefault(require("../container/ModuleFederationPlugin"));
|
|
20
|
+
const node_1 = require("@module-federation/node");
|
|
22
21
|
/**
|
|
23
|
-
* NextFederationPlugin is a webpack plugin that handles Next.js application
|
|
24
|
-
* federation using Module Federation.
|
|
22
|
+
* NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
|
|
25
23
|
*/
|
|
26
24
|
class NextFederationPlugin {
|
|
27
25
|
/**
|
|
@@ -34,57 +32,70 @@ class NextFederationPlugin {
|
|
|
34
32
|
this._options = mainOptions;
|
|
35
33
|
this._extraOptions = extraOptions;
|
|
36
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
|
|
37
|
+
* @param compiler The webpack compiler object.
|
|
38
|
+
*/
|
|
37
39
|
apply(compiler) {
|
|
38
|
-
|
|
39
|
-
const validCompile = (0, validate_options_1.validateCompilerOptions)(compiler);
|
|
40
|
-
if (!validCompile)
|
|
40
|
+
if (!this.validateOptions(compiler))
|
|
41
41
|
return;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Check if the compiler is for the server or client
|
|
45
|
-
const isServer = compiler.options.name === 'server';
|
|
46
|
-
const { webpack } = compiler;
|
|
47
|
-
// Apply the CopyFederationPlugin
|
|
42
|
+
const isServer = this.isServerCompiler(compiler);
|
|
43
|
+
//@ts-ignore
|
|
48
44
|
new CopyFederationPlugin_1.default(isServer).apply(compiler);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
this.applyConditionalPlugins(compiler, isServer);
|
|
46
|
+
const normalFederationPluginOptions = this.getNormalFederationPluginOptions(compiler, isServer);
|
|
47
|
+
this.applyModuleFederationPlugins(compiler, normalFederationPluginOptions, isServer);
|
|
48
|
+
}
|
|
49
|
+
validateOptions(compiler) {
|
|
50
|
+
const compilerValid = (0, validate_options_1.validateCompilerOptions)(compiler);
|
|
51
|
+
const pluginValid = (0, validate_options_1.validatePluginOptions)(this._options);
|
|
52
|
+
if (compilerValid === undefined)
|
|
53
|
+
console.error('Compiler validation failed');
|
|
54
|
+
if (pluginValid === undefined)
|
|
55
|
+
console.error('Plugin validation failed');
|
|
56
|
+
const validCompilerTarget = compiler.options.name === 'server' || compiler.options.name === 'client';
|
|
57
|
+
return (compilerValid !== undefined &&
|
|
58
|
+
pluginValid !== undefined &&
|
|
59
|
+
validCompilerTarget);
|
|
60
|
+
}
|
|
61
|
+
isServerCompiler(compiler) {
|
|
62
|
+
return compiler.options.name === 'server';
|
|
63
|
+
}
|
|
64
|
+
applyConditionalPlugins(compiler, isServer) {
|
|
65
|
+
compiler.options.output.uniqueName = this._options.name;
|
|
66
|
+
(0, next_fragments_1.applyPathFixes)(compiler, this._extraOptions);
|
|
60
67
|
if (isServer) {
|
|
61
|
-
|
|
68
|
+
//@ts-ignore
|
|
62
69
|
(0, apply_server_plugins_1.configureServerCompilerOptions)(compiler);
|
|
63
70
|
(0, apply_server_plugins_1.configureServerLibraryAndFilename)(this._options);
|
|
71
|
+
//@ts-ignore
|
|
64
72
|
(0, apply_server_plugins_1.applyServerPlugins)(compiler, this._options);
|
|
73
|
+
//@ts-ignore
|
|
65
74
|
(0, apply_server_plugins_1.handleServerExternals)(compiler, {
|
|
66
75
|
...this._options,
|
|
67
|
-
shared: { ...
|
|
76
|
+
shared: { ...(0, next_fragments_1.retrieveDefaultShared)(isServer), ...this._options.shared },
|
|
68
77
|
});
|
|
69
78
|
}
|
|
70
79
|
else {
|
|
80
|
+
//@ts-ignore
|
|
71
81
|
(0, apply_client_plugins_1.applyClientPlugins)(compiler, this._options, this._extraOptions);
|
|
72
82
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
83
|
+
}
|
|
84
|
+
getNormalFederationPluginOptions(compiler, isServer) {
|
|
85
|
+
const defaultShared = (0, next_fragments_1.retrieveDefaultShared)(isServer);
|
|
86
|
+
const noop = this.getNoopPath();
|
|
87
|
+
return {
|
|
76
88
|
...this._options,
|
|
77
89
|
runtime: false,
|
|
90
|
+
remoteType: 'script',
|
|
78
91
|
exposes: {
|
|
79
|
-
|
|
80
|
-
|
|
92
|
+
'./noop': noop,
|
|
93
|
+
...this._options.exposes,
|
|
81
94
|
...(this._extraOptions.exposePages
|
|
82
95
|
? (0, nextPageMapLoader_1.exposeNextjsPages)(compiler.options.context)
|
|
83
96
|
: {}),
|
|
84
|
-
...this._options.exposes,
|
|
85
97
|
},
|
|
86
98
|
remotes: {
|
|
87
|
-
//@ts-ignore
|
|
88
99
|
...this._options.remotes,
|
|
89
100
|
},
|
|
90
101
|
shared: {
|
|
@@ -92,46 +103,68 @@ class NextFederationPlugin {
|
|
|
92
103
|
...this._options.shared,
|
|
93
104
|
},
|
|
94
105
|
};
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
}
|
|
107
|
+
getNoopPath() {
|
|
108
|
+
let noop;
|
|
109
|
+
try {
|
|
110
|
+
noop = require.resolve('../../federation-noop');
|
|
97
111
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
(0, next_fragments_1.applyRemoteDelegates)(this._options, compiler);
|
|
101
|
-
//@ts-ignore
|
|
102
|
-
if (this._extraOptions.automaticAsyncBoundary) {
|
|
103
|
-
console.warn('[nextjs-mf]: automaticAsyncBoundary is deprecated');
|
|
112
|
+
catch (e) {
|
|
113
|
+
noop = require.resolve('../../federation-noop.cjs');
|
|
104
114
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
...hostFederationPluginOptions,
|
|
115
|
+
return noop;
|
|
116
|
+
}
|
|
117
|
+
createEmbeddedOptions(normalFederationPluginOptions, isServer) {
|
|
118
|
+
return {
|
|
119
|
+
...normalFederationPluginOptions,
|
|
120
|
+
name: 'host_inner_ctn',
|
|
121
|
+
runtime: isServer ? 'webpack-runtime' : 'webpack',
|
|
122
|
+
filename: `host_inner_ctn.js`,
|
|
123
|
+
remoteType: 'script',
|
|
124
|
+
library: {
|
|
125
|
+
...normalFederationPluginOptions.library,
|
|
117
126
|
name: 'host_inner_ctn',
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
applyClientFederationPlugins(compiler, normalFederationPluginOptions) {
|
|
131
|
+
const embeddedOptions = this.createEmbeddedOptions(normalFederationPluginOptions);
|
|
132
|
+
new ModuleFederationPlugin_1.default(normalFederationPluginOptions, embeddedOptions).apply(compiler);
|
|
133
|
+
}
|
|
134
|
+
applyServerFederationPlugins(compiler, normalFederationPluginOptions) {
|
|
135
|
+
const embeddedOptions = this.createEmbeddedOptions(normalFederationPluginOptions, true);
|
|
136
|
+
//@ts-ignore
|
|
137
|
+
const serverSharedOptions = Object.keys(
|
|
138
|
+
//@ts-ignore
|
|
139
|
+
normalFederationPluginOptions.shared).reduce((acc, key) => ({
|
|
140
|
+
...acc,
|
|
141
|
+
//@ts-ignore
|
|
142
|
+
[key]: { ...normalFederationPluginOptions.shared[key], eager: false },
|
|
143
|
+
}), {});
|
|
144
|
+
const mainOptions = {
|
|
145
|
+
...normalFederationPluginOptions,
|
|
146
|
+
shared: serverSharedOptions,
|
|
147
|
+
};
|
|
148
|
+
//@ts-ignore
|
|
149
|
+
const prepareRemote = (options) => {
|
|
150
|
+
return {
|
|
151
|
+
...options,
|
|
152
|
+
remotes: options.remotes
|
|
153
|
+
? (0, node_1.parseRemotes)(options.remotes)
|
|
154
|
+
: {},
|
|
128
155
|
};
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
156
|
+
};
|
|
157
|
+
//@ts-ignore
|
|
158
|
+
new ModuleFederationPlugin_1.default(prepareRemote(mainOptions), prepareRemote(embeddedOptions)).apply(compiler);
|
|
159
|
+
}
|
|
160
|
+
applyModuleFederationPlugins(compiler, normalFederationPluginOptions, isServer) {
|
|
161
|
+
const ModuleFederationPlugin = (0, next_fragments_1.getModuleFederationPluginConstructor)(isServer, compiler);
|
|
162
|
+
if (!isServer) {
|
|
163
|
+
this.applyClientFederationPlugins(compiler, normalFederationPluginOptions);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.applyServerFederationPlugins(compiler, normalFederationPluginOptions);
|
|
133
167
|
}
|
|
134
|
-
new AddRuntimeRequirementToPromiseExternalPlugin_1.default().apply(compiler);
|
|
135
168
|
}
|
|
136
169
|
}
|
|
137
170
|
exports.NextFederationPlugin = NextFederationPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;;;;AAUb,mFAA2D;AAE3D,uEAAoE;AACpE,qDAK0B;AAE1B,+CAA2C;AAC3C,yDAG4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,CAAC,4BAA4B,CAC/B,QAAQ,EACR,6BAA6B,CAC9B,CAAC;SACH;IACH,CAAC;CACF;AA7MD,oDA6MC;AAED,kBAAe,oBAAoB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Compiler from 'webpack/lib/Compiler';
|
|
2
2
|
import { container } from 'webpack';
|
|
3
3
|
import type { ModuleFederationPluginOptions, SharedObject } from '@module-federation/utilities';
|
|
4
4
|
type ConstructableModuleFederationPlugin = new (options: ModuleFederationPluginOptions) => container.ModuleFederationPlugin;
|
|
@@ -10,25 +10,31 @@ type ConstructableModuleFederationPlugin = new (options: ModuleFederationPluginO
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function getModuleFederationPluginConstructor(isServer: boolean, compiler: Compiler): ConstructableModuleFederationPlugin;
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@
|
|
16
|
-
@returns The default share scope based on the environment.
|
|
13
|
+
* Set up default shared values based on the environment.
|
|
14
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
15
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
17
16
|
*/
|
|
18
17
|
export declare const retrieveDefaultShared: (isServer: boolean) => SharedObject;
|
|
19
18
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@param {
|
|
29
|
-
|
|
30
|
-
@param {Compiler} compiler - The Webpack compiler instance.
|
|
19
|
+
* Apply remote delegates.
|
|
20
|
+
*
|
|
21
|
+
* This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look
|
|
22
|
+
* for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader.
|
|
23
|
+
* Once loaded, it will then look for the available delegates that will be used to configure the remote
|
|
24
|
+
* that the hoisted module will be dependent upon.
|
|
25
|
+
*
|
|
26
|
+
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
27
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
31
28
|
*/
|
|
32
29
|
export declare function applyRemoteDelegates(options: ModuleFederationPluginOptions, compiler: Compiler): void;
|
|
33
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Apply path fixes.
|
|
32
|
+
*
|
|
33
|
+
* This function applies fixes to the path for certain loaders. It checks if the fix is enabled in the options
|
|
34
|
+
* and if the loader is present in the rule. If both conditions are met, it injects the fix loader.
|
|
35
|
+
*
|
|
36
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
37
|
+
* @param {any} options - The ModuleFederationPluginOptions instance.
|
|
38
|
+
*/
|
|
39
|
+
export declare const applyPathFixes: (compiler: Compiler, options: any) => void;
|
|
34
40
|
export {};
|