@module-federation/nextjs-mf 6.4.0 → 6.4.1-beta.1
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 +111 -0
- package/README.md +3 -0
- package/package.json +4 -4
- package/src/default-delegate.d.ts +2 -0
- package/src/default-delegate.js +17 -0
- package/src/default-delegate.js.map +1 -0
- package/src/delegate-hoist-container.d.ts +0 -0
- package/src/delegate-hoist-container.js +2 -0
- package/src/delegate-hoist-container.js.map +1 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +6 -5
- package/src/index.js.map +1 -1
- package/src/internal-delegate-hoist.js +1 -0
- package/src/internal-delegate-hoist.js.map +1 -1
- package/src/internal.d.ts +39 -9
- package/src/internal.js +149 -235
- package/src/internal.js.map +1 -1
- package/src/inverse-self-formation.d.ts +0 -0
- package/src/inverse-self-formation.js +2 -0
- package/src/inverse-self-formation.js.map +1 -0
- package/src/loaders/async-boundary-loader.js +10 -2
- package/src/loaders/async-boundary-loader.js.map +1 -1
- package/src/loaders/delegateLoader.js +2 -4
- package/src/loaders/delegateLoader.js.map +1 -1
- package/src/loaders/inject-hoist.d.ts +3 -0
- package/src/loaders/inject-hoist.js +8 -0
- package/src/loaders/inject-hoist.js.map +1 -0
- package/src/loaders/nextPageMapLoader.js +0 -2
- package/src/loaders/nextPageMapLoader.js.map +1 -1
- package/src/loaders/share-scope-hoist.d.ts +5 -0
- package/src/loaders/share-scope-hoist.js +52 -0
- package/src/loaders/share-scope-hoist.js.map +1 -0
- package/src/plugins/AddModulesToRuntime.d.ts +19 -0
- package/src/plugins/AddModulesToRuntime.js +268 -0
- package/src/plugins/AddModulesToRuntime.js.map +1 -0
- package/src/plugins/ContainerStatsPlugin.d.ts +6 -0
- package/src/plugins/ContainerStatsPlugin.js +176 -0
- package/src/plugins/ContainerStatsPlugin.js.map +1 -0
- package/src/plugins/CopyFederationPlugin.d.ts +7 -0
- package/src/plugins/CopyFederationPlugin.js +48 -0
- package/src/plugins/CopyFederationPlugin.js.map +1 -0
- package/src/plugins/NextFederationPlugin/apply-automatic-async-boundary.d.ts +11 -0
- package/src/plugins/NextFederationPlugin/apply-automatic-async-boundary.js +61 -0
- package/src/plugins/NextFederationPlugin/apply-automatic-async-boundary.js.map +1 -0
- package/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +24 -0
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js +79 -0
- package/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
- package/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +61 -0
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js +158 -0
- package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
- package/src/plugins/NextFederationPlugin/index.d.ts +18 -0
- package/src/plugins/NextFederationPlugin/index.js +133 -0
- package/src/plugins/NextFederationPlugin/index.js.map +1 -0
- package/src/plugins/NextFederationPlugin/next-fragments.d.ts +44 -0
- package/src/plugins/NextFederationPlugin/next-fragments.js +115 -0
- package/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
- package/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
- package/src/plugins/NextFederationPlugin/regex-equal.js +25 -0
- package/src/plugins/NextFederationPlugin/regex-equal.js.map +1 -0
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +1 -0
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +20 -0
- package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -0
- package/src/plugins/NextFederationPlugin/set-options.d.ts +21 -0
- package/src/plugins/NextFederationPlugin/set-options.js +35 -0
- package/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
- package/src/plugins/NextFederationPlugin/validate-options.d.ts +26 -0
- package/src/plugins/NextFederationPlugin/validate-options.js +46 -0
- package/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
- package/src/plugins/async-pages-loader.d.ts +1 -0
- package/src/plugins/async-pages-loader.js +41 -0
- package/src/plugins/async-pages-loader.js.map +1 -0
- package/src/plugins/container/InvertedContainerPlugin.d.ts +25 -0
- package/src/plugins/container/InvertedContainerPlugin.js +73 -0
- package/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
- package/src/plugins/container/InvertedContainerRuntimeModule.d.ts +42 -0
- package/src/plugins/container/InvertedContainerRuntimeModule.js +82 -0
- package/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
- package/src/plugins/container/types.d.ts +2 -0
- package/src/plugins/container/types.js +3 -0
- package/src/plugins/container/types.js.map +1 -0
- package/utils/Template.d.ts +1 -1
- package/utils/Template.js +1 -1
- package/utils/Template.js.map +1 -1
- package/utils/build-utils.d.ts +0 -8
- package/utils/build-utils.js +1 -228
- package/utils/build-utils.js.map +1 -1
- package/utils/index.d.ts +2 -2
- package/utils/index.js +8 -2
- package/utils/index.js.map +1 -1
- package/src/plugins/ChildFederationPlugin.d.ts +0 -11
- package/src/plugins/ChildFederationPlugin.js +0 -299
- package/src/plugins/ChildFederationPlugin.js.map +0 -1
- package/src/plugins/ModuleFederationPlugin.d.ts +0 -7
- package/src/plugins/ModuleFederationPlugin.js +0 -50
- package/src/plugins/ModuleFederationPlugin.js.map +0 -1
- package/src/plugins/NextFederationPlugin.d.ts +0 -9
- package/src/plugins/NextFederationPlugin.js +0 -234
- package/src/plugins/NextFederationPlugin.js.map +0 -1
- package/src/plugins/RemoveRRRuntimePlugin.d.ts +0 -5
- package/src/plugins/RemoveRRRuntimePlugin.js +0 -40
- package/src/plugins/RemoveRRRuntimePlugin.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Requires either the default delegate module or a custom one
|
|
5
|
+
*/
|
|
6
|
+
function patchDefaultSharedLoader(content) {
|
|
7
|
+
if (content.includes('hasShareHoist')) {
|
|
8
|
+
return content;
|
|
9
|
+
}
|
|
10
|
+
const { shared } = this.getOptions();
|
|
11
|
+
const eagerShared = buildEagerShared(shared);
|
|
12
|
+
const shareScopes = buildShareScopes(eagerShared.scope);
|
|
13
|
+
const result = [
|
|
14
|
+
"console.log('initializing internal-module-hoist for:', __webpack_runtime_id__)",
|
|
15
|
+
shareScopes,
|
|
16
|
+
eagerShared.sideload,
|
|
17
|
+
'//hasShareHoist',
|
|
18
|
+
content,
|
|
19
|
+
].join('\n');
|
|
20
|
+
// Cache the generated result
|
|
21
|
+
this.cacheable?.();
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
exports.default = patchDefaultSharedLoader;
|
|
25
|
+
function buildEagerShared(shared) {
|
|
26
|
+
if (!shared) {
|
|
27
|
+
return { scope: '', sideload: '' };
|
|
28
|
+
}
|
|
29
|
+
return Object.entries(shared).reduce((acc, [name, params]) => {
|
|
30
|
+
if (params.eager === true && params.import === false) {
|
|
31
|
+
acc.scope += `
|
|
32
|
+
${JSON.stringify(name)}: {
|
|
33
|
+
"0": {
|
|
34
|
+
eager: true,
|
|
35
|
+
loaded: true,
|
|
36
|
+
get: () => () => require(${JSON.stringify('!!' + name + '?pop')}),
|
|
37
|
+
}
|
|
38
|
+
},`;
|
|
39
|
+
acc.sideload += `
|
|
40
|
+
__webpack_modules__[require.resolveWeak(${JSON.stringify(name)})] = __webpack_modules__[require.resolveWeak(${JSON.stringify('!!' + name + '?pop')})];
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, { scope: '', sideload: '' });
|
|
45
|
+
}
|
|
46
|
+
function buildShareScopes(eagerSharedScope) {
|
|
47
|
+
return `
|
|
48
|
+
const eager = {${eagerSharedScope}};
|
|
49
|
+
Object.assign(__webpack_share_scopes__.default || {}, eager);
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=share-scope-hoist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-scope-ho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,CACL,gDAAgD,IAAI,CAAC,SAAS,CAC7D,IAAI,GAAG,IAAI,GAAG,MAAM,CACrB;SACA,CAAC;SACH;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAC5B,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,gBAAwB;IAChD,OAAO;mBACU,gBAAgB;;GAEhC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default AddModulesToRuntimeChunkPlugin;
|
|
2
|
+
/**
|
|
3
|
+
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
4
|
+
* @class AddModulesToRuntimeChunkPlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class AddModulesToRuntimeChunkPlugin {
|
|
7
|
+
constructor(options: any);
|
|
8
|
+
options: any;
|
|
9
|
+
_delegateModules: Set<any>;
|
|
10
|
+
_eagerModules: Set<any>;
|
|
11
|
+
getChunkByName(chunks: any, name: any): any;
|
|
12
|
+
resolveSharedModules(compilation: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Applies the plugin to the webpack compiler.
|
|
15
|
+
* @param {Object} compiler - The webpack compiler instance.
|
|
16
|
+
*/
|
|
17
|
+
apply(compiler: Object): void;
|
|
18
|
+
classifyModule(module: any, internalSharedModules: any, modulesToMove: any): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const DelegateModulesPlugin_1 = tslib_1.__importDefault(require("@module-federation/utilities/src/plugins/DelegateModulesPlugin"));
|
|
5
|
+
const webpack_1 = require("webpack");
|
|
6
|
+
/**
|
|
7
|
+
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
8
|
+
* @class AddModulesToRuntimeChunkPlugin
|
|
9
|
+
*/
|
|
10
|
+
class AddModulesToRuntimeChunkPlugin {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = { debug: false, ...options };
|
|
13
|
+
this._delegateModules = new Set();
|
|
14
|
+
this._eagerModules = new Set();
|
|
15
|
+
}
|
|
16
|
+
getChunkByName(chunks, name) {
|
|
17
|
+
for (const chunk of chunks) {
|
|
18
|
+
if (chunk.name == name) {
|
|
19
|
+
return chunk;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
resolveSharedModules(compilation) {
|
|
25
|
+
// Tap into the 'finish-modules' hook to access the module list after they are all processed
|
|
26
|
+
compilation.hooks.finishModules.tapAsync('AddModulesToRuntimeChunkPlugin', (modules, callback) => {
|
|
27
|
+
const { shared } = this.options;
|
|
28
|
+
if (shared) {
|
|
29
|
+
const shareKey = Object.keys(shared);
|
|
30
|
+
for (const module of modules) {
|
|
31
|
+
if (shareKey.some((share) => {
|
|
32
|
+
if (module?.rawRequest === share) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
else if (share.endsWith('/')) {
|
|
36
|
+
return module?.rawRequest?.startsWith(share);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
})) {
|
|
42
|
+
this._sharedModules.add(module);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
callback();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Applies the plugin to the webpack compiler.
|
|
51
|
+
* @param {Object} compiler - The webpack compiler instance.
|
|
52
|
+
*/
|
|
53
|
+
apply(compiler) {
|
|
54
|
+
// Check if the target is the server
|
|
55
|
+
const isServer = compiler.options.name === 'server';
|
|
56
|
+
const { runtime, container, remotes, shared, eager, applicationName } = this.options;
|
|
57
|
+
new DelegateModulesPlugin_1.default({
|
|
58
|
+
runtime,
|
|
59
|
+
container,
|
|
60
|
+
remotes,
|
|
61
|
+
}).apply(compiler);
|
|
62
|
+
//TODO: investigate further and see if this can be used to add async boundries
|
|
63
|
+
// if (
|
|
64
|
+
// compiler.options.mode === 'development' &&
|
|
65
|
+
// typeof compiler.options.entry === 'function' &&
|
|
66
|
+
// !isServer
|
|
67
|
+
// ) {
|
|
68
|
+
// const backupEntries = compiler.options.entry;
|
|
69
|
+
// compiler.options.entry = () =>
|
|
70
|
+
// backupEntries().then((entries) => {
|
|
71
|
+
// //loop over object with for
|
|
72
|
+
// if (entries) {
|
|
73
|
+
// for (const [key, value] of Object.entries(entries)) {
|
|
74
|
+
// if (key === 'main') {
|
|
75
|
+
// value.import[0] =
|
|
76
|
+
// require.resolve('./async-pages-loader') +
|
|
77
|
+
// '!' +
|
|
78
|
+
// value.import[0];
|
|
79
|
+
// }
|
|
80
|
+
// if (key === 'pages/_app') {
|
|
81
|
+
// value.import[1] =
|
|
82
|
+
// require.resolve('./async-pages-loader') +
|
|
83
|
+
// '!' +
|
|
84
|
+
// value.import[1];
|
|
85
|
+
// }
|
|
86
|
+
// if (value.import[0].startsWith('next-client-pages-loader')) {
|
|
87
|
+
// value.import[0] =
|
|
88
|
+
// require.resolve('./async-pages-loader') +
|
|
89
|
+
// '!' +
|
|
90
|
+
// value.import[0];
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// return entries;
|
|
95
|
+
// });
|
|
96
|
+
// }
|
|
97
|
+
// Tap into compilation hooks
|
|
98
|
+
// compiler.hooks.compilation.tap(
|
|
99
|
+
// 'AddModulesToRuntimeChunkPlugin',
|
|
100
|
+
// (compilation) => {
|
|
101
|
+
// // Tap into optimizeChunks hook
|
|
102
|
+
// compilation.hooks.optimizeChunks.tap(
|
|
103
|
+
// 'AddModulesToRuntimeChunkPlugin',
|
|
104
|
+
// (chunks) => {
|
|
105
|
+
// return;
|
|
106
|
+
// // Get the runtime chunk and return if it's not found or has no runtime
|
|
107
|
+
// const mainChunk = this.getChunkByName(chunks, 'main');
|
|
108
|
+
// const runtimeChunk = this.getChunkByName(chunks, 'webpack');
|
|
109
|
+
// const container = this.getChunkByName(
|
|
110
|
+
// chunks,
|
|
111
|
+
// this.options.container
|
|
112
|
+
// );
|
|
113
|
+
//
|
|
114
|
+
// if (container && !isServer) {
|
|
115
|
+
// compilation.chunkGraph
|
|
116
|
+
// .getChunkModulesIterable(container)
|
|
117
|
+
// .forEach((module) => {
|
|
118
|
+
// if (
|
|
119
|
+
// // module.type === 'provide-module' ||
|
|
120
|
+
// module.type === 'javascript/auto'
|
|
121
|
+
// ) {
|
|
122
|
+
// compilation.chunkGraph.disconnectChunkAndModule(
|
|
123
|
+
// container,
|
|
124
|
+
// module
|
|
125
|
+
// );
|
|
126
|
+
// return;
|
|
127
|
+
// }
|
|
128
|
+
//
|
|
129
|
+
// // console.log(module.identifier(), module.type);
|
|
130
|
+
// });
|
|
131
|
+
// }
|
|
132
|
+
//
|
|
133
|
+
// for (const chunk of chunks) {
|
|
134
|
+
// if (!isServer) {
|
|
135
|
+
// for (const module of chunk.modulesIterable) {
|
|
136
|
+
// if (
|
|
137
|
+
// module.identifier().includes('webpack/runtime') ||
|
|
138
|
+
// module.identifier().includes('webpack/runtime')
|
|
139
|
+
// // chunk.debugId !== runtimeChunk.debugId
|
|
140
|
+
// ) {
|
|
141
|
+
// console.log(
|
|
142
|
+
// 'already in runtime',
|
|
143
|
+
// module.identifier(),
|
|
144
|
+
// chunk.debugId,
|
|
145
|
+
// runtimeChunk.debugId
|
|
146
|
+
// );
|
|
147
|
+
//
|
|
148
|
+
// // compilation.chunkGraph.disconnectChunkAndModule(
|
|
149
|
+
// // chunk,
|
|
150
|
+
// // module
|
|
151
|
+
// // );
|
|
152
|
+
// }
|
|
153
|
+
// }
|
|
154
|
+
// }
|
|
155
|
+
// }
|
|
156
|
+
//
|
|
157
|
+
// return;
|
|
158
|
+
//
|
|
159
|
+
// if (!runtimeChunk || !runtimeChunk.hasRuntime()) return;
|
|
160
|
+
// return;
|
|
161
|
+
// // Get the container chunk if specified
|
|
162
|
+
// const partialEntry = container
|
|
163
|
+
// ? this.getChunkByName(chunks, container)
|
|
164
|
+
// : null;
|
|
165
|
+
//
|
|
166
|
+
// // Get the shared module names to their imports if specified
|
|
167
|
+
// const internalSharedModules = shared
|
|
168
|
+
// ? Object.entries(shared).map(
|
|
169
|
+
// ([key, value]) => value.import || key
|
|
170
|
+
// )
|
|
171
|
+
// : null;
|
|
172
|
+
//
|
|
173
|
+
// // Get the modules of the container chunk if specified
|
|
174
|
+
// const partialContainerModules = partialEntry
|
|
175
|
+
// ? compilation.chunkGraph.getOrderedChunkModulesIterable(
|
|
176
|
+
// partialEntry
|
|
177
|
+
// )
|
|
178
|
+
// : null;
|
|
179
|
+
//
|
|
180
|
+
// const foundChunks = chunks.filter((chunk) => {
|
|
181
|
+
// const hasMatch = chunk !== runtimeChunk;
|
|
182
|
+
// return (
|
|
183
|
+
// hasMatch &&
|
|
184
|
+
// applicationName &&
|
|
185
|
+
// (chunk.name || chunk.id)?.startsWith(applicationName)
|
|
186
|
+
// );
|
|
187
|
+
// });
|
|
188
|
+
//
|
|
189
|
+
// // Iterate over each chunk
|
|
190
|
+
// for (const chunk of foundChunks) {
|
|
191
|
+
// const modulesToMove = [];
|
|
192
|
+
// const containers = [];
|
|
193
|
+
// const modulesIterable =
|
|
194
|
+
// compilation.chunkGraph.getOrderedChunkModulesIterable(chunk);
|
|
195
|
+
// for (const module of modulesIterable) {
|
|
196
|
+
// this.classifyModule(
|
|
197
|
+
// module,
|
|
198
|
+
// internalSharedModules,
|
|
199
|
+
// modulesToMove,
|
|
200
|
+
// containers
|
|
201
|
+
// );
|
|
202
|
+
// }
|
|
203
|
+
//
|
|
204
|
+
// if (partialContainerModules) {
|
|
205
|
+
// for (const module of partialContainerModules) {
|
|
206
|
+
// const destinationArray = module.rawRequest
|
|
207
|
+
// ? modulesToMove
|
|
208
|
+
// : containers;
|
|
209
|
+
// destinationArray.push(module);
|
|
210
|
+
// }
|
|
211
|
+
// }
|
|
212
|
+
//
|
|
213
|
+
// const modulesToConnect = [].concat(modulesToMove, containers);
|
|
214
|
+
//
|
|
215
|
+
// const { chunkGraph } = compilation;
|
|
216
|
+
// const runtimeChunkModules =
|
|
217
|
+
// chunkGraph.getOrderedChunkModulesIterable(runtimeChunk);
|
|
218
|
+
//
|
|
219
|
+
// for (const module of modulesToConnect) {
|
|
220
|
+
// if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {
|
|
221
|
+
// chunkGraph.connectChunkAndModule(runtimeChunk, module);
|
|
222
|
+
// }
|
|
223
|
+
//
|
|
224
|
+
// if (eager && modulesToMove.includes(module)) {
|
|
225
|
+
// if (this.options.debug) {
|
|
226
|
+
// console.log(
|
|
227
|
+
// `removing ${module.id || module.identifier()} from ${
|
|
228
|
+
// chunk.name || chunk.id
|
|
229
|
+
// } to ${runtimeChunk.name}`
|
|
230
|
+
// );
|
|
231
|
+
// }
|
|
232
|
+
// chunkGraph.disconnectChunkAndModule(chunk, module);
|
|
233
|
+
// }
|
|
234
|
+
// }
|
|
235
|
+
//
|
|
236
|
+
// for (const module of runtimeChunkModules) {
|
|
237
|
+
// if (!chunkGraph.isModuleInChunk(module, chunk)) {
|
|
238
|
+
// if (this._delegateModules.has(module)) {
|
|
239
|
+
// chunkGraph.connectChunkAndModule(chunk, module);
|
|
240
|
+
// if (this.options.debug) {
|
|
241
|
+
// console.log(
|
|
242
|
+
// `adding ${module.rawRequest} to ${chunk.name} from ${runtimeChunk.name} not removing it`
|
|
243
|
+
// );
|
|
244
|
+
// }
|
|
245
|
+
// }
|
|
246
|
+
// }
|
|
247
|
+
// }
|
|
248
|
+
// }
|
|
249
|
+
// }
|
|
250
|
+
// );
|
|
251
|
+
// }
|
|
252
|
+
// );
|
|
253
|
+
}
|
|
254
|
+
classifyModule(module, internalSharedModules, modulesToMove) {
|
|
255
|
+
if (
|
|
256
|
+
//TODO: do the same for shared modules, resolve them in the afterFinishModules hook
|
|
257
|
+
internalSharedModules?.some((share) => module?.rawRequest?.includes(share))) {
|
|
258
|
+
// modulesToMove.push(module);
|
|
259
|
+
}
|
|
260
|
+
else if (module?.userRequest?.includes('internal-delegate-hoist')) {
|
|
261
|
+
// TODO: can probably move the whole classification part to afterFinishModules,
|
|
262
|
+
// track all modules i want to move, then just search the chunks
|
|
263
|
+
// modulesToMove.push(module);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.default = AddModulesToRuntimeChunkPlugin;
|
|
268
|
+
//# sourceMappingURL=AddModulesToRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddModulesToRuntime.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/plugins/AddModulesToRuntime.js"],"names":[],"mappings":";;;AAAA,mIAAmG;AACnG,qCAAgC;AAChC;;;GAGG;AACH,MAAM,8BAA8B;IAClC,YAAY,OAAO;QACjB,IAAI,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,cAAc,CAAC,MAAM,EAAE,IAAI;QACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,oBAAoB,CAAC,WAAW;QAC9B,4FAA4F;QAC5F,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CACtC,gCAAgC,EAChC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACpB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAEhC,IAAI,MAAM,EAAE;gBACV,MAAM,QA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AAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CACpC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CACpC,EACD;YACA,8BAA8B;SAC/B;aAAM,IAAI,MAAM,EAAE,WAAW,EAAE,QAAQ,CAAC,yBAAyB,CAAC,EAAE;YACnE,+EAA+E;YAC/E,iEAAiE;YACjE,8BAA8B;SAC/B;IACH,CAAC;CACF;AAED,kBAAe,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require('path');
|
|
4
|
+
class ModuleChunkDependencyPlugin {
|
|
5
|
+
constructor(federationOptions) {
|
|
6
|
+
this.federationOptions = federationOptions;
|
|
7
|
+
}
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
compiler.hooks.emit.tapAsync('ModuleChunkInfoPlugin', (compilation, callback) => {
|
|
10
|
+
const moduleChunkInfo = {};
|
|
11
|
+
compilation.chunks.forEach((chunk) => {
|
|
12
|
+
chunk.getModules().forEach((module) => {
|
|
13
|
+
if (module?.request?.includes('menu.tsx')) {
|
|
14
|
+
const identifier = module.identifier();
|
|
15
|
+
const relativePath = path.relative(compiler.context, identifier);
|
|
16
|
+
if (!moduleChunkInfo[relativePath]) {
|
|
17
|
+
moduleChunkInfo[relativePath] = [];
|
|
18
|
+
}
|
|
19
|
+
moduleChunkInfo[relativePath].push(chunk.id);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
console.log('moduleChunkInfo', moduleChunkInfo);
|
|
24
|
+
// const jsonContent = JSON.stringify(moduleChunkInfo, null, 2);
|
|
25
|
+
// compilation.assets[this.outputFile] = {
|
|
26
|
+
// source: () => jsonContent,
|
|
27
|
+
// size: () => jsonContent.length,
|
|
28
|
+
// };
|
|
29
|
+
callback();
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
// eslint-disable-next-line no-unreachable
|
|
33
|
+
compiler.hooks.afterEmit.tapAsync('ModuleChunkDependencyPlugin', (compilation, callback) => {
|
|
34
|
+
const { entrypoints, chunkGraph } = compilation;
|
|
35
|
+
const container = entrypoints.get(this.federationOptions.name);
|
|
36
|
+
const entryChunk = container.getEntrypointChunk();
|
|
37
|
+
const modulesInChunk = chunkGraph.getChunkModulesIterable(entryChunk);
|
|
38
|
+
const gotChunks = chunkGraph.getChunkModules(entryChunk);
|
|
39
|
+
const findExposed = gotChunks.find((module) => {
|
|
40
|
+
return module._exposes;
|
|
41
|
+
});
|
|
42
|
+
const containerChunk = findExposed.getChunks().find((chunk) => {
|
|
43
|
+
return chunk.name === this.federationOptions.name;
|
|
44
|
+
});
|
|
45
|
+
if (!containerChunk)
|
|
46
|
+
return;
|
|
47
|
+
// console.log('entryChunk',entryChunk);
|
|
48
|
+
// console.log('gotChunks', gotChunks)
|
|
49
|
+
// console.log('modulesInChunk', modulesInChunk);
|
|
50
|
+
// console.log('containerChunk',containerChunk)
|
|
51
|
+
// console.log('getChunkMaps',containerChunk.getChunkMaps())
|
|
52
|
+
// console.log('getAllReferencedChunks',containerChunk.getAllReferencedChunks())
|
|
53
|
+
const referencedChunks = containerChunk.getAllReferencedChunks();
|
|
54
|
+
console.log(referencedChunks);
|
|
55
|
+
// console.log(referencedChunks);
|
|
56
|
+
// referencedChunks.forEach((chunk) => {
|
|
57
|
+
// console.log(chunk.id, chunk.getModules());
|
|
58
|
+
// })
|
|
59
|
+
// const moduleMap = containerChunk.getChunkModuleMaps((module) => {
|
|
60
|
+
// return module.id
|
|
61
|
+
// });
|
|
62
|
+
// console.log(moduleMap)
|
|
63
|
+
// console.log('getChunkModuleMaps',containerChunk.getChunkModuleMaps((module) => {
|
|
64
|
+
// console.log(module.id, module.rawRequest)
|
|
65
|
+
// }))
|
|
66
|
+
// console.log('findExposed',findExposed)
|
|
67
|
+
// console.log('getchunks', containerChunk);
|
|
68
|
+
// console.log('getChunkModules', chunkGraph.getChunkModules(containerChunk));
|
|
69
|
+
// console.log('getModuleChunks', chunkGraph.getModuleChunks(findExposed));
|
|
70
|
+
const moduleChunkDependencyMap = {};
|
|
71
|
+
const swappedExposes = Object.entries(this.federationOptions.exposes).reduce((acc, [key, value]) => {
|
|
72
|
+
acc[value] = key;
|
|
73
|
+
return acc;
|
|
74
|
+
}, {});
|
|
75
|
+
const exposesEntries = Object.entries(swappedExposes);
|
|
76
|
+
// const chunkGraph = compilation.chunkGraph;
|
|
77
|
+
for (const module of compilation.modules) {
|
|
78
|
+
let exposedKey;
|
|
79
|
+
let exposedFile;
|
|
80
|
+
if (!exposesEntries.some(([exposedPath, exposedName]) => {
|
|
81
|
+
if (module.rawRequest &&
|
|
82
|
+
module.rawRequest.startsWith(exposedPath)) {
|
|
83
|
+
exposedKey = exposedName;
|
|
84
|
+
exposedFile = exposedPath;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
})) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const dependentChunksSet = new Set();
|
|
91
|
+
// module.dependencies.forEach((dependency) => {
|
|
92
|
+
// // console.log(dependency);
|
|
93
|
+
// let dependentModule =
|
|
94
|
+
// dependency?._parentModule?.rawRequest?.startsWith(exposedFile)
|
|
95
|
+
// ? dependency._parentModule
|
|
96
|
+
// : null;
|
|
97
|
+
//
|
|
98
|
+
// if (dependentModule) {
|
|
99
|
+
// const moduleChunks = Array.from(
|
|
100
|
+
// chunkGraph.getModuleChunks(dependentModule)
|
|
101
|
+
// );
|
|
102
|
+
// moduleChunks.forEach((chunk) => {
|
|
103
|
+
// if(exposedKey.includes('menu')) {
|
|
104
|
+
// console.log({
|
|
105
|
+
// hasRuntime: chunk.hasRuntime(),
|
|
106
|
+
// chunk,
|
|
107
|
+
// dependentModule,
|
|
108
|
+
// isIn: chunkGraph.isModuleInChunk(dependentModule, chunk)
|
|
109
|
+
// });
|
|
110
|
+
// }
|
|
111
|
+
// if (
|
|
112
|
+
// typeof chunk.runtime === 'string' &&
|
|
113
|
+
// chunk.runtime !== this.federationOptions.name
|
|
114
|
+
// ) {
|
|
115
|
+
// return;
|
|
116
|
+
// }
|
|
117
|
+
// if (
|
|
118
|
+
// !chunk.runtime.toJSON().includes(this.federationOptions.name)
|
|
119
|
+
// ) {
|
|
120
|
+
// return;
|
|
121
|
+
// }
|
|
122
|
+
// // if(exposedKey.includes('menu')) {
|
|
123
|
+
// // console.log('chunk',chunk)
|
|
124
|
+
// // }
|
|
125
|
+
// dependentChunksSet.add(chunk);
|
|
126
|
+
// });
|
|
127
|
+
// }
|
|
128
|
+
// });
|
|
129
|
+
// moduleChunkDependencyMap[exposedKey] = Array.from(dependentChunksSet);
|
|
130
|
+
const moduleId = chunkGraph.getModuleId(module);
|
|
131
|
+
if (module.request && module.request.includes('menu')) {
|
|
132
|
+
const containerd = Array.from(referencedChunks).filter((c) => {
|
|
133
|
+
return c.containsModule(module);
|
|
134
|
+
});
|
|
135
|
+
console.log({ containerd });
|
|
136
|
+
}
|
|
137
|
+
// console.log({req: module.request, getChunks:module.getChunks(), getModuleChunks: chunkGraph.getModuleChunks(module)});
|
|
138
|
+
// module.getChunks().forEach((chunk) => {
|
|
139
|
+
// console.log({req:module.request,chunk:chunk.id,containsModule:chunk.containsModule(module), module:chunkGraph.getChunkModules(chunk)})
|
|
140
|
+
//
|
|
141
|
+
// })
|
|
142
|
+
// console.log({getModuChunk:chunkGraph.getModuleChunks(module), referencedChunks})
|
|
143
|
+
const dependentChunks = Array.from(chunkGraph.getModuleChunks(module)).reduce((acc, chunk) => {
|
|
144
|
+
// console.log('has ref chunk',referencedChunks.has(chunk));
|
|
145
|
+
if (referencedChunks.has(chunk)
|
|
146
|
+
// chunk.runtime === this.federationOptions.name ||
|
|
147
|
+
// (chunk.runtime.toJSON && chunk.runtime.toJSON().includes(this.federationOptions.name))
|
|
148
|
+
) {
|
|
149
|
+
if (exposedKey === './menu') {
|
|
150
|
+
// console.log(chunk);
|
|
151
|
+
}
|
|
152
|
+
// console.log(chunk.files,chunk.runtime.toJSON().includes(this.federationOptions.name))
|
|
153
|
+
acc.push(...chunk.files);
|
|
154
|
+
}
|
|
155
|
+
return acc;
|
|
156
|
+
}, []);
|
|
157
|
+
// console.log(exposedKey, moduleId,chunkGraph.getModuleChunks(module));
|
|
158
|
+
moduleChunkDependencyMap[exposedKey] = dependentChunks;
|
|
159
|
+
}
|
|
160
|
+
console.log(moduleChunkDependencyMap);
|
|
161
|
+
// const jsonOutput = JSON.stringify(moduleChunkDependencyMap, null, 2);
|
|
162
|
+
// console.log(jsonOutput);
|
|
163
|
+
// callback()
|
|
164
|
+
// fs.writeFile(this.outputPath, jsonOutput, (err) => {
|
|
165
|
+
// if (err) {
|
|
166
|
+
// console.error('Error writing module chunk dependency JSON:', err);
|
|
167
|
+
// } else {
|
|
168
|
+
// console.log('Module chunk dependency JSON written successfully');
|
|
169
|
+
// }
|
|
170
|
+
callback();
|
|
171
|
+
// });
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.default = ModuleChunkDependencyPlugin;
|
|
176
|
+
//# sourceMappingURL=ContainerStatsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContainerStatsPlugin.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/plugins/ContainerStatsPlugin.js"],"names":[],"mappings":";;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,MAAM,2BAA2B;IAC/B,YAAY,iBAAiB;QAC3B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAC1B,uBAAuB,EACvB,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE;YACxB,MAAM,eAAe,GAAG,EAAE,CAAC;YAE3B,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC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E;wBAC3D,OAAO,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;oBAClC,CAAC,CAAC,CAAC;oBACH,OAAO,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;iBAC7B;gBACD,yHAAyH;gBACzH,0CAA0C;gBAC1C,2IAA2I;gBAC3I,EAAE;gBACF,KAAK;gBACL,mFAAmF;gBACnF,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAChC,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CACnC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;oBACtB,4DAA4D;oBAC5D,IACE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;oBAC3B,mDAAmD;oBACnD,yFAAyF;sBACzF;wBACA,IAAI,UAAU,KAAK,QAAQ,EAAE;4BAC3B,sBAAsB;yBACvB;wBACD,wFAAwF;wBACxF,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;qBAC1B;oBACD,OAAO,GAAG,CAAC;gBACb,CAAC,EAAE,EAAE,CAAC,CAAC;gBACP,wEAAwE;gBACxE,wBAAwB,CAAC,UAAU,CAAC,GAAG,eAAe,CAAC;aACxD;YAED,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;YAEtC,wEAAwE;YACxE,2BAA2B;YAC3B,aAAa;YACb,uDAAuD;YACvD,eAAe;YACf,yEAAyE;YACzE,aAAa;YACb,wEAAwE;YACxE,MAAM;YACN,QAAQ,EAAE,CAAC;YACX,MAAM;QACR,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
+
class CopyBuildOutputPlugin {
|
|
7
|
+
constructor(isServer) {
|
|
8
|
+
this.isServer = isServer;
|
|
9
|
+
}
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
const copyFiles = (source, destination) => {
|
|
12
|
+
const files = fs_1.default.readdirSync(source);
|
|
13
|
+
files.forEach((file) => {
|
|
14
|
+
const sourcePath = path_1.default.join(source, file);
|
|
15
|
+
const destinationPath = path_1.default.join(destination, file);
|
|
16
|
+
if (fs_1.default.lstatSync(sourcePath).isDirectory()) {
|
|
17
|
+
if (!fs_1.default.existsSync(destinationPath)) {
|
|
18
|
+
fs_1.default.mkdirSync(destinationPath);
|
|
19
|
+
}
|
|
20
|
+
copyFiles(sourcePath, destinationPath);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
fs_1.default.copyFileSync(sourcePath, destinationPath);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
compiler.hooks.afterEmit.tapAsync('CopyBuildOutputPlugin', (compilation, callback) => {
|
|
28
|
+
const { outputPath } = compiler;
|
|
29
|
+
const outputString = outputPath.split('.next')[0] + '.next';
|
|
30
|
+
const isProd = compiler.options.mode === 'production';
|
|
31
|
+
if (!isProd && !this.isServer) {
|
|
32
|
+
return callback();
|
|
33
|
+
}
|
|
34
|
+
const serverLoc = path_1.default.join(outputString, this.isServer && isProd ? '/ssr' : '/static/ssr');
|
|
35
|
+
const servingLoc = path_1.default.join(outputPath, 'ssr');
|
|
36
|
+
if (!fs_1.default.existsSync(serverLoc)) {
|
|
37
|
+
fs_1.default.mkdirSync(serverLoc, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
const sourcePath = this.isServer ? outputPath : servingLoc;
|
|
40
|
+
if (fs_1.default.existsSync(sourcePath)) {
|
|
41
|
+
copyFiles(sourcePath, serverLoc);
|
|
42
|
+
}
|
|
43
|
+
callback();
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.default = CopyBuildOutputPlugin;
|
|
48
|
+
//# sourceMappingURL=CopyFederationPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopyFederationPlugin.js","sourceRoot":"","sources":["../../../../../packages/nextjs-mf/src/plugins/CopyFederationPlugin.ts"],"names":[],"mappings":";;;AAAA,oDAAoB;AACpB,wDAAwB;AAGxB,MAAM,qBAAqB;IAGzB,YAAY,QAAiB;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,WAAmB,EAAQ,EAAE;YAC9D,MAAM,KAAK,GAAG,YAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAErC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBACrB,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC3C,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAErD,IAAI,YAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,EAAE;oBAC1C,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;wBACnC,YAAE,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;qBAC/B;oBACD,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;iBACxC;qBAAM;oBACL,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;iBAC9C;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAC/B,uBAAuB,EACvB,CAAC,WAAwB,EAAE,QAAoB,EAAE,EAAE;YACjD,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;YAChC,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;YAC5D,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC;YAEtD,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAC7B,OAAO,QAAQ,EAAE,CAAC;aACnB;YAED,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CACzB,YAAY,EACZ,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CACjD,CAAC;YACF,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAEhD,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAC7B,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC9C;YAED,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;YAC3D,IAAI,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAC7B,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;aAClC;YACD,QAAQ,EAAE,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ModuleFederationPluginOptions, NextFederationPluginExtraOptions } from '@module-federation/utilities';
|
|
2
|
+
import { Compiler } from 'webpack';
|
|
3
|
+
/**
|
|
4
|
+
|
|
5
|
+
Apply automatic async boundary.
|
|
6
|
+
@param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
7
|
+
@param {NextFederationPluginExtraOptions} extraOptions - The NextFederationPluginExtraOptions instance.
|
|
8
|
+
@param {Compiler} compiler - The Webpack compiler instance.
|
|
9
|
+
@remarks This function applies an automatic async boundary to the Next.js application.
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyAutomaticAsyncBoundary(options: ModuleFederationPluginOptions, extraOptions: NextFederationPluginExtraOptions, compiler: Compiler): void;
|