@module-federation/nextjs-mf 8.2.6 → 8.3.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/README.md +56 -28
- package/dist/package.json +3 -4
- package/dist/src/internal.js +0 -70
- package/dist/src/internal.js.map +1 -1
- package/dist/src/loaders/fixImageLoader.js +0 -4
- package/dist/src/loaders/fixImageLoader.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +0 -2
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +2 -4
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
- package/dist/utils/index.d.ts +2 -5
- package/dist/utils/index.js +7 -6
- package/dist/utils/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/src/plugins/container/HoistPseudoEagerModules.d.ts +0 -19
- package/dist/src/plugins/container/HoistPseudoEagerModules.js +0 -79
- package/dist/src/plugins/container/HoistPseudoEagerModules.js.map +0 -1
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +0 -39
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -72
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
package/README.md
CHANGED
|
@@ -165,18 +165,12 @@ new NextFederationPlugin({
|
|
|
165
165
|
extraOptions: {
|
|
166
166
|
debug: boolean, // `false` by default
|
|
167
167
|
exposePages: boolean, // `false` by default
|
|
168
|
-
enableImageLoaderFix: boolean, // `false` by default
|
|
169
|
-
enableUrlLoaderFix: boolean, // `false` by default
|
|
170
|
-
skipSharingNextInternals: boolean, // `false` by default
|
|
171
168
|
},
|
|
172
169
|
});
|
|
173
170
|
```
|
|
174
171
|
|
|
175
172
|
- `debug` – enables debug mode. It will print additional information about what is going on under the hood.
|
|
176
173
|
- `exposePages` – exposes automatically all nextjs pages for you and theirs `./pages-map`.
|
|
177
|
-
- `enableImageLoaderFix` – adds public hostname to all assets bundled by `nextjs-image-loader`. So if you serve remoteEntry from `http://example.com` then all bundled assets will get this hostname in runtime. It's something like Base URL in HTML but for federated modules.
|
|
178
|
-
- `enableUrlLoaderFix` – adds public hostname to all assets bundled by `url-loader`.
|
|
179
|
-
- `skipSharingNextInternals` – disables sharing of next internals. You can use it if you want to share next internals yourself or want to use this plugin on non next applications
|
|
180
174
|
|
|
181
175
|
## Demo
|
|
182
176
|
|
|
@@ -273,49 +267,62 @@ new NextFederationPlugin({
|
|
|
273
267
|
|
|
274
268
|
Ive added a util for dynamic chunk loading, in the event you need to load remote containers dynamically.
|
|
275
269
|
|
|
276
|
-
**InjectScript**
|
|
277
270
|
|
|
278
271
|
```js
|
|
279
|
-
import {
|
|
272
|
+
import { loadRemote, init } from '@module-federation/runtime';
|
|
280
273
|
// if i have remotes in my federation plugin, i can pass the name of the remote
|
|
281
|
-
|
|
282
|
-
remoteContainer.get('./exposedModule');
|
|
283
|
-
});
|
|
274
|
+
loadRemote('home/exposedModule')
|
|
284
275
|
// if i want to load a custom remote not known at build time.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
276
|
+
init({
|
|
277
|
+
name: 'hostname',
|
|
278
|
+
remotes: [
|
|
279
|
+
{
|
|
280
|
+
name: 'home',
|
|
281
|
+
entry: 'http://somthing.com/remoteEntry.js'
|
|
282
|
+
}
|
|
283
|
+
],
|
|
284
|
+
force: true // may be needed to sideload remotes after the fact.
|
|
285
|
+
})
|
|
286
|
+
loadRemote('home/exposedModule')
|
|
292
287
|
```
|
|
293
288
|
|
|
294
289
|
**revalidate**
|
|
290
|
+
### Hot Reloading with `revalidate` in Production Environments
|
|
291
|
+
|
|
292
|
+
In production environments, ensuring that your server can dynamically reload and update without requiring a full restart is crucial for maintaining uptime and providing the latest features to your users without disruption. The `revalidate` utility from `@module-federation/nextjs-mf/utils` facilitates this by enabling hot reloading of the node server (not the client). This section outlines two implementations for integrating `revalidate` into your Next.js application to leverage hot reloading capabilities.
|
|
293
|
+
|
|
294
|
+
#### Preferred Implementation: Blocking Updates Before Rendering
|
|
295
|
+
|
|
296
|
+
This implementation is recommended for most use cases as it helps avoid hydration errors by ensuring that the server and client are always in sync. By blocking and checking for updates before rendering, you can guarantee that your application is always up-to-date without negatively impacting the user experience.
|
|
295
297
|
|
|
296
|
-
|
|
297
|
-
This is recommended, without it - servers will not be able to pull remote updates without a full restart.
|
|
298
|
+
**How it Works:**
|
|
298
299
|
|
|
299
|
-
|
|
300
|
+
- **Before rendering the page**, the server checks if there are any updates available.
|
|
301
|
+
- **If updates are available**, it proceeds with Hot Module Replacement (HMR) before responding to the client request.
|
|
302
|
+
- **This method ensures** that all users receive the latest version of the application without encountering inconsistencies between the server-rendered and client-rendered content.
|
|
303
|
+
|
|
304
|
+
**Implementation Example:**
|
|
300
305
|
|
|
301
306
|
```js
|
|
302
307
|
// __document.js
|
|
303
308
|
|
|
304
309
|
import { revalidate } from '@module-federation/nextjs-mf/utils';
|
|
305
310
|
import Document, { Html, Head, Main, NextScript } from 'next/document';
|
|
311
|
+
|
|
306
312
|
class MyDocument extends Document {
|
|
307
313
|
static async getInitialProps(ctx) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
console.log('finished sending response', shouldUpdate);
|
|
314
|
+
if (ctx?.pathname && !ctx?.pathname?.endsWith('_error')) {
|
|
315
|
+
await revalidate().then((shouldUpdate) => {
|
|
316
|
+
if (shouldUpdate) {
|
|
317
|
+
console.log('Hot Module Replacement (HMR) activated', shouldUpdate);
|
|
318
|
+
}
|
|
314
319
|
});
|
|
315
|
-
}
|
|
320
|
+
}
|
|
316
321
|
|
|
322
|
+
const initialProps = await Document.getInitialProps(ctx);
|
|
317
323
|
return initialProps;
|
|
318
324
|
}
|
|
325
|
+
|
|
319
326
|
render() {
|
|
320
327
|
return (
|
|
321
328
|
<Html>
|
|
@@ -330,6 +337,27 @@ class MyDocument extends Document {
|
|
|
330
337
|
}
|
|
331
338
|
```
|
|
332
339
|
|
|
340
|
+
#### Stale Method: Post-Response Update Checks
|
|
341
|
+
|
|
342
|
+
While not recommended due to the potential for hydration errors, this method involves listening for the 'finish' event on the response object and then checking for updates. This could be useful in specific scenarios where updates can be applied less frequently or where immediate consistency between server and client is not as critical.
|
|
343
|
+
|
|
344
|
+
**How it Works:**
|
|
345
|
+
|
|
346
|
+
- **After responding to the client**, the server listens for the 'finish' event on the response object.
|
|
347
|
+
- **Once the response has been sent**, it checks for updates.
|
|
348
|
+
- **If updates are found**, it logs or acts upon these updates, although the updates will only apply to subsequent requests.
|
|
349
|
+
|
|
350
|
+
**Implementation Example:**
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
// Included in the `getInitialProps` method as shown in the preferred implementation
|
|
354
|
+
ctx?.res?.on('finish', () => {
|
|
355
|
+
revalidate().then((shouldUpdate) => {
|
|
356
|
+
console.log('Response sent, checking for updates:', shouldUpdate);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
333
361
|
## For Express.js
|
|
334
362
|
|
|
335
363
|
Hot reloading Express.js required additional steps: https://github.com/module-federation/universe/blob/main/packages/node/README.md
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/nextjs-mf",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -61,12 +61,11 @@
|
|
|
61
61
|
"schema-utils": "3.3.0",
|
|
62
62
|
"semver": "6.3.1",
|
|
63
63
|
"tapable": "2.2.1",
|
|
64
|
-
"terser-webpack-plugin": "5.3.10",
|
|
65
64
|
"upath": "2.0.1",
|
|
66
65
|
"url": "0.11.3",
|
|
67
66
|
"webpack-sources": "^3.2.3",
|
|
68
|
-
"@module-federation/managers": "0.
|
|
69
|
-
"@module-federation/manifest": "0.
|
|
67
|
+
"@module-federation/managers": "0.1.1",
|
|
68
|
+
"@module-federation/manifest": "0.1.1"
|
|
70
69
|
},
|
|
71
70
|
"peerDependencies": {
|
|
72
71
|
"next": "^12 || ^13 || ^14",
|
package/dist/src/internal.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toDisplayErrors = exports.getDelegates = exports.parseRemotes = exports.DEFAULT_SHARE_SCOPE_BROWSER = exports.DEFAULT_SHARE_SCOPE = void 0;
|
|
4
|
-
const enhanced_1 = require("@module-federation/enhanced");
|
|
5
4
|
/**
|
|
6
5
|
* @typedef SharedObject
|
|
7
6
|
* @type {object}
|
|
@@ -111,15 +110,6 @@ exports.DEFAULT_SHARE_SCOPE_BROWSER = Object.entries(exports.DEFAULT_SHARE_SCOPE
|
|
|
111
110
|
* @returns {boolean} - True if the value is an internal or promise delegate module reference, false otherwise.
|
|
112
111
|
*/
|
|
113
112
|
const isInternalOrPromise = (value) => ['internal ', 'promise '].some((prefix) => value.startsWith(prefix));
|
|
114
|
-
/**
|
|
115
|
-
* Checks if the remote value is using the standard remote syntax.
|
|
116
|
-
*
|
|
117
|
-
* @param {string} value - The remote value to check.
|
|
118
|
-
* @returns {boolean} - True if the value is using the standard remote syntax, false otherwise.
|
|
119
|
-
*/
|
|
120
|
-
const isStandardRemoteSyntax = (value) => {
|
|
121
|
-
return value.includes('@');
|
|
122
|
-
};
|
|
123
113
|
/**
|
|
124
114
|
* Parses the remotes object and checks if they are using a custom promise template or not.
|
|
125
115
|
* If it's a custom promise template, the remote syntax is parsed to get the module name and version number.
|
|
@@ -159,66 +149,6 @@ const isInternalDelegate = (value) => {
|
|
|
159
149
|
*/
|
|
160
150
|
const getDelegates = (remotes) => Object.entries(remotes).reduce((acc, [key, value]) => isInternalDelegate(value) ? { ...acc, [key]: value } : acc, {});
|
|
161
151
|
exports.getDelegates = getDelegates;
|
|
162
|
-
/**
|
|
163
|
-
* This function validates the type of the shared item and constructs a shared configuration object based on the item and key.
|
|
164
|
-
* If the item is identical to the key or if the item does not necessitate a specific version,
|
|
165
|
-
* the function returns an object with the import property set to the item.
|
|
166
|
-
* Otherwise, it returns an object with the import property set to the key and the requiredVersion property set to the item.
|
|
167
|
-
*
|
|
168
|
-
* @param {string | string[]} item - The shared item to be validated and used to construct the shared configuration object. It can be a string or an array of strings.
|
|
169
|
-
* @param {string} key - The key associated with the shared item.
|
|
170
|
-
* @returns {object} - The constructed shared configuration object.
|
|
171
|
-
* @throws {Error} - An error is thrown if the item type is not a string or an array of strings.
|
|
172
|
-
*/
|
|
173
|
-
const getSharedConfig = (item, key) => {
|
|
174
|
-
if (Array.isArray(item)) {
|
|
175
|
-
// This handles the case where item is an array
|
|
176
|
-
// Replace the following line with your actual logic
|
|
177
|
-
return item.map((i) => ({
|
|
178
|
-
import: i === key || !(0, enhanced_1.isRequiredVersion)(i) ? i : key,
|
|
179
|
-
requiredVersion: i === key || !(0, enhanced_1.isRequiredVersion)(i) ? undefined : i,
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
182
|
-
else if (typeof item === 'string') {
|
|
183
|
-
// Handle the case where item is a string
|
|
184
|
-
return {
|
|
185
|
-
import: item === key || !(0, enhanced_1.isRequiredVersion)(item) ? item : key,
|
|
186
|
-
requiredVersion: item === key || !(0, enhanced_1.isRequiredVersion)(item) ? undefined : item,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
throw new Error('Unexpected type in shared');
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Parses the share options from the provided ModuleFederationPluginOptions object and constructs a new object containing all shared configurations.
|
|
195
|
-
* This newly constructed object is then used as the value for the 'shared' property of the Module Federation Plugin Options.
|
|
196
|
-
* The function uses the 'parseOptions' utility function from webpack to parse the 'shared' property of the provided options object.
|
|
197
|
-
* The 'getSharedConfig' function is used as the 'config' argument for 'parseOptions' to construct the shared configuration object for each shared item.
|
|
198
|
-
* The 'item' argument for 'parseOptions' is a function that simply returns the item as it is.
|
|
199
|
-
* The function then reduces the parsed shared options into a new object with the shared configuration for each shared item.
|
|
200
|
-
*
|
|
201
|
-
* @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions object to parse the share options from.
|
|
202
|
-
* @returns {Record<string, SharedConfig>} - An object containing the shared configuration for each shared item.
|
|
203
|
-
*/
|
|
204
|
-
const parseShareOptions = (options) => {
|
|
205
|
-
if (!options.shared)
|
|
206
|
-
return options;
|
|
207
|
-
const sharedOptions = (0, enhanced_1.parseOptions)(options.shared, getSharedConfig, (item) => item);
|
|
208
|
-
return sharedOptions.reduce((acc, [key, options]) => {
|
|
209
|
-
acc[key] = {
|
|
210
|
-
import: options.import,
|
|
211
|
-
shareKey: options.shareKey || key,
|
|
212
|
-
shareScope: options.shareScope,
|
|
213
|
-
requiredVersion: options.requiredVersion,
|
|
214
|
-
strictVersion: options.strictVersion,
|
|
215
|
-
singleton: options.singleton,
|
|
216
|
-
packageName: options.packageName,
|
|
217
|
-
eager: options.eager,
|
|
218
|
-
};
|
|
219
|
-
return acc;
|
|
220
|
-
}, {});
|
|
221
|
-
};
|
|
222
152
|
/**
|
|
223
153
|
* Takes an error object and formats it into a displayable string.
|
|
224
154
|
* If the error object contains a stack trace, it is appended to the error message.
|
package/dist/src/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAiB;IAC/C,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CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -73,11 +73,7 @@ async function fixImageLoader(remaining) {
|
|
|
73
73
|
Template.indent([
|
|
74
74
|
'try {',
|
|
75
75
|
Template.indent([
|
|
76
|
-
`if(typeof document === 'undefined')`,
|
|
77
76
|
Template.indent(`return ${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : ''`),
|
|
78
|
-
`const path = (document.currentScript && document.currentScript.src) || new URL(${publicPath}).origin;`,
|
|
79
|
-
`const splitted = path.split('/_next')`,
|
|
80
|
-
`return splitted.length === 2 ? splitted[0] : '';`,
|
|
81
77
|
]),
|
|
82
78
|
'} catch (e) {',
|
|
83
79
|
Template.indent([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixImageLoader.js","sourceRoot":"","sources":["../../../src/loaders/fixImageLoader.ts"],"names":[],"mappings":";;;;;;AACA,0FAAqF;AACrF,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAC1B,IAAA,6CAAoB,EAAC,SAAS,CAAC,CACJ,CAAC;AAC9B,gDAAwB;AAExB;;;;;;;;;;;;;;;GAeG;AACI,KAAK,UAAU,cAAc,CAElC,SAAiB;IAEjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;IAC3D,YAAY;IACZ,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,cAAc,CAAC;IAE7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CACpC,GAAG,IAAI,CAAC,YAAY,+BAA+B,SAAS,EAAE,CAC/D,CAAC;IAEF,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAA2B,CAAC;IAErE,MAAM,mBAAmB,GAAG,QAAQ;QAClC,CAAC,CAAC,GAAG,QA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AK,CAAC,EAAE,EAAE;QACpB,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;YAClB,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpC,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,GAAG,CAAC,IAAI,CACN,GAAG,GAAG,qCAAqC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACnE,CAAC;YACF,OAAO,GAAG,CAAC;QACb,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7C,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAc,CACf,CAAC;IAEF,OAAO,QAAQ,CAAC,QAAQ,CAAC;QACvB,yCAAyC;QACzC,OAAO;QACP,QAAQ,CAAC,MAAM,CAAC,mCAAmC,mBAAmB,GAAG,CAAC;QAC1E,gBAAgB;QAChB,kBAAkB;QAClB,QAAQ,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9C,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AApGD,wCAoGC;AAED;;GAEG;AACU,QAAA,KAAK,GAAG,cAAc,CAAC"}
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.applyClientPlugins = void 0;
|
|
7
7
|
const node_1 = require("@module-federation/node");
|
|
8
8
|
const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
|
|
9
|
-
const enhanced_1 = require("@module-federation/enhanced");
|
|
10
9
|
/**
|
|
11
10
|
* Applies client-specific plugins.
|
|
12
11
|
*
|
|
@@ -34,7 +33,6 @@ function applyClientPlugins(compiler, options, extraOptions) {
|
|
|
34
33
|
compiler.options.output.publicPath = 'auto';
|
|
35
34
|
// Build will hang without this. Likely something in my plugin
|
|
36
35
|
compiler.options.optimization.splitChunks = undefined;
|
|
37
|
-
new enhanced_1.HoistContainerReferencesPlugin().apply(compiler);
|
|
38
36
|
// If automatic page stitching is enabled, add a new rule to the compiler's module rules
|
|
39
37
|
if (extraOptions.automaticPageStitching) {
|
|
40
38
|
console.warn('[nextjs-mf]', 'automatic page stitching is disabled in v7');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-client-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"names":[],"mappings":";;;;;;AAKA,kDAAiE;AACjE,mGAA2E;
|
|
1
|
+
{"version":3,"file":"apply-client-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"names":[],"mappings":";;;;;;AAKA,kDAAiE;AACjE,mGAA2E;AAE3E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC,EACtC,YAA8C;IAE9C,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC7B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAClC,YAAY;IACZ,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,GAAG,SAAS,CAAC;IAEtD,wFAAwF;IACxF,IAAI,YAAY,CAAC,sBAAsB,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,4CAA4C,CAAC,CAAC;IAC5E,CAAC;IAED,mDAAmD;IACnD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC7D,CAAC;IAED,6FAA6F;IAC7F,OAAO,CAAC,OAAO,GAAG;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI;KACL,CAAC;IAEF,qDAAqD;IACrD,IAAI,6BAAsB,CAAC;QACzB,QAAQ,EAAE;YACR,oCAAoC;YACpC,6BAA6B;SAC9B;QACD,YAAY;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,0DAA0D;IAC1D,IAAI,iCAAuB,CAAC;QAC1B,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,gBAAgB;QAC9B,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,OAAO,EAAE,OAAO,CAAC,OAAiC;QAClD,MAAM,EAAE,OAAO,CAAC,MAAa;QAC7B,UAAU,EAAE,SAAS;QACrB,OAAO,EAAE,OAAO,CAAC,OAAc;QAC/B,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,YAAY;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AAjDD,gDAiDC"}
|
|
@@ -4,10 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.configureServerCompilerOptions = exports.handleServerExternals = exports.configureServerLibraryAndFilename = exports.applyServerPlugins = void 0;
|
|
7
|
-
const enhanced_1 = require("@module-federation/enhanced");
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
|
|
10
|
-
const
|
|
9
|
+
const enhanced_1 = require("@module-federation/enhanced");
|
|
11
10
|
/**
|
|
12
11
|
* This function applies server-specific plugins to the webpack compiler.
|
|
13
12
|
*
|
|
@@ -29,10 +28,9 @@ function applyServerPlugins(compiler, options) {
|
|
|
29
28
|
}
|
|
30
29
|
// Hoist container references into runtime chunks
|
|
31
30
|
//@ts-ignore
|
|
32
|
-
new enhanced_1.HoistContainerReferencesPlugin().apply(compiler);
|
|
33
31
|
// Add the StreamingTargetPlugin with the ModuleFederationPlugin from the webpack container
|
|
34
32
|
new StreamingTargetPlugin(options, {
|
|
35
|
-
ModuleFederationPlugin:
|
|
33
|
+
ModuleFederationPlugin: enhanced_1.ModuleFederationPlugin,
|
|
36
34
|
}).apply(compiler);
|
|
37
35
|
// Add a new commonjs chunk loading plugin to the compiler
|
|
38
36
|
new InvertedContainerPlugin_1.default({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAwB;AACxB,mGAA2E;AAC3E,0DAAqE;AACrE;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC;IAEtC,gEAAgE;IAChE,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrE,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC;IAC9D,MAAM,UAAU,GAAG,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IACzE,IACE,OAAO,aAAa,KAAK,QAAQ;QACjC,UAAU;QACV,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,CAAC,EACnC,CAAC;QACD,MAAM,MAAM,GAAG,iBAAiB,CAAC;QACjC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,GAAG,aAAa,CAAC,OAAO,CAC3D,KAAK,EACL,MAAM,CACP,CAAC;IACJ,CAAC;IACD,iDAAiD;IACjD,YAAY;IAEZ,2FAA2F;IAC3F,IAAI,qBAAqB,CAAC,OAAO,EAAE;QACjC,sBAAsB,EAAE,iCAAsB;KAC/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,CAAC;AA3DD,sDA2DC;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimePlugin.js","sourceRoot":"","sources":["../../../../src/plugins/container/runtimePlugin.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"runtimePlugin.js","sourceRoot":"","sources":["../../../../src/plugins/container/runtimePlugin.ts"],"names":[],"mappings":";;AACA;IACE,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,eAAe,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;YACzC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;YAC7B,MAAM,EAAE,GAAG;gBACT,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBACpC,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;YAEF,EAAE,CAAC,eAAe,GAAG,UAAU,GAAQ;gBACrC,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC;YACF,IAAI,GAAG,CAAC;YACR,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;gBACrB,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;oBACX,UAAU,EAAE,IAAI;oBAChB,OAAO,EAAE,EA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V,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,QAAQ,GAAG;gBACd,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,yDAAyD;gBAChI,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;YAChD,CAAC,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,IAAI;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAtLD,4BAsLC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import * as deadUtils from '@module-federation/utilities';
|
|
1
2
|
/**
|
|
2
3
|
* Extracts the URL and global from the module federation utilities.
|
|
3
4
|
* @module @module-federation/utilities/src/utils/pure
|
|
4
5
|
*/
|
|
5
6
|
export { extractUrlAndGlobal } from '@module-federation/utilities';
|
|
6
|
-
|
|
7
|
-
* Injects a script from the module federation utilities.
|
|
8
|
-
* @module @module-federation/utilities/src/utils/common
|
|
9
|
-
*/
|
|
10
|
-
export { injectScript } from '@module-federation/utilities';
|
|
7
|
+
export declare const injectScript: (args: any) => Promise<deadUtils.WebpackRemoteContainer>;
|
|
11
8
|
/**
|
|
12
9
|
* Flushes chunks from the module federation node utilities.
|
|
13
10
|
* @module @module-federation/node/utils
|
package/dist/utils/index.js
CHANGED
|
@@ -24,18 +24,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.revalidate = exports.FlushedChunks = exports.flushChunks = exports.injectScript = exports.extractUrlAndGlobal = void 0;
|
|
27
|
+
const deadUtils = __importStar(require("@module-federation/utilities"));
|
|
27
28
|
/**
|
|
28
29
|
* Extracts the URL and global from the module federation utilities.
|
|
29
30
|
* @module @module-federation/utilities/src/utils/pure
|
|
30
31
|
*/
|
|
31
32
|
var utilities_1 = require("@module-federation/utilities");
|
|
32
33
|
Object.defineProperty(exports, "extractUrlAndGlobal", { enumerable: true, get: function () { return utilities_1.extractUrlAndGlobal; } });
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
const injectScript = (args) => {
|
|
36
|
+
console.warn('injectScript is deprecated, use module-federation/runtime and loadRemote');
|
|
37
|
+
return deadUtils.injectScript(args);
|
|
38
|
+
};
|
|
39
|
+
exports.injectScript = injectScript;
|
|
39
40
|
/**
|
|
40
41
|
* Flushes chunks from the module federation node utilities.
|
|
41
42
|
* @module @module-federation/node/utils
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,0DAAmE;AAA1D,gHAAA,mBAAmB,OAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wEAA0D;AAE1D;;;GAGG;AACH,0DAAmE;AAA1D,gHAAA,mBAAmB,OAAA;AAE5B,YAAY;AACL,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,EAAE;IACnC,OAAO,CAAC,IAAI,CACV,0EAA0E,CAC3E,CAAC;IACF,OAAO,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AALW,QAAA,YAAY,gBAKvB;AAEF;;;GAGG;AACH,aAAa;AACb,uDAA4D;AAAnD,oGAAA,WAAW,OAAA;AAEpB;;GAEG;AACH,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAOtB;;;;;GAKG;AACI,MAAM,UAAU,GAAG,CACxB,cAAmB,SAAS,EAC5B,QAAiB,KAAK,EACtB,EAAE;IACF,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC9D,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,aAAa;IACb,OAAO,kDAAO,+BAA+B,IAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;QAC5D,OAAO,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/nextjs-mf",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"webpack-sources": "^3.2.3",
|
|
43
43
|
"eventemitter3": "^5.0.0",
|
|
44
44
|
"@module-federation/utilities": "3.0.6",
|
|
45
|
-
"@module-federation/
|
|
46
|
-
"@module-federation/
|
|
47
|
-
"@module-federation/enhanced": "0.
|
|
48
|
-
"@module-federation/
|
|
49
|
-
"@module-federation/
|
|
45
|
+
"@module-federation/runtime": "0.1.1",
|
|
46
|
+
"@module-federation/sdk": "0.1.1",
|
|
47
|
+
"@module-federation/enhanced": "0.1.1",
|
|
48
|
+
"@module-federation/node": "2.1.1",
|
|
49
|
+
"@module-federation/webpack-type": "0.0.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"webpack": "^5.40.0",
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack';
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {import("webpack").Compiler} Compiler
|
|
4
|
-
* @typedef {import("webpack").Compilation} Compilation
|
|
5
|
-
* @typedef {import("webpack").Chunk} Chunk
|
|
6
|
-
* @typedef {import("webpack").Module} Module
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* This class is responsible for hoisting container references in the code.
|
|
10
|
-
* @constructor
|
|
11
|
-
*/
|
|
12
|
-
export declare class HoistPseudoEager {
|
|
13
|
-
/**
|
|
14
|
-
* @function apply
|
|
15
|
-
* @param {Compiler} compiler The webpack compiler object
|
|
16
|
-
*/
|
|
17
|
-
apply(compiler: Compiler): void;
|
|
18
|
-
}
|
|
19
|
-
export default HoistPseudoEager;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HoistPseudoEager = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {import("webpack").Compiler} Compiler
|
|
6
|
-
* @typedef {import("webpack").Compilation} Compilation
|
|
7
|
-
* @typedef {import("webpack").Chunk} Chunk
|
|
8
|
-
* @typedef {import("webpack").Module} Module
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* This class is responsible for hoisting container references in the code.
|
|
12
|
-
* @constructor
|
|
13
|
-
*/
|
|
14
|
-
class HoistPseudoEager {
|
|
15
|
-
/**
|
|
16
|
-
* @function apply
|
|
17
|
-
* @param {Compiler} compiler The webpack compiler object
|
|
18
|
-
*/
|
|
19
|
-
apply(compiler) {
|
|
20
|
-
// Hook into the compilation process
|
|
21
|
-
compiler.hooks.thisCompilation.tap('HoistPseudoEager', (compilation) => {
|
|
22
|
-
// Perform the hoisting after chunks are optimized
|
|
23
|
-
compilation.hooks.afterOptimizeChunks.tap('HoistPseudoEager', (chunks, chunkGroups) => {
|
|
24
|
-
// Create a map to store chunks by their id or name
|
|
25
|
-
/** @type {Map<(string|number), Chunk>} */
|
|
26
|
-
const chunkSet = new Map();
|
|
27
|
-
// Create a set to store external module requests
|
|
28
|
-
/** @type {Set<Module>} */
|
|
29
|
-
const externalRequests = new Set();
|
|
30
|
-
// Populate the chunkSet with chunks
|
|
31
|
-
for (const chunk of chunks) {
|
|
32
|
-
const ident = chunk.id || chunk.name;
|
|
33
|
-
if (ident) {
|
|
34
|
-
chunkSet.set(ident, chunk);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Iterate over chunks again to handle remote modules
|
|
38
|
-
for (const chunk of chunks) {
|
|
39
|
-
// Get iterable of remote modules for the chunk
|
|
40
|
-
const remoteModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(chunk, 'remote');
|
|
41
|
-
if (!remoteModules)
|
|
42
|
-
continue;
|
|
43
|
-
const runtime = chunkSet.get('webpack-runtime') || chunkSet.get('webpack');
|
|
44
|
-
const runtimeRoots = runtime
|
|
45
|
-
? compilation.chunkGraph.getChunkRootModules(runtime)
|
|
46
|
-
: null;
|
|
47
|
-
const refChunks = runtime
|
|
48
|
-
? Array.from(runtime.getAllReferencedChunks())
|
|
49
|
-
: null;
|
|
50
|
-
if (refChunks) {
|
|
51
|
-
for (const refChunk of refChunks) {
|
|
52
|
-
const consumeSharedModules = compilation.chunkGraph.getChunkModulesIterableBySourceType(refChunk, 'consume-shared');
|
|
53
|
-
if (!consumeSharedModules)
|
|
54
|
-
continue;
|
|
55
|
-
//loop through consume-shared modules
|
|
56
|
-
for (const module of consumeSharedModules) {
|
|
57
|
-
// Get the module associated with the dependency
|
|
58
|
-
for (const block of module.blocks) {
|
|
59
|
-
for (const dep of block.dependencies) {
|
|
60
|
-
const mod = compilation.moduleGraph.getModule(dep);
|
|
61
|
-
// If the module exists and the chunk has a runtime, add the module to externalRequests
|
|
62
|
-
if (mod !== null && runtime) {
|
|
63
|
-
// Get the runtime chunk from the chunkSet
|
|
64
|
-
// If the runtime chunk exists, connect it with the module in the chunk graph
|
|
65
|
-
compilation.chunkGraph.connectChunkAndModule(runtime, mod);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.HoistPseudoEager = HoistPseudoEager;
|
|
78
|
-
exports.default = HoistPseudoEager;
|
|
79
|
-
//# sourceMappingURL=HoistPseudoEagerModules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HoistPseudoEagerModules.js","sourceRoot":"","sources":["../../../../src/plugins/container/HoistPseudoEagerModules.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAa,gBAAgB;IAC3B;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,oCAAoC;QACpC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAChC,kBAAkB,EAClB,CAAC,WAAwB,EAAE,EAAE;YAC3B,kDAAkD;YAClD,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,GAAG,CACvC,kBAAkB,EAClB,CAAC,MAAuB,EAAE,WAAyB,EAAE,EAAE;gBACrD,mDAAmD;gBACnD,0CAA0C;gBAC1C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;gBACnD,iDAAiD;gBACjD,0BAA0B;gBAC1B,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;gBAC3C,oCAAoC;gBACpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC;oBACrC,IAAI,KAAK,EAAE,CAAC;wBACV,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;oBAC7B,CAAC;gBACH,CAAC;gBAED,qDAAqD;gBACrD,KAAK,MAAM,KAAK,I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G,CACJ,CAAC;wCACJ,CAAC;oCACH,CAAC;gCACH,CAAC;4BACH,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA/ED,4CA+EC;AACD,kBAAe,gBAAgB,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Compiler } from 'webpack';
|
|
2
|
-
/**
|
|
3
|
-
* This plugin removes eager modules from the runtime.
|
|
4
|
-
* @class RemoveEagerModulesFromRuntimePlugin
|
|
5
|
-
*/
|
|
6
|
-
declare class RemoveEagerModulesFromRuntimePlugin {
|
|
7
|
-
private container;
|
|
8
|
-
private debug;
|
|
9
|
-
private modulesToProcess;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an instance of RemoveEagerModulesFromRuntimePlugin.
|
|
12
|
-
* @param {Object} options - The options for the plugin.
|
|
13
|
-
* @param {string} options.container - The container to remove modules from.
|
|
14
|
-
* @param {boolean} options.debug - Whether to log debug information.
|
|
15
|
-
*/
|
|
16
|
-
constructor(options: {
|
|
17
|
-
container?: string;
|
|
18
|
-
debug?: boolean;
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Applies the plugin to the compiler.
|
|
22
|
-
* @param {Compiler} compiler - The webpack compiler.
|
|
23
|
-
*/
|
|
24
|
-
apply(compiler: Compiler): void;
|
|
25
|
-
/**
|
|
26
|
-
* Processes the modules in the chunk.
|
|
27
|
-
* @param {Compilation} compilation - The webpack compilation.
|
|
28
|
-
* @param {Chunk} chunk - The chunk to process.
|
|
29
|
-
* @param {Iterable<Module>} modules - The modules in the chunk.
|
|
30
|
-
*/
|
|
31
|
-
private processModules;
|
|
32
|
-
/**
|
|
33
|
-
* Removes the modules from the chunk.
|
|
34
|
-
* @param {Compilation} compilation - The webpack compilation.
|
|
35
|
-
* @param {Chunk} chunk - The chunk to remove modules from.
|
|
36
|
-
*/
|
|
37
|
-
private removeModules;
|
|
38
|
-
}
|
|
39
|
-
export default RemoveEagerModulesFromRuntimePlugin;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* This plugin removes eager modules from the runtime.
|
|
5
|
-
* @class RemoveEagerModulesFromRuntimePlugin
|
|
6
|
-
*/
|
|
7
|
-
class RemoveEagerModulesFromRuntimePlugin {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of RemoveEagerModulesFromRuntimePlugin.
|
|
10
|
-
* @param {Object} options - The options for the plugin.
|
|
11
|
-
* @param {string} options.container - The container to remove modules from.
|
|
12
|
-
* @param {boolean} options.debug - Whether to log debug information.
|
|
13
|
-
*/
|
|
14
|
-
constructor(options) {
|
|
15
|
-
this.container = options.container;
|
|
16
|
-
this.debug = options.debug || false;
|
|
17
|
-
this.modulesToProcess = new Set();
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Applies the plugin to the compiler.
|
|
21
|
-
* @param {Compiler} compiler - The webpack compiler.
|
|
22
|
-
*/
|
|
23
|
-
apply(compiler) {
|
|
24
|
-
if (!this.container) {
|
|
25
|
-
console.warn('[nextjs-mf]:', 'RemoveEagerModulesFromRuntimePlugin container is not defined:', this.container);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
compiler.hooks.thisCompilation.tap('RemoveEagerModulesFromRuntimePlugin', (compilation) => {
|
|
29
|
-
compilation.hooks.optimizeChunkModules.tap('RemoveEagerModulesFromRuntimePlugin', (chunks, modules) => {
|
|
30
|
-
for (const chunk of chunks) {
|
|
31
|
-
if (chunk.hasRuntime() && chunk.name === this.container) {
|
|
32
|
-
this.processModules(compilation, chunk, modules);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Processes the modules in the chunk.
|
|
40
|
-
* @param {Compilation} compilation - The webpack compilation.
|
|
41
|
-
* @param {Chunk} chunk - The chunk to process.
|
|
42
|
-
* @param {Iterable<Module>} modules - The modules in the chunk.
|
|
43
|
-
*/
|
|
44
|
-
processModules(compilation, chunk, modules) {
|
|
45
|
-
for (const module of modules) {
|
|
46
|
-
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (module.constructor.name === 'NormalModule') {
|
|
50
|
-
this.modulesToProcess.add(module);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
this.removeModules(compilation, chunk);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Removes the modules from the chunk.
|
|
57
|
-
* @param {Compilation} compilation - The webpack compilation.
|
|
58
|
-
* @param {Chunk} chunk - The chunk to remove modules from.
|
|
59
|
-
*/
|
|
60
|
-
removeModules(compilation, chunk) {
|
|
61
|
-
for (const moduleToRemove of this.modulesToProcess) {
|
|
62
|
-
if (this.debug) {
|
|
63
|
-
console.log('removing', moduleToRemove.constructor.name);
|
|
64
|
-
}
|
|
65
|
-
if (compilation.chunkGraph.isModuleInChunk(moduleToRemove, chunk)) {
|
|
66
|
-
compilation.chunkGraph.disconnectChunkAndModule(chunk, moduleToRemove);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.default = RemoveEagerModulesFromRuntimePlugin;
|
|
72
|
-
//# sourceMappingURL=RemoveEagerModulesFromRuntimePlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RemoveEagerModulesFromRuntimePlugin.js","sourceRoot":"","sources":["../../../../src/plugins/container/RemoveEagerModulesFromRuntimePlugin.ts"],"names":[],"mappings":";;AAEA;;;GAGG;AACH,MAAM,mCAAmC;IAKvC;;;;;OAKG;IACH,YAAY,OAAgD;QAC1D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC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