@module-federation/nextjs-mf 5.3.3 → 5.4.1-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/lib/ModuleFederationPlugin.js +5 -1
- package/lib/NextFederationPlugin.js +39 -1086
- package/lib/_virtual/Template.js +7 -0
- package/lib/_virtual/UrlNode.js +9 -0
- package/lib/_virtual/_commonjsHelpers.js +44 -0
- package/lib/_virtual/_fast-glob.js +16 -0
- package/lib/_virtual/_fs.js +16 -0
- package/lib/_virtual/_path.js +16 -0
- package/lib/_virtual/_tslib.js +176 -0
- package/lib/_virtual/_webpack-sources.js +16 -0
- package/lib/_virtual/fs.js +4 -0
- package/lib/_virtual/fs2.js +7 -0
- package/lib/_virtual/helpers.js +7 -0
- package/lib/_virtual/nextPageMapLoader.js +7 -0
- package/lib/_virtual/options.js +7 -0
- package/lib/_virtual/utils.js +7 -0
- package/lib/build-utils.js +176 -0
- package/lib/client/MFClient.d.ts +4 -1
- package/lib/client/MFClient.d.ts.map +1 -1
- package/lib/client/MFClient.js +35 -19
- package/lib/client/RemoteContainer.js +1 -0
- package/lib/client/RemotePages.d.ts +2 -1
- package/lib/client/RemotePages.d.ts.map +1 -1
- package/lib/client/RemotePages.js +38 -12
- package/lib/dependencies/webpack/lib/Template.js +437 -0
- package/lib/dependencies/webpack/lib/container/options.js +102 -0
- package/lib/dependencies/webpack/lib/sharing/utils.js +104 -0
- package/lib/dependencies/webpack/lib/util/fs.js +359 -0
- package/lib/index.js +1 -1
- package/lib/internal.js +58 -28
- package/lib/loaders/UrlNode.js +11 -1
- package/lib/loaders/fixImageLoader.js +14 -8
- package/lib/loaders/helpers.js +16 -3
- package/lib/loaders/nextPageMapLoader.js +26 -5
- package/lib/loaders/patchNextClientPageLoader.js +1 -1
- package/lib/plugins/DevHmrFixInvalidPongPlugin.js +23 -1
- package/lib/utils.js +24 -7
- package/package.json +7 -4
package/lib/internal.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var options = require('./dependencies/webpack/lib/container/options.js');
|
|
6
|
+
var utils = require('./dependencies/webpack/lib/sharing/utils.js');
|
|
7
|
+
var utils$1 = require('./utils.js');
|
|
8
|
+
var path = require('path');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
4
13
|
|
|
5
14
|
// the share scope we attach by default
|
|
6
15
|
// in hosts we re-key them to prevent webpack moving the modules into their own chunks (cause eager error)
|
|
7
16
|
// in remote these are marked as import:false as we always expect the host to prove them
|
|
8
|
-
|
|
17
|
+
const DEFAULT_SHARE_SCOPE = {
|
|
9
18
|
react: {
|
|
10
19
|
singleton: true,
|
|
11
20
|
requiredVersion: false,
|
|
@@ -44,7 +53,7 @@ export const DEFAULT_SHARE_SCOPE = {
|
|
|
44
53
|
},
|
|
45
54
|
};
|
|
46
55
|
// put host infront of any shared module key, so "hostreact"
|
|
47
|
-
|
|
56
|
+
const reKeyHostShared = (options) => {
|
|
48
57
|
return Object.entries({
|
|
49
58
|
...(options || {}),
|
|
50
59
|
...DEFAULT_SHARE_SCOPE,
|
|
@@ -66,19 +75,9 @@ export const reKeyHostShared = (options) => {
|
|
|
66
75
|
return acc;
|
|
67
76
|
}, {});
|
|
68
77
|
};
|
|
69
|
-
|
|
70
|
-
// split the @ syntax into url and global
|
|
71
|
-
export const extractUrlAndGlobal = (urlAndGlobal) => {
|
|
72
|
-
const index = urlAndGlobal.indexOf('@');
|
|
73
|
-
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
74
|
-
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
75
|
-
}
|
|
76
|
-
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
|
77
|
-
};
|
|
78
|
-
|
|
79
78
|
// browser template to convert remote into promise new promise and use require.loadChunk to load the chunk
|
|
80
|
-
|
|
81
|
-
return `
|
|
79
|
+
const generateRemoteTemplate = (url, global) => {
|
|
80
|
+
return `new Promise(function (resolve, reject) {
|
|
82
81
|
var __webpack_error__ = new Error();
|
|
83
82
|
if (typeof ${global} !== 'undefined') return resolve();
|
|
84
83
|
__webpack_require__.l(
|
|
@@ -132,17 +131,17 @@ export const generateRemoteTemplate = (url, global) => {
|
|
|
132
131
|
}
|
|
133
132
|
return proxy
|
|
134
133
|
})`;
|
|
135
|
-
}
|
|
134
|
+
};
|
|
136
135
|
|
|
137
|
-
const parseShareOptions = (options) => {
|
|
138
|
-
const sharedOptions = parseOptions(
|
|
139
|
-
options.shared,
|
|
136
|
+
const parseShareOptions = (options$1) => {
|
|
137
|
+
const sharedOptions = options.parseOptions(
|
|
138
|
+
options$1.shared,
|
|
140
139
|
(item, key) => {
|
|
141
140
|
if (typeof item !== 'string')
|
|
142
141
|
throw new Error('Unexpected array in shared');
|
|
143
142
|
/** @type {SharedConfig} */
|
|
144
143
|
const config =
|
|
145
|
-
item === key || !isRequiredVersion(item)
|
|
144
|
+
item === key || !utils.isRequiredVersion(item)
|
|
146
145
|
? {
|
|
147
146
|
import: item,
|
|
148
147
|
}
|
|
@@ -170,7 +169,7 @@ const parseShareOptions = (options) => {
|
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
// shared packages must be compiled into webpack bundle, not require() pass through
|
|
173
|
-
|
|
172
|
+
const internalizeSharedPackages = (options, compiler) => {
|
|
174
173
|
//TODO: should use this util for other areas where we read MF options from userland
|
|
175
174
|
if (!options.shared) {
|
|
176
175
|
return;
|
|
@@ -200,7 +199,7 @@ export const internalizeSharedPackages = (options, compiler) => {
|
|
|
200
199
|
}
|
|
201
200
|
};
|
|
202
201
|
|
|
203
|
-
|
|
202
|
+
const externalizedShares = Object.entries(DEFAULT_SHARE_SCOPE).reduce(
|
|
204
203
|
(acc, item) => {
|
|
205
204
|
const [key, value] = item;
|
|
206
205
|
acc[key] = { ...value, import: false };
|
|
@@ -213,20 +212,20 @@ export const externalizedShares = Object.entries(DEFAULT_SHARE_SCOPE).reduce(
|
|
|
213
212
|
);
|
|
214
213
|
|
|
215
214
|
// determine output base path, derives .next folder location
|
|
216
|
-
|
|
215
|
+
const getOutputPath = (compiler) => {
|
|
217
216
|
const isServer = compiler.options.target !== 'client';
|
|
218
|
-
let outputPath = compiler.options.output.path.split(
|
|
217
|
+
let outputPath = compiler.options.output.path.split(path__default["default"].sep);
|
|
219
218
|
const foundIndex = outputPath.findIndex((i) => {
|
|
220
219
|
return i === (isServer ? 'server' : 'static');
|
|
221
220
|
});
|
|
222
221
|
outputPath = outputPath
|
|
223
222
|
.slice(0, foundIndex > 0 ? foundIndex : outputPath.length)
|
|
224
|
-
.join(
|
|
223
|
+
.join(path__default["default"].sep);
|
|
225
224
|
|
|
226
225
|
return outputPath;
|
|
227
226
|
};
|
|
228
227
|
|
|
229
|
-
|
|
228
|
+
const removePlugins = [
|
|
230
229
|
'NextJsRequireCacheHotReloader',
|
|
231
230
|
'BuildManifestPlugin',
|
|
232
231
|
'WellKnownErrorsPlugin',
|
|
@@ -239,3 +238,34 @@ export const removePlugins = [
|
|
|
239
238
|
'DropClientPage',
|
|
240
239
|
'ReactFreshWebpackPlugin',
|
|
241
240
|
];
|
|
241
|
+
|
|
242
|
+
const parseRemoteSyntax = (remote) => {
|
|
243
|
+
if (typeof remote === 'string' && remote.includes('@')) {
|
|
244
|
+
const [url, global] = utils$1.extractUrlAndGlobal(remote);
|
|
245
|
+
return generateRemoteTemplate(url, global);
|
|
246
|
+
}
|
|
247
|
+
return remote
|
|
248
|
+
};
|
|
249
|
+
const parseRemotes = (remotes) =>{
|
|
250
|
+
return Object.entries(remotes).reduce(
|
|
251
|
+
(acc, remote) => {
|
|
252
|
+
if (!remote[1].startsWith('promise ') && remote[1].includes('@')) {
|
|
253
|
+
acc[remote[0]] = 'promise ' + parseRemoteSyntax(remote[1]);
|
|
254
|
+
return acc;
|
|
255
|
+
}
|
|
256
|
+
acc[remote[0]] = remote[1];
|
|
257
|
+
return acc;
|
|
258
|
+
},
|
|
259
|
+
{}
|
|
260
|
+
);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
exports.DEFAULT_SHARE_SCOPE = DEFAULT_SHARE_SCOPE;
|
|
264
|
+
exports.externalizedShares = externalizedShares;
|
|
265
|
+
exports.generateRemoteTemplate = generateRemoteTemplate;
|
|
266
|
+
exports.getOutputPath = getOutputPath;
|
|
267
|
+
exports.internalizeSharedPackages = internalizeSharedPackages;
|
|
268
|
+
exports.parseRemoteSyntax = parseRemoteSyntax;
|
|
269
|
+
exports.parseRemotes = parseRemotes;
|
|
270
|
+
exports.reKeyHostShared = reKeyHostShared;
|
|
271
|
+
exports.removePlugins = removePlugins;
|
package/lib/loaders/UrlNode.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../_virtual/_commonjsHelpers.js');
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* 🛑🛑🛑 Attention! 🛑🛑🛑
|
|
3
9
|
* Do not add type definitions to this file!!
|
|
@@ -15,7 +21,7 @@
|
|
|
15
21
|
* It was copied from
|
|
16
22
|
* @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
|
|
17
23
|
*/
|
|
18
|
-
|
|
24
|
+
class UrlNode {
|
|
19
25
|
placeholder = true;
|
|
20
26
|
children = new Map();
|
|
21
27
|
slugName = null;
|
|
@@ -207,3 +213,7 @@ module.exports = class UrlNode {
|
|
|
207
213
|
._insert(urlPaths.slice(1), slugNames, isCatchAll);
|
|
208
214
|
}
|
|
209
215
|
}
|
|
216
|
+
|
|
217
|
+
var UrlNode_1 = { UrlNode };
|
|
218
|
+
|
|
219
|
+
exports["default"] = UrlNode_1;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Template = require('./../dependencies/webpack/lib/Template.js');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
|
+
|
|
8
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* This loader was specially created for tunning next-image-loader result
|
|
@@ -18,6 +23,7 @@ const RuntimeGlobals = require('webpack/lib/RuntimeGlobals');
|
|
|
18
23
|
*/
|
|
19
24
|
async function fixImageLoader(remaining) {
|
|
20
25
|
this.cacheable(true);
|
|
26
|
+
const publicPath = this._compiler.webpack.RuntimeGlobals.publicPath;
|
|
21
27
|
const isServer = this._compiler.options.name !== 'client';
|
|
22
28
|
const result = await this.importModule(
|
|
23
29
|
`${this.resourcePath}.webpack[javascript/auto]` + `!=!${remaining}`
|
|
@@ -26,13 +32,13 @@ async function fixImageLoader(remaining) {
|
|
|
26
32
|
|
|
27
33
|
const computedAssetPrefix = isServer
|
|
28
34
|
? ` \'\'`
|
|
29
|
-
: `(${
|
|
35
|
+
: `(${publicPath} && ${publicPath}.indexOf('://') > 0 ? new URL(${publicPath}).origin : \'\')`;
|
|
30
36
|
|
|
31
37
|
const constructedObject = Object.entries(content).reduce(
|
|
32
38
|
(acc, [key, value]) => {
|
|
33
39
|
if (key === 'src') {
|
|
34
40
|
if (value && value.indexOf('://') < 0) {
|
|
35
|
-
value =
|
|
41
|
+
value = path__default["default"].join(value);
|
|
36
42
|
}
|
|
37
43
|
acc.push(
|
|
38
44
|
`${key}: computedAssetsPrefixReference + ${JSON.stringify(value)}`
|
|
@@ -44,13 +50,13 @@ async function fixImageLoader(remaining) {
|
|
|
44
50
|
},
|
|
45
51
|
[]
|
|
46
52
|
);
|
|
47
|
-
const updated = Template.asString([
|
|
53
|
+
const updated = Template["default"].asString([
|
|
48
54
|
"let computedAssetsPrefixReference = '';",
|
|
49
55
|
'try {',
|
|
50
|
-
Template.indent(`computedAssetsPrefixReference = ${computedAssetPrefix};`),
|
|
56
|
+
Template["default"].indent(`computedAssetsPrefixReference = ${computedAssetPrefix};`),
|
|
51
57
|
'} catch (e) {}',
|
|
52
58
|
'export default {',
|
|
53
|
-
Template.indent(constructedObject.join(',\n')),
|
|
59
|
+
Template["default"].indent(constructedObject.join(',\n')),
|
|
54
60
|
'}',
|
|
55
61
|
]);
|
|
56
62
|
return updated;
|
package/lib/loaders/helpers.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../_virtual/_commonjsHelpers.js');
|
|
6
|
+
var helpers = require('../_virtual/helpers.js');
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Inject a loader into the current module rule.
|
|
3
10
|
* This function mutates `rule` argument!
|
|
4
11
|
*/
|
|
5
|
-
|
|
12
|
+
|
|
13
|
+
var injectRuleLoader = helpers.__exports.injectRuleLoader = function injectRuleLoader(rule, loader) {
|
|
6
14
|
if (rule.loader) {
|
|
7
15
|
rule.use = [loader, { loader: rule.loader, options: rule.options }];
|
|
8
16
|
delete rule.loader;
|
|
@@ -15,7 +23,7 @@ module.exports.injectRuleLoader = function injectRuleLoader(rule, loader) {
|
|
|
15
23
|
/**
|
|
16
24
|
* Check that current module rule has a loader with the provided name.
|
|
17
25
|
*/
|
|
18
|
-
|
|
26
|
+
var hasLoader = helpers.__exports.hasLoader = function hasLoader(rule, loaderName) {
|
|
19
27
|
if (rule.loader === loaderName) {
|
|
20
28
|
return true;
|
|
21
29
|
} else if (rule.use) {
|
|
@@ -34,7 +42,7 @@ module.exports.hasLoader = function hasLoader(rule, loaderName) {
|
|
|
34
42
|
return false;
|
|
35
43
|
};
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
var toDisplayErrors = helpers.__exports.toDisplayErrors = function toDisplayErrors(err) {
|
|
38
46
|
return err
|
|
39
47
|
.map((error) => {
|
|
40
48
|
let message = error.message;
|
|
@@ -45,3 +53,8 @@ module.exports.toDisplayErrors = function toDisplayErrors(err) {
|
|
|
45
53
|
})
|
|
46
54
|
.join('\n');
|
|
47
55
|
};
|
|
56
|
+
|
|
57
|
+
exports["default"] = helpers.__exports;
|
|
58
|
+
exports.hasLoader = hasLoader;
|
|
59
|
+
exports.injectRuleLoader = injectRuleLoader;
|
|
60
|
+
exports.toDisplayErrors = toDisplayErrors;
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../_virtual/_commonjsHelpers.js');
|
|
6
|
+
var nextPageMapLoader$1 = require('../_virtual/nextPageMapLoader.js');
|
|
7
|
+
require('../_virtual/_fast-glob.js');
|
|
8
|
+
require('../_virtual/_fs.js');
|
|
9
|
+
require('../_virtual/UrlNode.js');
|
|
10
|
+
var require$$0 = require('fast-glob');
|
|
11
|
+
var require$$1 = require('fs');
|
|
12
|
+
var UrlNode$1 = require('./UrlNode.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
17
|
+
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
18
|
+
|
|
19
|
+
const fg = require$$0__default["default"];
|
|
20
|
+
const fs = require$$1__default["default"];
|
|
3
21
|
|
|
4
22
|
// TODO: import UrlNode from ./client folder when whole project migrates on TypeScript (but right now using JS copy of this class)
|
|
5
23
|
// const UrlNode = require('../client/UrlNode').UrlNode;
|
|
6
|
-
const UrlNode =
|
|
24
|
+
const UrlNode = UrlNode$1["default"].UrlNode;
|
|
7
25
|
|
|
8
26
|
/**
|
|
9
27
|
* Webpack loader which prepares MF map for NextJS pages
|
|
@@ -175,5 +193,8 @@ function preparePageMapV2(pages) {
|
|
|
175
193
|
return result;
|
|
176
194
|
}
|
|
177
195
|
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
nextPageMapLoader$1.nextPageMapLoader.exports = nextPageMapLoader;
|
|
197
|
+
var exposeNextjsPages_1 = nextPageMapLoader$1.nextPageMapLoader.exports.exposeNextjsPages = exposeNextjsPages;
|
|
198
|
+
|
|
199
|
+
exports["default"] = nextPageMapLoader$1.nextPageMapLoader.exports;
|
|
200
|
+
exports.exposeNextjsPages = exposeNextjsPages_1;
|
|
@@ -32,7 +32,7 @@ function patchNextClientPageLoader(content) {
|
|
|
32
32
|
class PageLoaderExtended extends PageLoader {
|
|
33
33
|
constructor(buildId, assetPrefix) {
|
|
34
34
|
super(buildId, assetPrefix);
|
|
35
|
-
global.mf_client = new MFClient(this);
|
|
35
|
+
global.mf_client = new MFClient(this, { mode: process.env.NODE_ENV });
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
_getPageListOriginal() {
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../_virtual/_commonjsHelpers.js');
|
|
6
|
+
|
|
7
|
+
if (!String.prototype.replaceAll) {
|
|
8
|
+
String.prototype.replaceAll = function (str, newStr) {
|
|
9
|
+
// If a regex pattern
|
|
10
|
+
if (
|
|
11
|
+
Object.prototype.toString.call(str).toLowerCase() === '[object regexp]'
|
|
12
|
+
) {
|
|
13
|
+
return this.replace(str, newStr);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// If a string
|
|
17
|
+
return this.replace(new RegExp(str, 'g'), newStr);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
/**
|
|
2
22
|
* If HMR through websocket received {"invalid":true, "event":"pong"} event
|
|
3
23
|
* then pages reloads. But for federated page this is unwanted behavior.
|
|
@@ -57,4 +77,6 @@ function escapeRegExp(string) {
|
|
|
57
77
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
58
78
|
}
|
|
59
79
|
|
|
60
|
-
|
|
80
|
+
var DevHmrFixInvalidPongPlugin_1 = DevHmrFixInvalidPongPlugin;
|
|
81
|
+
|
|
82
|
+
exports["default"] = DevHmrFixInvalidPongPlugin_1;
|
package/lib/utils.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
// split the @ syntax into url and global
|
|
6
|
+
const extractUrlAndGlobal = (urlAndGlobal) => {
|
|
7
|
+
const index = urlAndGlobal.indexOf('@');
|
|
8
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
9
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
10
|
+
}
|
|
11
|
+
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
|
12
|
+
};
|
|
13
|
+
|
|
5
14
|
const remoteVars = process.env.REMOTES || {};
|
|
6
15
|
|
|
7
16
|
const runtimeRemotes = Object.entries(remoteVars).reduce(function (acc, item) {
|
|
@@ -14,7 +23,7 @@ const runtimeRemotes = Object.entries(remoteVars).reduce(function (acc, item) {
|
|
|
14
23
|
acc[key] = { asyncContainer: value() };
|
|
15
24
|
} else if (typeof value === 'string') {
|
|
16
25
|
// if its just a string (global@url)
|
|
17
|
-
const [
|
|
26
|
+
const [url, global] = extractUrlAndGlobal(value);
|
|
18
27
|
acc[key] = { global, url };
|
|
19
28
|
} else {
|
|
20
29
|
// we dont know or currently support this type
|
|
@@ -24,6 +33,8 @@ const runtimeRemotes = Object.entries(remoteVars).reduce(function (acc, item) {
|
|
|
24
33
|
return acc;
|
|
25
34
|
}, {});
|
|
26
35
|
|
|
36
|
+
const remotes = runtimeRemotes;
|
|
37
|
+
|
|
27
38
|
/**
|
|
28
39
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
29
40
|
*
|
|
@@ -32,7 +43,7 @@ const runtimeRemotes = Object.entries(remoteVars).reduce(function (acc, item) {
|
|
|
32
43
|
* or
|
|
33
44
|
* { asyncContainer } - async container is a promise that resolves to the remote container
|
|
34
45
|
*/
|
|
35
|
-
|
|
46
|
+
const injectScript = (keyOrRuntimeRemoteItem) => {
|
|
36
47
|
let reference = keyOrRuntimeRemoteItem;
|
|
37
48
|
if (typeof keyOrRuntimeRemoteItem === 'string') {
|
|
38
49
|
reference = runtimeRemotes[keyOrRuntimeRemoteItem];
|
|
@@ -61,7 +72,13 @@ function injectScript(keyOrRuntimeRemoteItem) {
|
|
|
61
72
|
event && (event.type === 'load' ? 'missing' : event.type);
|
|
62
73
|
var realSrc = event && event.target && event.target.src;
|
|
63
74
|
__webpack_error__.message =
|
|
64
|
-
'Loading script failed.\n(' +
|
|
75
|
+
'Loading script failed.\n(' +
|
|
76
|
+
errorType +
|
|
77
|
+
': ' +
|
|
78
|
+
realSrc +
|
|
79
|
+
' or global var ' +
|
|
80
|
+
remoteGlobal +
|
|
81
|
+
')';
|
|
65
82
|
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
66
83
|
__webpack_error__.type = errorType;
|
|
67
84
|
__webpack_error__.request = realSrc;
|
|
@@ -101,8 +118,8 @@ function injectScript(keyOrRuntimeRemoteItem) {
|
|
|
101
118
|
}
|
|
102
119
|
return container;
|
|
103
120
|
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var injectScript_1 = injectScript;
|
|
121
|
+
};
|
|
107
122
|
|
|
108
|
-
exports.
|
|
123
|
+
exports.extractUrlAndGlobal = extractUrlAndGlobal;
|
|
124
|
+
exports.injectScript = injectScript;
|
|
125
|
+
exports.remotes = remotes;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"public": true,
|
|
3
3
|
"name": "@module-federation/nextjs-mf",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.4.1-1",
|
|
5
5
|
"description": "Module Federation helper for NextJS",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
"prepublishOnly": "yarn build"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@swc/core": "^1.3.2",
|
|
24
25
|
"chalk": "^4.0.0",
|
|
25
26
|
"eventemitter3": "^4.0.7",
|
|
26
|
-
"fast-glob": "^3.2.11"
|
|
27
|
+
"fast-glob": "^3.2.11",
|
|
28
|
+
"webpack-sources": "^3.2.3"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
@@ -32,14 +34,15 @@
|
|
|
32
34
|
"@types/react": "^18.0.19",
|
|
33
35
|
"concurrently": "^7.3.0",
|
|
34
36
|
"cpx": "^1.5.0",
|
|
35
|
-
"next": "12.3.
|
|
37
|
+
"next": "12.3.0",
|
|
36
38
|
"prettier": "2.3.2",
|
|
37
39
|
"react": "^18.2.0",
|
|
38
40
|
"rollup": "^2.78.1",
|
|
39
41
|
"rollup-obfuscator": "^3.0.1",
|
|
40
42
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
41
43
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
42
|
-
"rollup-plugin-
|
|
44
|
+
"rollup-plugin-rename-node-modules": "^1.3.1",
|
|
45
|
+
"rollup-plugin-typescript2": "0.34.0",
|
|
43
46
|
"tslib": "^2.4.0",
|
|
44
47
|
"typescript": "^4.8.2",
|
|
45
48
|
"webpack": "5.64.4"
|