@module-federation/nextjs-mf 5.5.1 → 5.6.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 +1 -27
- package/{lib/client → client}/CombinedPages.d.ts +27 -28
- package/client/CombinedPages.js +38 -0
- package/client/CombinedPages.js.map +1 -0
- package/{lib/client → client}/MFClient.d.ts +72 -73
- package/client/MFClient.js +159 -0
- package/client/MFClient.js.map +1 -0
- package/{lib/client → client}/RemoteContainer.d.ts +46 -58
- package/client/RemoteContainer.js +121 -0
- package/client/RemoteContainer.js.map +1 -0
- package/{lib/client → client}/RemotePages.d.ts +49 -49
- package/client/RemotePages.js +138 -0
- package/client/RemotePages.js.map +1 -0
- package/{lib/client → client}/UrlNode.d.ts +17 -18
- package/{lib/client → client}/UrlNode.js +157 -161
- package/client/UrlNode.js.map +1 -0
- package/{lib/client → client}/helpers.d.ts +16 -17
- package/{lib/client → client}/helpers.js +90 -104
- package/client/helpers.js.map +1 -0
- package/client/index.d.ts +2 -0
- package/client/index.js +6 -0
- package/client/index.js.map +1 -0
- package/{lib/client → client}/useMFClient.d.ts +24 -25
- package/client/useMFClient.js +55 -0
- package/client/useMFClient.js.map +1 -0
- package/{lib/client → client}/useMFRemote.d.ts +16 -17
- package/client/useMFRemote.js +50 -0
- package/client/useMFRemote.js.map +1 -0
- package/jest.config.d.ts +13 -0
- package/jest.config.js +18 -0
- package/jest.config.js.map +1 -0
- package/package.json +19 -42
- package/src/include-defaults.d.ts +0 -0
- package/{lib → src}/include-defaults.js +4 -3
- package/src/include-defaults.js.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -0
- package/src/internal.d.ts +12 -0
- package/src/internal.js +260 -0
- package/src/internal.js.map +1 -0
- package/src/loaders/fixImageLoader.d.ts +16 -0
- package/src/loaders/fixImageLoader.js +53 -0
- package/src/loaders/fixImageLoader.js.map +1 -0
- package/src/loaders/fixUrlLoader.d.ts +13 -0
- package/src/loaders/fixUrlLoader.js +25 -0
- package/src/loaders/fixUrlLoader.js.map +1 -0
- package/src/loaders/helpers.d.ts +10 -0
- package/src/loaders/helpers.js +46 -0
- package/src/loaders/helpers.js.map +1 -0
- package/src/loaders/nextPageMapLoader.d.ts +15 -0
- package/src/loaders/nextPageMapLoader.js +151 -0
- package/src/loaders/nextPageMapLoader.js.map +1 -0
- package/src/loaders/patchNextClientPageLoader.d.ts +7 -0
- package/src/loaders/patchNextClientPageLoader.js +43 -0
- package/src/loaders/patchNextClientPageLoader.js.map +1 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
- package/src/plugins/ChildFederationPlugin.d.ts +9 -0
- package/src/plugins/ChildFederationPlugin.js +281 -0
- package/src/plugins/ChildFederationPlugin.js.map +1 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.d.ts +11 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js +55 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js.map +1 -0
- package/src/plugins/ModuleFederationPlugin.d.ts +7 -0
- package/src/plugins/ModuleFederationPlugin.js +50 -0
- package/src/plugins/ModuleFederationPlugin.js.map +1 -0
- package/src/plugins/NextFederationPlugin.d.ts +9 -0
- package/src/plugins/NextFederationPlugin.js +111 -0
- package/src/plugins/NextFederationPlugin.js.map +1 -0
- package/src/plugins/RemoveRRRuntimePlugin.d.ts +5 -0
- package/src/plugins/RemoveRRRuntimePlugin.js +39 -0
- package/src/plugins/RemoveRRRuntimePlugin.js.map +1 -0
- package/utils/Template.d.ts +148 -0
- package/utils/Template.js +381 -0
- package/utils/Template.js.map +1 -0
- package/utils/build-utils.d.ts +3 -0
- package/utils/build-utils.js +175 -0
- package/utils/build-utils.js.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +7 -0
- package/utils/index.js.map +1 -0
- package/.prettierignore +0 -2
- package/.prettierrc +0 -7
- package/LICENSE +0 -21
- package/lib/ModuleFederationPlugin.js +0 -84
- package/lib/NextFederationPlugin.js +0 -513
- package/lib/_virtual/Template.js +0 -7
- package/lib/_virtual/UrlNode.js +0 -9
- package/lib/_virtual/_commonjsHelpers.js +0 -44
- package/lib/_virtual/_fast-glob.js +0 -16
- package/lib/_virtual/_fs.js +0 -16
- package/lib/_virtual/_path.js +0 -16
- package/lib/_virtual/_tslib.js +0 -277
- package/lib/_virtual/_webpack-sources.js +0 -16
- package/lib/_virtual/fs.js +0 -4
- package/lib/_virtual/fs2.js +0 -7
- package/lib/_virtual/helpers.js +0 -7
- package/lib/_virtual/nextPageMapLoader.js +0 -7
- package/lib/_virtual/options.js +0 -7
- package/lib/_virtual/utils.js +0 -7
- package/lib/build-utils.js +0 -176
- package/lib/client/CombinedPages.d.ts.map +0 -1
- package/lib/client/CombinedPages.js +0 -60
- package/lib/client/MFClient.d.ts.map +0 -1
- package/lib/client/MFClient.js +0 -213
- package/lib/client/RemoteContainer.d.ts.map +0 -1
- package/lib/client/RemoteContainer.js +0 -162
- package/lib/client/RemotePages.d.ts.map +0 -1
- package/lib/client/RemotePages.js +0 -194
- package/lib/client/UrlNode.d.ts.map +0 -1
- package/lib/client/helpers.d.ts.map +0 -1
- package/lib/client/useMFClient.d.ts.map +0 -1
- package/lib/client/useMFClient.js +0 -79
- package/lib/client/useMFRemote.d.ts.map +0 -1
- package/lib/client/useMFRemote.js +0 -72
- package/lib/dependencies/webpack/lib/Template.js +0 -437
- package/lib/dependencies/webpack/lib/container/options.js +0 -102
- package/lib/dependencies/webpack/lib/sharing/utils.js +0 -104
- package/lib/dependencies/webpack/lib/util/fs.js +0 -359
- package/lib/index.js +0 -3
- package/lib/internal.js +0 -271
- package/lib/loaders/UrlNode.js +0 -219
- package/lib/loaders/fixImageLoader.js +0 -65
- package/lib/loaders/fixUrlLoader.js +0 -25
- package/lib/loaders/helpers.js +0 -60
- package/lib/loaders/nextPageMapLoader.js +0 -200
- package/lib/loaders/patchNextClientPageLoader.js +0 -53
- package/lib/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -94
- package/lib/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -414
- package/lib/node-plugin/streaming/index.js +0 -46
- package/lib/node-plugin/streaming/loadScript.js +0 -59
- package/lib/plugins/DevHmrFixInvalidPongPlugin.js +0 -82
- package/lib/utils.js +0 -125
- package/node-plugin/README.md +0 -27
- package/node-plugin/package.json +0 -4
- package/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -89
- package/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -410
- package/node-plugin/streaming/NodeRuntime.js +0 -245
- package/node-plugin/streaming/index.js +0 -42
- package/node-plugin/streaming/loadScript.js +0 -51
- package/tsconfig.json +0 -33
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promiseTemplate = exports.promiseFactory = exports.computeRemoteFilename = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const Template_1 = tslib_1.__importDefault(require("./Template"));
|
|
6
|
+
const internal_1 = require("../src/internal");
|
|
7
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
8
|
+
const swc = require('@swc/core');
|
|
9
|
+
const transformInput = (code) => {
|
|
10
|
+
return swc.transformSync(code, {
|
|
11
|
+
// Some options cannot be specified in .swcrc
|
|
12
|
+
sourceMaps: false,
|
|
13
|
+
// Input files are treated as module by default.
|
|
14
|
+
isModule: false,
|
|
15
|
+
// All options below can be configured via .swcrc
|
|
16
|
+
jsc: {
|
|
17
|
+
loose: false,
|
|
18
|
+
target: 'es5',
|
|
19
|
+
externalHelpers: false,
|
|
20
|
+
parser: {
|
|
21
|
+
syntax: 'ecmascript',
|
|
22
|
+
},
|
|
23
|
+
transform: {},
|
|
24
|
+
},
|
|
25
|
+
}).code;
|
|
26
|
+
};
|
|
27
|
+
const computeRemoteFilename = (isServer, filename) => {
|
|
28
|
+
if (isServer && filename) {
|
|
29
|
+
return path_1.default.basename(filename);
|
|
30
|
+
}
|
|
31
|
+
return filename;
|
|
32
|
+
};
|
|
33
|
+
exports.computeRemoteFilename = computeRemoteFilename;
|
|
34
|
+
//remote is defined in the template wrapper
|
|
35
|
+
const remoteTemplate = function () {
|
|
36
|
+
const index = urlAndGlobal.indexOf('@');
|
|
37
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
38
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
39
|
+
}
|
|
40
|
+
var remote = {
|
|
41
|
+
url: urlAndGlobal.substring(index + 1),
|
|
42
|
+
global: urlAndGlobal.substring(0, index), // this casting to satisfy TS
|
|
43
|
+
};
|
|
44
|
+
return new Promise(function (resolve, reject) {
|
|
45
|
+
const __webpack_error__ = new Error();
|
|
46
|
+
if (typeof window[remote.global] !== 'undefined') {
|
|
47
|
+
return resolve();
|
|
48
|
+
}
|
|
49
|
+
__webpack_require__.l(remote.url, function (event) {
|
|
50
|
+
if (typeof window[remote.global] !== 'undefined') {
|
|
51
|
+
return resolve();
|
|
52
|
+
}
|
|
53
|
+
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
54
|
+
var realSrc = event && event.target && event.target.src;
|
|
55
|
+
__webpack_error__.message =
|
|
56
|
+
'Loading script failed.(' +
|
|
57
|
+
errorType +
|
|
58
|
+
': ' +
|
|
59
|
+
realSrc +
|
|
60
|
+
' or global var ' +
|
|
61
|
+
remote.global +
|
|
62
|
+
')';
|
|
63
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
64
|
+
__webpack_error__.type = errorType;
|
|
65
|
+
__webpack_error__.request = realSrc;
|
|
66
|
+
reject(__webpack_error__);
|
|
67
|
+
}, remote.global);
|
|
68
|
+
}).then(function () {
|
|
69
|
+
const remoteGlobal = window[remote.global];
|
|
70
|
+
const proxy = {
|
|
71
|
+
get: remoteGlobal.get,
|
|
72
|
+
//@ts-ignore
|
|
73
|
+
init: function (shareScope) {
|
|
74
|
+
const handler = {
|
|
75
|
+
get(target, prop) {
|
|
76
|
+
if (target[prop]) {
|
|
77
|
+
Object.values(target[prop]).forEach(function (o) {
|
|
78
|
+
if (o.from === '_N_E') {
|
|
79
|
+
o.loaded = 1;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return target[prop];
|
|
84
|
+
},
|
|
85
|
+
set(target, property, value, receiver) {
|
|
86
|
+
if (target[property]) {
|
|
87
|
+
return target[property];
|
|
88
|
+
}
|
|
89
|
+
target[property] = value;
|
|
90
|
+
return true;
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
remoteGlobal.init(new Proxy(shareScope, handler));
|
|
95
|
+
}
|
|
96
|
+
catch (e) { }
|
|
97
|
+
remoteGlobal.__initialized = true;
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
if (!remoteGlobal.__initialized) {
|
|
101
|
+
proxy.init();
|
|
102
|
+
}
|
|
103
|
+
return proxy;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const promiseFactory = (factory) => {
|
|
107
|
+
const wrapper = `new Promise(${factory.toString()})`;
|
|
108
|
+
const isPromiseFactoryIncludesImportOrRequireContext = [
|
|
109
|
+
'require(',
|
|
110
|
+
'import(',
|
|
111
|
+
'import ',
|
|
112
|
+
].some((statement) => wrapper.includes(statement));
|
|
113
|
+
if (isPromiseFactoryIncludesImportOrRequireContext) {
|
|
114
|
+
throw new Error('promiseFactory does not support require, import, or import statements');
|
|
115
|
+
}
|
|
116
|
+
const template = Template_1.default.asString([
|
|
117
|
+
'function() {',
|
|
118
|
+
Template_1.default.indent([wrapper]),
|
|
119
|
+
'}',
|
|
120
|
+
]);
|
|
121
|
+
return template;
|
|
122
|
+
};
|
|
123
|
+
exports.promiseFactory = promiseFactory;
|
|
124
|
+
const promiseTemplate = (remote, ...otherPromises) => {
|
|
125
|
+
let promises = [];
|
|
126
|
+
if (otherPromises) {
|
|
127
|
+
promises = otherPromises.map((p) => {
|
|
128
|
+
return Template_1.default.getFunctionContent((0, exports.promiseFactory)(p));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
let remoteSyntax = remote;
|
|
132
|
+
let remoteFactory = internal_1.parseRemoteSyntax;
|
|
133
|
+
if (typeof remote === 'function' ||
|
|
134
|
+
remote.startsWith('function') ||
|
|
135
|
+
remote.startsWith('(')) {
|
|
136
|
+
remoteSyntax = Template_1.default.getFunctionContent((0, exports.promiseFactory)(remote));
|
|
137
|
+
remoteFactory = (remoteSyntax) => {
|
|
138
|
+
return Template_1.default.asString([
|
|
139
|
+
`${remoteSyntax}.then(function(urlAndGlobal) {`,
|
|
140
|
+
Template_1.default.indent([Template_1.default.getFunctionContent(remoteTemplate)]),
|
|
141
|
+
'})',
|
|
142
|
+
]);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
const allPromises = [remoteFactory(remoteSyntax), ...promises].join(',\n');
|
|
146
|
+
return Template_1.default.asString([
|
|
147
|
+
'promise new Promise(function(resolve, reject) {',
|
|
148
|
+
transformInput(Template_1.default.indent([
|
|
149
|
+
'Promise.all([',
|
|
150
|
+
Template_1.default.indent(allPromises),
|
|
151
|
+
']).then(function(promises) {',
|
|
152
|
+
Template_1.default.indent(['resolve(promises[0]);']),
|
|
153
|
+
'})',
|
|
154
|
+
])),
|
|
155
|
+
'})',
|
|
156
|
+
]);
|
|
157
|
+
};
|
|
158
|
+
exports.promiseTemplate = promiseTemplate;
|
|
159
|
+
// remotes: {
|
|
160
|
+
// shop: promiseTemplate('global@url', (resolve,reject) => {}),
|
|
161
|
+
// shop: promiseTemplate(
|
|
162
|
+
// // can also be a string if it needs to be computed in scope
|
|
163
|
+
// `(resolve, reject) => {
|
|
164
|
+
// resolve("${remotes.shop}");
|
|
165
|
+
// }`,
|
|
166
|
+
// (resolve,reject)=>{
|
|
167
|
+
// console.log('runing other promise');
|
|
168
|
+
// setTimeout(() => {
|
|
169
|
+
// console.log('resolving promise');
|
|
170
|
+
// resolve();
|
|
171
|
+
// } , 1000);
|
|
172
|
+
// }),
|
|
173
|
+
// checkout: remotes.checkout,
|
|
174
|
+
// },
|
|
175
|
+
//# sourceMappingURL=build-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-utils.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/utils/build-utils.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAClC,8CAAoD;AAEpD,wDAAwB;AAExB,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEjC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAE,EAAE;IACtC,OAAO,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE;QAC7B,6CAA6C;QAC7C,UAAU,EAAE,KAAK;QACjB,gDAAgD;QAChD,QAAQ,EAAE,KAAK;QACf,iDAAiD;QACjD,GAAG,EAAE;YACH,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,KAAK;YACb,eAAe,EAAE,KAAK;YACtB,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;aACrB;YACD,SAAS,EAAE,EAAE;SACd;KACF,CAAC,CAAC,IAAI,CAAC;AACV,CAAC,CAAC;AAEK,MAAM,qBAAqB,GAAG,CAAC,QAAiB,EAAE,QAAgB,EAAE,EAAE;IAC3E,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAChC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC;AAIF,2CAA2C;AAC3C,MAAM,cAAc,GAAG;IACrB,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAExC,IAAI,KAAK,IAAI,CAAC,I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AAa,GAAG,CAAC,YAAY,EAAE,EAAE;YAC/B,OAAO,kBAAQ,CAAC,QAAQ,CAAC;gBACvB,GAAG,YAAY,gCAAgC;gBAC/C,kBAAQ,CAAC,MAAM,CAAC,CAAC,kBAAQ,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC;gBAC9D,IAAI;aACL,CAAC,CAAC;QACL,CAAC,CAAC;KACH;IAED,MAAM,WAAW,GAAG,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE3E,OAAO,kBAAQ,CAAC,QAAQ,CAAC;QACvB,iDAAiD;QACjD,cAAc,CACZ,kBAAQ,CAAC,MAAM,CAAC;YACd,eAAe;YACf,kBAAQ,CAAC,MAAM,CAAC,WAAW,CAAC;YAC5B,8BAA8B;YAC9B,kBAAQ,CAAC,MAAM,CAAC,CAAC,uBAAuB,CAAC,CAAC;YAC1C,IAAI;SACL,CAAC,CACH;QACD,IAAI;KACL,CAAC,CAAC;AACL,CAAC,CAAC;AAlDW,QAAA,eAAe,mBAkD1B;AAEF,aAAa;AACb,iEAAiE;AACjE,6BAA6B;AAC7B,kEAAkE;AAClE,8BAA8B;AAC9B,8CAA8C;AAC9C,oBAAoB;AACpB,0BAA0B;AAC1B,6CAA6C;AAC7C,2BAA2B;AAC3B,4CAA4C;AAC5C,qBAAqB;AACrB,mBAAmB;AACnB,UAAU;AACV,kCAAkC;AAClC,KAAK"}
|
package/utils/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { extractUrlAndGlobal, injectScript } from '@module-federation/utilities';
|
package/utils/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.injectScript = exports.extractUrlAndGlobal = void 0;
|
|
4
|
+
var utilities_1 = require("@module-federation/utilities");
|
|
5
|
+
Object.defineProperty(exports, "extractUrlAndGlobal", { enumerable: true, get: function () { return utilities_1.extractUrlAndGlobal; } });
|
|
6
|
+
Object.defineProperty(exports, "injectScript", { enumerable: true, get: function () { return utilities_1.injectScript; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nextjs-mf/utils/index.ts"],"names":[],"mappings":";;;AAAA,0DAAiF;AAAxE,gHAAA,mBAAmB,OAAA;AAAE,yGAAA,YAAY,OAAA"}
|
package/.prettierignore
DELETED
package/.prettierrc
DELETED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 ScriptedAlchemy LLC (Zack Jackson)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
7
|
-
Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
/*
|
|
12
|
-
plugin was copied over because ContainerPlugin is called in compiler.hooks.afterPlugins which doest seem to work in child compiler
|
|
13
|
-
*/
|
|
14
|
-
/** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ExternalsType} ExternalsType */
|
|
15
|
-
/** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ModuleFederationPluginOptions} ModuleFederationPluginOptions */
|
|
16
|
-
|
|
17
|
-
/** @typedef {import("webpack").Shared} Shared */
|
|
18
|
-
/** @typedef {import("webpack").Compiler} Compiler */
|
|
19
|
-
|
|
20
|
-
class ModuleFederationPlugin {
|
|
21
|
-
/**
|
|
22
|
-
* @param {ModuleFederationPluginOptions} options options
|
|
23
|
-
*/
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this._options = options;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Apply the plugin
|
|
30
|
-
* @param {Compiler} compiler the compiler instance
|
|
31
|
-
* @returns {void}
|
|
32
|
-
*/
|
|
33
|
-
apply(compiler) {
|
|
34
|
-
const { _options: options } = this;
|
|
35
|
-
const webpack = compiler.webpack;
|
|
36
|
-
const { ContainerPlugin, ContainerReferencePlugin } = webpack.container;
|
|
37
|
-
const { SharePlugin } = webpack.sharing;
|
|
38
|
-
const library = options.library || { type: 'var', name: options.name };
|
|
39
|
-
const remoteType =
|
|
40
|
-
options.remoteType ||
|
|
41
|
-
(options.library && /** @type {ExternalsType} */ options.library.type) ||
|
|
42
|
-
'script';
|
|
43
|
-
if (
|
|
44
|
-
library &&
|
|
45
|
-
!compiler.options.output.enabledLibraryTypes.includes(library.type)
|
|
46
|
-
) {
|
|
47
|
-
compiler.options.output.enabledLibraryTypes.push(library.type);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
options.exposes &&
|
|
52
|
-
(Array.isArray(options.exposes)
|
|
53
|
-
? options.exposes.length > 0
|
|
54
|
-
: Object.keys(options.exposes).length > 0)
|
|
55
|
-
) {
|
|
56
|
-
new ContainerPlugin({
|
|
57
|
-
name: options.name,
|
|
58
|
-
library,
|
|
59
|
-
filename: options.filename,
|
|
60
|
-
runtime: options.runtime,
|
|
61
|
-
exposes: options.exposes,
|
|
62
|
-
}).apply(compiler);
|
|
63
|
-
}
|
|
64
|
-
if (
|
|
65
|
-
options.remotes &&
|
|
66
|
-
(Array.isArray(options.remotes)
|
|
67
|
-
? options.remotes.length > 0
|
|
68
|
-
: Object.keys(options.remotes).length > 0)
|
|
69
|
-
) {
|
|
70
|
-
new ContainerReferencePlugin({
|
|
71
|
-
remoteType,
|
|
72
|
-
remotes: options.remotes,
|
|
73
|
-
}).apply(compiler);
|
|
74
|
-
}
|
|
75
|
-
if (options.shared) {
|
|
76
|
-
new SharePlugin({
|
|
77
|
-
shared: options.shared,
|
|
78
|
-
shareScope: options.shareScope,
|
|
79
|
-
}).apply(compiler);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports["default"] = ModuleFederationPlugin;
|