@module-federation/webpack-bundler-runtime 0.9.0 → 0.9.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/dist/constant.cjs.js +1 -9
- package/dist/constant.esm.mjs +1 -5
- package/dist/index.cjs.js +135 -75
- package/dist/index.esm.mjs +134 -74
- package/dist/src/constant.d.ts +0 -1
- package/dist/src/container.d.ts +0 -9
- package/package.json +4 -8
- package/dist/container.cjs.d.ts +0 -1
- package/dist/container.cjs.js +0 -196
- package/dist/container.esm.d.ts +0 -1
- package/dist/container.esm.mjs +0 -193
- package/dist/polyfills.cjs.js +0 -14
- package/dist/polyfills.esm.mjs +0 -12
package/dist/constant.cjs.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const FEDERATION_SUPPORTED_TYPES = ['script'];
|
|
4
4
|
|
|
5
|
-
const FEDERATION_SUPPORTED_TYPES = [
|
|
6
|
-
'script'
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, "ENCODE_NAME_PREFIX", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return sdk.ENCODE_NAME_PREFIX; }
|
|
12
|
-
});
|
|
13
5
|
exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
|
package/dist/constant.esm.mjs
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var runtime = require('@module-federation/runtime');
|
|
4
4
|
var constant = require('./constant.cjs.js');
|
|
5
|
-
var sdk = require('@module-federation/sdk');
|
|
6
|
-
var polyfills = require('./polyfills.cjs.js');
|
|
7
5
|
|
|
8
6
|
function _interopNamespaceDefault(e) {
|
|
9
7
|
var n = Object.create(null);
|
|
@@ -25,18 +23,54 @@ function _interopNamespaceDefault(e) {
|
|
|
25
23
|
var runtime__namespace = /*#__PURE__*/_interopNamespaceDefault(runtime);
|
|
26
24
|
|
|
27
25
|
function attachShareScopeMap(webpackRequire) {
|
|
28
|
-
if (!webpackRequire.S ||
|
|
26
|
+
if (!webpackRequire.S ||
|
|
27
|
+
webpackRequire.federation.hasAttachShareScopeMap ||
|
|
28
|
+
!webpackRequire.federation.instance ||
|
|
29
|
+
!webpackRequire.federation.instance.shareScopeMap) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
|
|
32
33
|
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
const NameTransformSymbol = {
|
|
37
|
+
AT: '@',
|
|
38
|
+
HYPHEN: '-',
|
|
39
|
+
SLASH: '/'
|
|
40
|
+
};
|
|
41
|
+
const NameTransformMap = {
|
|
42
|
+
[NameTransformSymbol.AT]: 'scope_',
|
|
43
|
+
[NameTransformSymbol.HYPHEN]: '_',
|
|
44
|
+
[NameTransformSymbol.SLASH]: '__'
|
|
45
|
+
};
|
|
46
|
+
const EncodedNameTransformMap = {
|
|
47
|
+
[NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
|
|
48
|
+
[NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
|
|
49
|
+
[NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
|
|
50
|
+
};
|
|
51
|
+
const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
52
|
+
const decodeName = function(name, prefix, withExt) {
|
|
53
|
+
try {
|
|
54
|
+
let decodedName = name;
|
|
55
|
+
if (prefix) {
|
|
56
|
+
if (!decodedName.startsWith(prefix)) {
|
|
57
|
+
return decodedName;
|
|
58
|
+
}
|
|
59
|
+
decodedName = decodedName.replace(new RegExp(prefix, 'g'), '');
|
|
60
|
+
}
|
|
61
|
+
decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
|
|
62
|
+
if (withExt) ;
|
|
63
|
+
return decodedName;
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
35
69
|
function remotes(options) {
|
|
36
|
-
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options;
|
|
70
|
+
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap, } = options;
|
|
37
71
|
attachShareScopeMap(webpackRequire);
|
|
38
72
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
39
|
-
chunkMapping[chunkId].forEach((id)=>{
|
|
73
|
+
chunkMapping[chunkId].forEach((id) => {
|
|
40
74
|
let getScope = webpackRequire.R;
|
|
41
75
|
if (!getScope) {
|
|
42
76
|
getScope = [];
|
|
@@ -52,68 +86,77 @@ function remotes(options) {
|
|
|
52
86
|
if (data.p) {
|
|
53
87
|
return promises.push(data.p);
|
|
54
88
|
}
|
|
55
|
-
const onError = (error)=>{
|
|
89
|
+
const onError = (error) => {
|
|
56
90
|
if (!error) {
|
|
57
91
|
error = new Error('Container missing');
|
|
58
92
|
}
|
|
59
93
|
if (typeof error.message === 'string') {
|
|
60
94
|
error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
|
|
61
95
|
}
|
|
62
|
-
webpackRequire.m[id] = ()=>{
|
|
96
|
+
webpackRequire.m[id] = () => {
|
|
63
97
|
throw error;
|
|
64
98
|
};
|
|
65
99
|
data.p = 0;
|
|
66
100
|
};
|
|
67
|
-
const handleFunction = (fn, arg1, arg2, d, next, first)=>{
|
|
101
|
+
const handleFunction = (fn, arg1, arg2, d, next, first) => {
|
|
68
102
|
try {
|
|
69
103
|
const promise = fn(arg1, arg2);
|
|
70
104
|
if (promise && promise.then) {
|
|
71
|
-
const p = promise.then((result)=>next(result, d), onError);
|
|
105
|
+
const p = promise.then((result) => next(result, d), onError);
|
|
72
106
|
if (first) {
|
|
73
|
-
promises.push(data.p = p);
|
|
74
|
-
}
|
|
107
|
+
promises.push((data.p = p));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
75
110
|
return p;
|
|
76
111
|
}
|
|
77
|
-
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
78
114
|
return next(promise, d, first);
|
|
79
115
|
}
|
|
80
|
-
}
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
81
118
|
onError(error);
|
|
82
119
|
}
|
|
83
120
|
};
|
|
84
|
-
const onExternal = (external, _, first)=>
|
|
121
|
+
const onExternal = (external, _, first) => external
|
|
122
|
+
? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first)
|
|
123
|
+
: onError();
|
|
85
124
|
// eslint-disable-next-line no-var
|
|
86
|
-
var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
125
|
+
var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
87
126
|
// eslint-disable-next-line no-var
|
|
88
|
-
var onFactory = (factory)=>{
|
|
127
|
+
var onFactory = (factory) => {
|
|
89
128
|
data.p = 1;
|
|
90
|
-
webpackRequire.m[id] = (module)=>{
|
|
129
|
+
webpackRequire.m[id] = (module) => {
|
|
91
130
|
module.exports = factory();
|
|
92
131
|
};
|
|
93
132
|
};
|
|
94
|
-
const onRemoteLoaded = ()=>{
|
|
133
|
+
const onRemoteLoaded = () => {
|
|
95
134
|
try {
|
|
96
|
-
const remoteName =
|
|
135
|
+
const remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
|
|
97
136
|
const remoteModuleName = remoteName + data[1].slice(1);
|
|
98
137
|
const instance = webpackRequire.federation.instance;
|
|
99
|
-
const loadRemote = ()=>webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
138
|
+
const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
139
|
+
loadFactory: false,
|
|
140
|
+
from: 'build',
|
|
141
|
+
});
|
|
103
142
|
if (instance.options.shareStrategy === 'version-first') {
|
|
104
|
-
return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(()=>{
|
|
143
|
+
return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(() => {
|
|
105
144
|
return loadRemote();
|
|
106
145
|
});
|
|
107
146
|
}
|
|
108
147
|
return loadRemote();
|
|
109
|
-
}
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
110
150
|
onError(error);
|
|
111
151
|
}
|
|
112
152
|
};
|
|
113
|
-
const useRuntimeLoad = remoteInfos.length === 1 &&
|
|
153
|
+
const useRuntimeLoad = remoteInfos.length === 1 &&
|
|
154
|
+
constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) &&
|
|
155
|
+
remoteInfos[0].name;
|
|
114
156
|
if (useRuntimeLoad) {
|
|
115
157
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
116
|
-
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
117
160
|
handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
|
|
118
161
|
}
|
|
119
162
|
});
|
|
@@ -121,23 +164,23 @@ function remotes(options) {
|
|
|
121
164
|
}
|
|
122
165
|
|
|
123
166
|
function consumes(options) {
|
|
124
|
-
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options;
|
|
167
|
+
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire, } = options;
|
|
125
168
|
attachShareScopeMap(webpackRequire);
|
|
126
169
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
127
|
-
chunkMapping[chunkId].forEach((id)=>{
|
|
170
|
+
chunkMapping[chunkId].forEach((id) => {
|
|
128
171
|
if (webpackRequire.o(installedModules, id)) {
|
|
129
172
|
return promises.push(installedModules[id]);
|
|
130
173
|
}
|
|
131
|
-
const onFactory = (factory)=>{
|
|
174
|
+
const onFactory = (factory) => {
|
|
132
175
|
installedModules[id] = 0;
|
|
133
|
-
webpackRequire.m[id] = (module)=>{
|
|
176
|
+
webpackRequire.m[id] = (module) => {
|
|
134
177
|
delete webpackRequire.c[id];
|
|
135
178
|
module.exports = factory();
|
|
136
179
|
};
|
|
137
180
|
};
|
|
138
|
-
const onError = (error)=>{
|
|
181
|
+
const onError = (error) => {
|
|
139
182
|
delete installedModules[id];
|
|
140
|
-
webpackRequire.m[id] = (module)=>{
|
|
183
|
+
webpackRequire.m[id] = (module) => {
|
|
141
184
|
delete webpackRequire.c[id];
|
|
142
185
|
throw error;
|
|
143
186
|
};
|
|
@@ -148,70 +191,81 @@ function consumes(options) {
|
|
|
148
191
|
throw new Error('Federation instance not found!');
|
|
149
192
|
}
|
|
150
193
|
const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id];
|
|
151
|
-
const promise = federationInstance
|
|
152
|
-
customShareInfo: shareInfo
|
|
153
|
-
|
|
194
|
+
const promise = federationInstance
|
|
195
|
+
.loadShare(shareKey, { customShareInfo: shareInfo })
|
|
196
|
+
.then((factory) => {
|
|
154
197
|
if (factory === false) {
|
|
155
198
|
return getter();
|
|
156
199
|
}
|
|
157
200
|
return factory;
|
|
158
201
|
});
|
|
159
202
|
if (promise.then) {
|
|
160
|
-
promises.push(installedModules[id] = promise.then(onFactory).catch(onError));
|
|
161
|
-
}
|
|
203
|
+
promises.push((installedModules[id] = promise.then(onFactory).catch(onError)));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
162
206
|
// @ts-ignore maintain previous logic
|
|
163
207
|
onFactory(promise);
|
|
164
208
|
}
|
|
165
|
-
}
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
166
211
|
onError(e);
|
|
167
212
|
}
|
|
168
213
|
});
|
|
169
214
|
}
|
|
170
215
|
}
|
|
171
216
|
|
|
172
|
-
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
|
|
173
|
-
if (!initScope)
|
|
217
|
+
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope, }) {
|
|
218
|
+
if (!initScope)
|
|
219
|
+
initScope = [];
|
|
174
220
|
const mfInstance = webpackRequire.federation.instance;
|
|
175
221
|
// handling circular init calls
|
|
176
222
|
var initToken = initTokens[shareScopeName];
|
|
177
|
-
if (!initToken)
|
|
178
|
-
from: mfInstance.name
|
|
179
|
-
|
|
180
|
-
|
|
223
|
+
if (!initToken)
|
|
224
|
+
initToken = initTokens[shareScopeName] = { from: mfInstance.name };
|
|
225
|
+
if (initScope.indexOf(initToken) >= 0)
|
|
226
|
+
return;
|
|
181
227
|
initScope.push(initToken);
|
|
182
228
|
const promise = initPromises[shareScopeName];
|
|
183
|
-
if (promise)
|
|
184
|
-
|
|
185
|
-
var
|
|
186
|
-
|
|
229
|
+
if (promise)
|
|
230
|
+
return promise;
|
|
231
|
+
var warn = (msg) => typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
232
|
+
var initExternal = (id) => {
|
|
233
|
+
var handleError = (err) => warn('Initialization of sharing external failed: ' + err);
|
|
187
234
|
try {
|
|
188
235
|
var module = webpackRequire(id);
|
|
189
|
-
if (!module)
|
|
190
|
-
|
|
236
|
+
if (!module)
|
|
237
|
+
return;
|
|
238
|
+
var initFn = (module) => module &&
|
|
239
|
+
module.init &&
|
|
240
|
+
// @ts-ignore compat legacy mf shared behavior
|
|
191
241
|
module.init(webpackRequire.S[shareScopeName], initScope);
|
|
192
|
-
if (module.then)
|
|
242
|
+
if (module.then)
|
|
243
|
+
return promises.push(module.then(initFn, handleError));
|
|
193
244
|
var initResult = initFn(module);
|
|
194
245
|
// @ts-ignore
|
|
195
|
-
if (initResult && typeof initResult !== 'boolean' && initResult.then)
|
|
196
|
-
|
|
197
|
-
|
|
246
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then)
|
|
247
|
+
// @ts-ignore
|
|
248
|
+
return promises.push(initResult['catch'](handleError));
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
198
251
|
handleError(err);
|
|
199
252
|
}
|
|
200
253
|
};
|
|
201
254
|
const promises = mfInstance.initializeSharing(shareScopeName, {
|
|
202
255
|
strategy: mfInstance.options.shareStrategy,
|
|
203
256
|
initScope,
|
|
204
|
-
from: 'build'
|
|
257
|
+
from: 'build',
|
|
205
258
|
});
|
|
206
259
|
attachShareScopeMap(webpackRequire);
|
|
207
260
|
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
|
|
208
261
|
if (bundlerRuntimeRemotesOptions) {
|
|
209
|
-
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{
|
|
262
|
+
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId) => {
|
|
210
263
|
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
|
|
211
264
|
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
|
|
212
265
|
if (info.length > 1) {
|
|
213
266
|
initExternal(externalModuleId);
|
|
214
|
-
}
|
|
267
|
+
}
|
|
268
|
+
else if (info.length === 1) {
|
|
215
269
|
const remoteInfo = info[0];
|
|
216
270
|
if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
217
271
|
initExternal(externalModuleId);
|
|
@@ -220,9 +274,9 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
|
|
|
220
274
|
});
|
|
221
275
|
}
|
|
222
276
|
if (!promises.length) {
|
|
223
|
-
return initPromises[shareScopeName] = true;
|
|
277
|
+
return (initPromises[shareScopeName] = true);
|
|
224
278
|
}
|
|
225
|
-
return initPromises[shareScopeName] = Promise.all(promises).then(()=>initPromises[shareScopeName] = true);
|
|
279
|
+
return (initPromises[shareScopeName] = Promise.all(promises).then(() => (initPromises[shareScopeName] = true)));
|
|
226
280
|
}
|
|
227
281
|
|
|
228
282
|
function handleInitialConsumes(options) {
|
|
@@ -234,25 +288,26 @@ function handleInitialConsumes(options) {
|
|
|
234
288
|
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
|
|
235
289
|
try {
|
|
236
290
|
return federationInstance.loadShareSync(shareKey, {
|
|
237
|
-
customShareInfo: shareInfo
|
|
291
|
+
customShareInfo: shareInfo,
|
|
238
292
|
});
|
|
239
|
-
}
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
240
295
|
console.error('loadShareSync failed! The function should not be called unless you set "eager:true". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.');
|
|
241
296
|
console.error('The original error message is as follows: ');
|
|
242
297
|
throw err;
|
|
243
298
|
}
|
|
244
299
|
}
|
|
245
300
|
function installInitialConsumes(options) {
|
|
246
|
-
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
|
|
247
|
-
initialConsumes.forEach((id)=>{
|
|
248
|
-
webpackRequire.m[id] = (module)=>{
|
|
301
|
+
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes, } = options;
|
|
302
|
+
initialConsumes.forEach((id) => {
|
|
303
|
+
webpackRequire.m[id] = (module) => {
|
|
249
304
|
// Handle scenario when module is used synchronously
|
|
250
305
|
installedModules[id] = 0;
|
|
251
306
|
delete webpackRequire.c[id];
|
|
252
307
|
const factory = handleInitialConsumes({
|
|
253
308
|
moduleId: id,
|
|
254
309
|
moduleToHandlerMapping,
|
|
255
|
-
webpackRequire
|
|
310
|
+
webpackRequire,
|
|
256
311
|
});
|
|
257
312
|
if (typeof factory !== 'function') {
|
|
258
313
|
throw new Error(`Shared module is not available for eager consumption: ${id}`);
|
|
@@ -263,17 +318,22 @@ function installInitialConsumes(options) {
|
|
|
263
318
|
}
|
|
264
319
|
|
|
265
320
|
function initContainerEntry(options) {
|
|
266
|
-
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
|
|
267
|
-
if (!webpackRequire.S)
|
|
268
|
-
|
|
321
|
+
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions, } = options;
|
|
322
|
+
if (!webpackRequire.S)
|
|
323
|
+
return;
|
|
324
|
+
if (!webpackRequire.federation ||
|
|
325
|
+
!webpackRequire.federation.instance ||
|
|
326
|
+
!webpackRequire.federation.initOptions)
|
|
327
|
+
return;
|
|
269
328
|
const federationInstance = webpackRequire.federation.instance;
|
|
270
329
|
var name = shareScopeKey || 'default';
|
|
271
|
-
federationInstance.initOptions(
|
|
330
|
+
federationInstance.initOptions({
|
|
272
331
|
name: webpackRequire.federation.initOptions.name,
|
|
273
|
-
remotes: []
|
|
274
|
-
|
|
332
|
+
remotes: [],
|
|
333
|
+
...remoteEntryInitOptions,
|
|
334
|
+
});
|
|
275
335
|
federationInstance.initShareScopeMap(name, shareScope, {
|
|
276
|
-
hostShareScopeMap:
|
|
336
|
+
hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
|
|
277
337
|
});
|
|
278
338
|
if (webpackRequire.federation.attachShareScopeMap) {
|
|
279
339
|
webpackRequire.federation.attachShareScopeMap(webpackRequire);
|
|
@@ -295,10 +355,10 @@ const federation = {
|
|
|
295
355
|
I: initializeSharing,
|
|
296
356
|
S: {},
|
|
297
357
|
installInitialConsumes,
|
|
298
|
-
initContainerEntry
|
|
358
|
+
initContainerEntry,
|
|
299
359
|
},
|
|
300
360
|
attachShareScopeMap,
|
|
301
|
-
bundlerRuntimeOptions: {}
|
|
361
|
+
bundlerRuntimeOptions: {},
|
|
302
362
|
};
|
|
303
363
|
|
|
304
364
|
module.exports = federation;
|
package/dist/index.esm.mjs
CHANGED
|
@@ -1,21 +1,55 @@
|
|
|
1
1
|
import * as runtime from '@module-federation/runtime';
|
|
2
2
|
import { FEDERATION_SUPPORTED_TYPES } from './constant.esm.mjs';
|
|
3
|
-
import { decodeName, ENCODE_NAME_PREFIX } from '@module-federation/sdk';
|
|
4
|
-
import { _ as _extends } from './polyfills.esm.mjs';
|
|
5
3
|
|
|
6
4
|
function attachShareScopeMap(webpackRequire) {
|
|
7
|
-
if (!webpackRequire.S ||
|
|
5
|
+
if (!webpackRequire.S ||
|
|
6
|
+
webpackRequire.federation.hasAttachShareScopeMap ||
|
|
7
|
+
!webpackRequire.federation.instance ||
|
|
8
|
+
!webpackRequire.federation.instance.shareScopeMap) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
|
|
11
12
|
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
const NameTransformSymbol = {
|
|
16
|
+
AT: '@',
|
|
17
|
+
HYPHEN: '-',
|
|
18
|
+
SLASH: '/'
|
|
19
|
+
};
|
|
20
|
+
const NameTransformMap = {
|
|
21
|
+
[NameTransformSymbol.AT]: 'scope_',
|
|
22
|
+
[NameTransformSymbol.HYPHEN]: '_',
|
|
23
|
+
[NameTransformSymbol.SLASH]: '__'
|
|
24
|
+
};
|
|
25
|
+
const EncodedNameTransformMap = {
|
|
26
|
+
[NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
|
|
27
|
+
[NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
|
|
28
|
+
[NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
|
|
29
|
+
};
|
|
30
|
+
const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
31
|
+
const decodeName = function(name, prefix, withExt) {
|
|
32
|
+
try {
|
|
33
|
+
let decodedName = name;
|
|
34
|
+
if (prefix) {
|
|
35
|
+
if (!decodedName.startsWith(prefix)) {
|
|
36
|
+
return decodedName;
|
|
37
|
+
}
|
|
38
|
+
decodedName = decodedName.replace(new RegExp(prefix, 'g'), '');
|
|
39
|
+
}
|
|
40
|
+
decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
|
|
41
|
+
if (withExt) ;
|
|
42
|
+
return decodedName;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
14
48
|
function remotes(options) {
|
|
15
|
-
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap } = options;
|
|
49
|
+
const { chunkId, promises, chunkMapping, idToExternalAndNameMapping, webpackRequire, idToRemoteMap, } = options;
|
|
16
50
|
attachShareScopeMap(webpackRequire);
|
|
17
51
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
18
|
-
chunkMapping[chunkId].forEach((id)=>{
|
|
52
|
+
chunkMapping[chunkId].forEach((id) => {
|
|
19
53
|
let getScope = webpackRequire.R;
|
|
20
54
|
if (!getScope) {
|
|
21
55
|
getScope = [];
|
|
@@ -31,68 +65,77 @@ function remotes(options) {
|
|
|
31
65
|
if (data.p) {
|
|
32
66
|
return promises.push(data.p);
|
|
33
67
|
}
|
|
34
|
-
const onError = (error)=>{
|
|
68
|
+
const onError = (error) => {
|
|
35
69
|
if (!error) {
|
|
36
70
|
error = new Error('Container missing');
|
|
37
71
|
}
|
|
38
72
|
if (typeof error.message === 'string') {
|
|
39
73
|
error.message += `\nwhile loading "${data[1]}" from ${data[2]}`;
|
|
40
74
|
}
|
|
41
|
-
webpackRequire.m[id] = ()=>{
|
|
75
|
+
webpackRequire.m[id] = () => {
|
|
42
76
|
throw error;
|
|
43
77
|
};
|
|
44
78
|
data.p = 0;
|
|
45
79
|
};
|
|
46
|
-
const handleFunction = (fn, arg1, arg2, d, next, first)=>{
|
|
80
|
+
const handleFunction = (fn, arg1, arg2, d, next, first) => {
|
|
47
81
|
try {
|
|
48
82
|
const promise = fn(arg1, arg2);
|
|
49
83
|
if (promise && promise.then) {
|
|
50
|
-
const p = promise.then((result)=>next(result, d), onError);
|
|
84
|
+
const p = promise.then((result) => next(result, d), onError);
|
|
51
85
|
if (first) {
|
|
52
|
-
promises.push(data.p = p);
|
|
53
|
-
}
|
|
86
|
+
promises.push((data.p = p));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
54
89
|
return p;
|
|
55
90
|
}
|
|
56
|
-
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
57
93
|
return next(promise, d, first);
|
|
58
94
|
}
|
|
59
|
-
}
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
60
97
|
onError(error);
|
|
61
98
|
}
|
|
62
99
|
};
|
|
63
|
-
const onExternal = (external, _, first)=>
|
|
100
|
+
const onExternal = (external, _, first) => external
|
|
101
|
+
? handleFunction(webpackRequire.I, data[0], 0, external, onInitialized, first)
|
|
102
|
+
: onError();
|
|
64
103
|
// eslint-disable-next-line no-var
|
|
65
|
-
var onInitialized = (_, external, first)=>handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
104
|
+
var onInitialized = (_, external, first) => handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
66
105
|
// eslint-disable-next-line no-var
|
|
67
|
-
var onFactory = (factory)=>{
|
|
106
|
+
var onFactory = (factory) => {
|
|
68
107
|
data.p = 1;
|
|
69
|
-
webpackRequire.m[id] = (module)=>{
|
|
108
|
+
webpackRequire.m[id] = (module) => {
|
|
70
109
|
module.exports = factory();
|
|
71
110
|
};
|
|
72
111
|
};
|
|
73
|
-
const onRemoteLoaded = ()=>{
|
|
112
|
+
const onRemoteLoaded = () => {
|
|
74
113
|
try {
|
|
75
114
|
const remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
|
|
76
115
|
const remoteModuleName = remoteName + data[1].slice(1);
|
|
77
116
|
const instance = webpackRequire.federation.instance;
|
|
78
|
-
const loadRemote = ()=>webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
const loadRemote = () => webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
118
|
+
loadFactory: false,
|
|
119
|
+
from: 'build',
|
|
120
|
+
});
|
|
82
121
|
if (instance.options.shareStrategy === 'version-first') {
|
|
83
|
-
return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(()=>{
|
|
122
|
+
return Promise.all(instance.sharedHandler.initializeSharing(data[0])).then(() => {
|
|
84
123
|
return loadRemote();
|
|
85
124
|
});
|
|
86
125
|
}
|
|
87
126
|
return loadRemote();
|
|
88
|
-
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
89
129
|
onError(error);
|
|
90
130
|
}
|
|
91
131
|
};
|
|
92
|
-
const useRuntimeLoad = remoteInfos.length === 1 &&
|
|
132
|
+
const useRuntimeLoad = remoteInfos.length === 1 &&
|
|
133
|
+
FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) &&
|
|
134
|
+
remoteInfos[0].name;
|
|
93
135
|
if (useRuntimeLoad) {
|
|
94
136
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
95
|
-
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
96
139
|
handleFunction(webpackRequire, data[2], 0, 0, onExternal, 1);
|
|
97
140
|
}
|
|
98
141
|
});
|
|
@@ -100,23 +143,23 @@ function remotes(options) {
|
|
|
100
143
|
}
|
|
101
144
|
|
|
102
145
|
function consumes(options) {
|
|
103
|
-
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire } = options;
|
|
146
|
+
const { chunkId, promises, chunkMapping, installedModules, moduleToHandlerMapping, webpackRequire, } = options;
|
|
104
147
|
attachShareScopeMap(webpackRequire);
|
|
105
148
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
106
|
-
chunkMapping[chunkId].forEach((id)=>{
|
|
149
|
+
chunkMapping[chunkId].forEach((id) => {
|
|
107
150
|
if (webpackRequire.o(installedModules, id)) {
|
|
108
151
|
return promises.push(installedModules[id]);
|
|
109
152
|
}
|
|
110
|
-
const onFactory = (factory)=>{
|
|
153
|
+
const onFactory = (factory) => {
|
|
111
154
|
installedModules[id] = 0;
|
|
112
|
-
webpackRequire.m[id] = (module)=>{
|
|
155
|
+
webpackRequire.m[id] = (module) => {
|
|
113
156
|
delete webpackRequire.c[id];
|
|
114
157
|
module.exports = factory();
|
|
115
158
|
};
|
|
116
159
|
};
|
|
117
|
-
const onError = (error)=>{
|
|
160
|
+
const onError = (error) => {
|
|
118
161
|
delete installedModules[id];
|
|
119
|
-
webpackRequire.m[id] = (module)=>{
|
|
162
|
+
webpackRequire.m[id] = (module) => {
|
|
120
163
|
delete webpackRequire.c[id];
|
|
121
164
|
throw error;
|
|
122
165
|
};
|
|
@@ -127,70 +170,81 @@ function consumes(options) {
|
|
|
127
170
|
throw new Error('Federation instance not found!');
|
|
128
171
|
}
|
|
129
172
|
const { shareKey, getter, shareInfo } = moduleToHandlerMapping[id];
|
|
130
|
-
const promise = federationInstance
|
|
131
|
-
customShareInfo: shareInfo
|
|
132
|
-
|
|
173
|
+
const promise = federationInstance
|
|
174
|
+
.loadShare(shareKey, { customShareInfo: shareInfo })
|
|
175
|
+
.then((factory) => {
|
|
133
176
|
if (factory === false) {
|
|
134
177
|
return getter();
|
|
135
178
|
}
|
|
136
179
|
return factory;
|
|
137
180
|
});
|
|
138
181
|
if (promise.then) {
|
|
139
|
-
promises.push(installedModules[id] = promise.then(onFactory).catch(onError));
|
|
140
|
-
}
|
|
182
|
+
promises.push((installedModules[id] = promise.then(onFactory).catch(onError)));
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
141
185
|
// @ts-ignore maintain previous logic
|
|
142
186
|
onFactory(promise);
|
|
143
187
|
}
|
|
144
|
-
}
|
|
188
|
+
}
|
|
189
|
+
catch (e) {
|
|
145
190
|
onError(e);
|
|
146
191
|
}
|
|
147
192
|
});
|
|
148
193
|
}
|
|
149
194
|
}
|
|
150
195
|
|
|
151
|
-
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope }) {
|
|
152
|
-
if (!initScope)
|
|
196
|
+
function initializeSharing({ shareScopeName, webpackRequire, initPromises, initTokens, initScope, }) {
|
|
197
|
+
if (!initScope)
|
|
198
|
+
initScope = [];
|
|
153
199
|
const mfInstance = webpackRequire.federation.instance;
|
|
154
200
|
// handling circular init calls
|
|
155
201
|
var initToken = initTokens[shareScopeName];
|
|
156
|
-
if (!initToken)
|
|
157
|
-
from: mfInstance.name
|
|
158
|
-
|
|
159
|
-
|
|
202
|
+
if (!initToken)
|
|
203
|
+
initToken = initTokens[shareScopeName] = { from: mfInstance.name };
|
|
204
|
+
if (initScope.indexOf(initToken) >= 0)
|
|
205
|
+
return;
|
|
160
206
|
initScope.push(initToken);
|
|
161
207
|
const promise = initPromises[shareScopeName];
|
|
162
|
-
if (promise)
|
|
163
|
-
|
|
164
|
-
var
|
|
165
|
-
|
|
208
|
+
if (promise)
|
|
209
|
+
return promise;
|
|
210
|
+
var warn = (msg) => typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
211
|
+
var initExternal = (id) => {
|
|
212
|
+
var handleError = (err) => warn('Initialization of sharing external failed: ' + err);
|
|
166
213
|
try {
|
|
167
214
|
var module = webpackRequire(id);
|
|
168
|
-
if (!module)
|
|
169
|
-
|
|
215
|
+
if (!module)
|
|
216
|
+
return;
|
|
217
|
+
var initFn = (module) => module &&
|
|
218
|
+
module.init &&
|
|
219
|
+
// @ts-ignore compat legacy mf shared behavior
|
|
170
220
|
module.init(webpackRequire.S[shareScopeName], initScope);
|
|
171
|
-
if (module.then)
|
|
221
|
+
if (module.then)
|
|
222
|
+
return promises.push(module.then(initFn, handleError));
|
|
172
223
|
var initResult = initFn(module);
|
|
173
224
|
// @ts-ignore
|
|
174
|
-
if (initResult && typeof initResult !== 'boolean' && initResult.then)
|
|
175
|
-
|
|
176
|
-
|
|
225
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then)
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
return promises.push(initResult['catch'](handleError));
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
177
230
|
handleError(err);
|
|
178
231
|
}
|
|
179
232
|
};
|
|
180
233
|
const promises = mfInstance.initializeSharing(shareScopeName, {
|
|
181
234
|
strategy: mfInstance.options.shareStrategy,
|
|
182
235
|
initScope,
|
|
183
|
-
from: 'build'
|
|
236
|
+
from: 'build',
|
|
184
237
|
});
|
|
185
238
|
attachShareScopeMap(webpackRequire);
|
|
186
239
|
const bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
|
|
187
240
|
if (bundlerRuntimeRemotesOptions) {
|
|
188
|
-
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId)=>{
|
|
241
|
+
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach((moduleId) => {
|
|
189
242
|
const info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
|
|
190
243
|
const externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
|
|
191
244
|
if (info.length > 1) {
|
|
192
245
|
initExternal(externalModuleId);
|
|
193
|
-
}
|
|
246
|
+
}
|
|
247
|
+
else if (info.length === 1) {
|
|
194
248
|
const remoteInfo = info[0];
|
|
195
249
|
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
196
250
|
initExternal(externalModuleId);
|
|
@@ -199,9 +253,9 @@ function initializeSharing({ shareScopeName, webpackRequire, initPromises, initT
|
|
|
199
253
|
});
|
|
200
254
|
}
|
|
201
255
|
if (!promises.length) {
|
|
202
|
-
return initPromises[shareScopeName] = true;
|
|
256
|
+
return (initPromises[shareScopeName] = true);
|
|
203
257
|
}
|
|
204
|
-
return initPromises[shareScopeName] = Promise.all(promises).then(()=>initPromises[shareScopeName] = true);
|
|
258
|
+
return (initPromises[shareScopeName] = Promise.all(promises).then(() => (initPromises[shareScopeName] = true)));
|
|
205
259
|
}
|
|
206
260
|
|
|
207
261
|
function handleInitialConsumes(options) {
|
|
@@ -213,25 +267,26 @@ function handleInitialConsumes(options) {
|
|
|
213
267
|
const { shareKey, shareInfo } = moduleToHandlerMapping[moduleId];
|
|
214
268
|
try {
|
|
215
269
|
return federationInstance.loadShareSync(shareKey, {
|
|
216
|
-
customShareInfo: shareInfo
|
|
270
|
+
customShareInfo: shareInfo,
|
|
217
271
|
});
|
|
218
|
-
}
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
219
274
|
console.error('loadShareSync failed! The function should not be called unless you set "eager:true". If you do not set it, and encounter this issue, you can check whether an async boundary is implemented.');
|
|
220
275
|
console.error('The original error message is as follows: ');
|
|
221
276
|
throw err;
|
|
222
277
|
}
|
|
223
278
|
}
|
|
224
279
|
function installInitialConsumes(options) {
|
|
225
|
-
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes } = options;
|
|
226
|
-
initialConsumes.forEach((id)=>{
|
|
227
|
-
webpackRequire.m[id] = (module)=>{
|
|
280
|
+
const { moduleToHandlerMapping, webpackRequire, installedModules, initialConsumes, } = options;
|
|
281
|
+
initialConsumes.forEach((id) => {
|
|
282
|
+
webpackRequire.m[id] = (module) => {
|
|
228
283
|
// Handle scenario when module is used synchronously
|
|
229
284
|
installedModules[id] = 0;
|
|
230
285
|
delete webpackRequire.c[id];
|
|
231
286
|
const factory = handleInitialConsumes({
|
|
232
287
|
moduleId: id,
|
|
233
288
|
moduleToHandlerMapping,
|
|
234
|
-
webpackRequire
|
|
289
|
+
webpackRequire,
|
|
235
290
|
});
|
|
236
291
|
if (typeof factory !== 'function') {
|
|
237
292
|
throw new Error(`Shared module is not available for eager consumption: ${id}`);
|
|
@@ -242,17 +297,22 @@ function installInitialConsumes(options) {
|
|
|
242
297
|
}
|
|
243
298
|
|
|
244
299
|
function initContainerEntry(options) {
|
|
245
|
-
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions } = options;
|
|
246
|
-
if (!webpackRequire.S)
|
|
247
|
-
|
|
300
|
+
const { webpackRequire, shareScope, initScope, shareScopeKey, remoteEntryInitOptions, } = options;
|
|
301
|
+
if (!webpackRequire.S)
|
|
302
|
+
return;
|
|
303
|
+
if (!webpackRequire.federation ||
|
|
304
|
+
!webpackRequire.federation.instance ||
|
|
305
|
+
!webpackRequire.federation.initOptions)
|
|
306
|
+
return;
|
|
248
307
|
const federationInstance = webpackRequire.federation.instance;
|
|
249
308
|
var name = shareScopeKey || 'default';
|
|
250
|
-
federationInstance.initOptions(
|
|
309
|
+
federationInstance.initOptions({
|
|
251
310
|
name: webpackRequire.federation.initOptions.name,
|
|
252
|
-
remotes: []
|
|
253
|
-
|
|
311
|
+
remotes: [],
|
|
312
|
+
...remoteEntryInitOptions,
|
|
313
|
+
});
|
|
254
314
|
federationInstance.initShareScopeMap(name, shareScope, {
|
|
255
|
-
hostShareScopeMap:
|
|
315
|
+
hostShareScopeMap: remoteEntryInitOptions?.shareScopeMap || {},
|
|
256
316
|
});
|
|
257
317
|
if (webpackRequire.federation.attachShareScopeMap) {
|
|
258
318
|
webpackRequire.federation.attachShareScopeMap(webpackRequire);
|
|
@@ -274,10 +334,10 @@ const federation = {
|
|
|
274
334
|
I: initializeSharing,
|
|
275
335
|
S: {},
|
|
276
336
|
installInitialConsumes,
|
|
277
|
-
initContainerEntry
|
|
337
|
+
initContainerEntry,
|
|
278
338
|
},
|
|
279
339
|
attachShareScopeMap,
|
|
280
|
-
bundlerRuntimeOptions: {}
|
|
340
|
+
bundlerRuntimeOptions: {},
|
|
281
341
|
};
|
|
282
342
|
|
|
283
343
|
export { federation as default };
|
package/dist/src/constant.d.ts
CHANGED
package/dist/src/container.d.ts
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { UserOptions } from '@module-federation/runtime/types';
|
|
2
|
-
interface ExtendedOptions extends UserOptions {
|
|
3
|
-
exposes: {
|
|
4
|
-
[key: string]: () => Promise<() => any>;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export declare const createContainer: (federationOptions: ExtendedOptions) => any;
|
|
8
|
-
export declare const createContainerAsync: (federationOptions: ExtendedOptions) => Promise<any>;
|
|
9
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"public": true,
|
|
3
3
|
"name": "@module-federation/webpack-bundler-runtime",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Module Federation Runtime for webpack",
|
|
7
7
|
"keywords": [
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"module": "./dist/index.esm.mjs",
|
|
26
26
|
"types": "./dist/index.cjs.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@module-federation/runtime": "0.9.
|
|
29
|
-
"@module-federation/sdk": "0.9.
|
|
28
|
+
"@module-federation/runtime": "0.9.1",
|
|
29
|
+
"@module-federation/sdk": "0.9.1"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
@@ -37,10 +37,6 @@
|
|
|
37
37
|
"import": "./dist/constant.esm.mjs",
|
|
38
38
|
"require": "./dist/constant.cjs.js"
|
|
39
39
|
},
|
|
40
|
-
"./container": {
|
|
41
|
-
"import": "./dist/container.esm.mjs",
|
|
42
|
-
"require": "./dist/container.cjs.js"
|
|
43
|
-
},
|
|
44
40
|
"./*": "./*"
|
|
45
41
|
},
|
|
46
42
|
"typesVersions": {
|
|
@@ -54,6 +50,6 @@
|
|
|
54
50
|
}
|
|
55
51
|
},
|
|
56
52
|
"devDependencies": {
|
|
57
|
-
"@module-federation/runtime": "0.9.
|
|
53
|
+
"@module-federation/runtime": "0.9.1"
|
|
58
54
|
}
|
|
59
55
|
}
|
package/dist/container.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/container";
|
package/dist/container.cjs.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index.cjs.js');
|
|
4
|
-
|
|
5
|
-
const createContainer = (federationOptions)=>{
|
|
6
|
-
const { exposes, name, remotes = [], shared, plugins } = federationOptions;
|
|
7
|
-
const __webpack_modules__ = {
|
|
8
|
-
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': (//@ts-ignore
|
|
9
|
-
module, //@ts-ignore
|
|
10
|
-
__webpack_exports__, //@ts-ignore
|
|
11
|
-
__webpack_require__)=>{
|
|
12
|
-
__webpack_require__.r(__webpack_exports__);
|
|
13
|
-
const bundler_runtime = __webpack_require__.n(index);
|
|
14
|
-
const prevFederation = __webpack_require__.federation;
|
|
15
|
-
__webpack_require__.federation = {};
|
|
16
|
-
for(const key in bundler_runtime()){
|
|
17
|
-
__webpack_require__.federation[key] = bundler_runtime()[key];
|
|
18
|
-
}
|
|
19
|
-
for(const key in prevFederation){
|
|
20
|
-
__webpack_require__.federation[key] = prevFederation[key];
|
|
21
|
-
}
|
|
22
|
-
if (!__webpack_require__.federation.instance) {
|
|
23
|
-
const pluginsToAdd = plugins || [];
|
|
24
|
-
__webpack_require__.federation.initOptions.plugins = __webpack_require__.federation.initOptions.plugins ? __webpack_require__.federation.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;
|
|
25
|
-
__webpack_require__.federation.instance = __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);
|
|
26
|
-
if (__webpack_require__.federation.attachShareScopeMap) {
|
|
27
|
-
__webpack_require__.federation.attachShareScopeMap(__webpack_require__);
|
|
28
|
-
}
|
|
29
|
-
if (__webpack_require__.federation.installInitialConsumes) {
|
|
30
|
-
__webpack_require__.federation.installInitialConsumes();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
//@ts-ignore
|
|
35
|
-
'webpack/container/entry/createContainer': (//@ts-ignore
|
|
36
|
-
module, //@ts-ignore
|
|
37
|
-
exports, //@ts-ignore
|
|
38
|
-
__webpack_require__)=>{
|
|
39
|
-
const moduleMap = {};
|
|
40
|
-
for(const key in exposes){
|
|
41
|
-
if (Object.prototype.hasOwnProperty.call(exposes, key)) {
|
|
42
|
-
//@ts-ignore
|
|
43
|
-
moduleMap[key] = ()=>Promise.resolve(exposes[key]()).then((m)=>()=>m);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//@ts-ignore
|
|
47
|
-
const get = (module, getScope)=>{
|
|
48
|
-
__webpack_require__.R = getScope;
|
|
49
|
-
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(()=>{
|
|
50
|
-
throw new Error(`Module "${module}" does not exist in container.`);
|
|
51
|
-
});
|
|
52
|
-
__webpack_require__.R = undefined;
|
|
53
|
-
return getScope;
|
|
54
|
-
};
|
|
55
|
-
//@ts-ignore
|
|
56
|
-
const init = (shareScope, initScope, remoteEntryInitOptions)=>{
|
|
57
|
-
return __webpack_require__.federation.bundlerRuntime.initContainerEntry({
|
|
58
|
-
webpackRequire: __webpack_require__,
|
|
59
|
-
shareScope: shareScope,
|
|
60
|
-
initScope: initScope,
|
|
61
|
-
remoteEntryInitOptions: remoteEntryInitOptions,
|
|
62
|
-
shareScopeKey: 'default'
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
__webpack_require__('./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js');
|
|
66
|
-
// This exports getters to disallow modifications
|
|
67
|
-
__webpack_require__.d(exports, {
|
|
68
|
-
get: ()=>get,
|
|
69
|
-
init: ()=>init,
|
|
70
|
-
moduleMap: ()=>moduleMap
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const __webpack_module_cache__ = {};
|
|
75
|
-
//@ts-ignore
|
|
76
|
-
const __webpack_require__ = (moduleId)=>{
|
|
77
|
-
//@ts-ignore
|
|
78
|
-
let cachedModule = __webpack_module_cache__[moduleId];
|
|
79
|
-
if (cachedModule !== undefined) {
|
|
80
|
-
return cachedModule.exports;
|
|
81
|
-
}
|
|
82
|
-
//@ts-ignore
|
|
83
|
-
let module = __webpack_module_cache__[moduleId] = {
|
|
84
|
-
id: moduleId,
|
|
85
|
-
loaded: false,
|
|
86
|
-
exports: {}
|
|
87
|
-
};
|
|
88
|
-
const execOptions = {
|
|
89
|
-
id: moduleId,
|
|
90
|
-
module: module,
|
|
91
|
-
//@ts-ignore
|
|
92
|
-
factory: __webpack_modules__[moduleId],
|
|
93
|
-
require: __webpack_require__
|
|
94
|
-
};
|
|
95
|
-
__webpack_require__.i.forEach((handler)=>{
|
|
96
|
-
handler(execOptions);
|
|
97
|
-
});
|
|
98
|
-
module = execOptions.module;
|
|
99
|
-
execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
|
|
100
|
-
module.loaded = true;
|
|
101
|
-
return module.exports;
|
|
102
|
-
};
|
|
103
|
-
__webpack_require__.m = __webpack_modules__;
|
|
104
|
-
__webpack_require__.c = __webpack_module_cache__;
|
|
105
|
-
//@ts-ignore
|
|
106
|
-
__webpack_require__.i = [];
|
|
107
|
-
//@ts-ignore
|
|
108
|
-
if (!__webpack_require__.federation) {
|
|
109
|
-
__webpack_require__.federation = {
|
|
110
|
-
initOptions: {
|
|
111
|
-
name: name,
|
|
112
|
-
//@ts-ignore
|
|
113
|
-
remotes: remotes.map((remote)=>({
|
|
114
|
-
type: remote.type,
|
|
115
|
-
alias: remote.alias,
|
|
116
|
-
name: remote.name,
|
|
117
|
-
//@ts-ignore
|
|
118
|
-
entry: remote.entry,
|
|
119
|
-
shareScope: remote.shareScope || 'default'
|
|
120
|
-
}))
|
|
121
|
-
},
|
|
122
|
-
chunkMatcher: ()=>true,
|
|
123
|
-
rootOutputDir: '',
|
|
124
|
-
initialConsumes: undefined,
|
|
125
|
-
bundlerRuntimeOptions: {}
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
//@ts-ignore
|
|
129
|
-
__webpack_require__.n = (module)=>{
|
|
130
|
-
const getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
131
|
-
__webpack_require__.d(getter, {
|
|
132
|
-
a: getter
|
|
133
|
-
});
|
|
134
|
-
return getter;
|
|
135
|
-
};
|
|
136
|
-
//@ts-ignore
|
|
137
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
138
|
-
for(const key in definition){
|
|
139
|
-
if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
140
|
-
Object.defineProperty(exports, key, {
|
|
141
|
-
enumerable: true,
|
|
142
|
-
get: definition[key]
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
__webpack_require__.f = {};
|
|
148
|
-
__webpack_require__.g = (()=>{
|
|
149
|
-
if (typeof globalThis === 'object') return globalThis;
|
|
150
|
-
try {
|
|
151
|
-
return undefined || new Function('return this')();
|
|
152
|
-
} catch (e) {
|
|
153
|
-
if (typeof window === 'object') return window;
|
|
154
|
-
}
|
|
155
|
-
})();
|
|
156
|
-
//@ts-ignore
|
|
157
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
158
|
-
//@ts-ignore
|
|
159
|
-
__webpack_require__.r = (exports)=>{
|
|
160
|
-
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
161
|
-
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
162
|
-
value: 'Module'
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
Object.defineProperty(exports, '__esModule', {
|
|
166
|
-
value: true
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
//@ts-ignore
|
|
170
|
-
__webpack_require__.federation.initOptions.shared = shared;
|
|
171
|
-
__webpack_require__.S = {};
|
|
172
|
-
const initPromises = {};
|
|
173
|
-
const initTokens = {};
|
|
174
|
-
//@ts-ignore
|
|
175
|
-
__webpack_require__.I = (name, initScope)=>{
|
|
176
|
-
//@ts-ignore
|
|
177
|
-
return __webpack_require__.federation.bundlerRuntime.I({
|
|
178
|
-
shareScopeName: name,
|
|
179
|
-
webpackRequire: __webpack_require__,
|
|
180
|
-
initPromises: initPromises,
|
|
181
|
-
initTokens: initTokens,
|
|
182
|
-
initScope: initScope
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
const __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer');
|
|
186
|
-
__webpack_exports__.get;
|
|
187
|
-
__webpack_exports__.init;
|
|
188
|
-
return __webpack_exports__;
|
|
189
|
-
};
|
|
190
|
-
const createContainerAsync = async (federationOptions)=>{
|
|
191
|
-
// todo: consider async startup options here, for "async boundary" provision.
|
|
192
|
-
return createContainer(federationOptions);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
exports.createContainer = createContainer;
|
|
196
|
-
exports.createContainerAsync = createContainerAsync;
|
package/dist/container.esm.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/container";
|
package/dist/container.esm.mjs
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import federation from './index.esm.mjs';
|
|
2
|
-
|
|
3
|
-
const createContainer = (federationOptions)=>{
|
|
4
|
-
const { exposes, name, remotes = [], shared, plugins } = federationOptions;
|
|
5
|
-
const __webpack_modules__ = {
|
|
6
|
-
'./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js': (//@ts-ignore
|
|
7
|
-
module, //@ts-ignore
|
|
8
|
-
__webpack_exports__, //@ts-ignore
|
|
9
|
-
__webpack_require__)=>{
|
|
10
|
-
__webpack_require__.r(__webpack_exports__);
|
|
11
|
-
const bundler_runtime = __webpack_require__.n(federation);
|
|
12
|
-
const prevFederation = __webpack_require__.federation;
|
|
13
|
-
__webpack_require__.federation = {};
|
|
14
|
-
for(const key in bundler_runtime()){
|
|
15
|
-
__webpack_require__.federation[key] = bundler_runtime()[key];
|
|
16
|
-
}
|
|
17
|
-
for(const key in prevFederation){
|
|
18
|
-
__webpack_require__.federation[key] = prevFederation[key];
|
|
19
|
-
}
|
|
20
|
-
if (!__webpack_require__.federation.instance) {
|
|
21
|
-
const pluginsToAdd = plugins || [];
|
|
22
|
-
__webpack_require__.federation.initOptions.plugins = __webpack_require__.federation.initOptions.plugins ? __webpack_require__.federation.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;
|
|
23
|
-
__webpack_require__.federation.instance = __webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);
|
|
24
|
-
if (__webpack_require__.federation.attachShareScopeMap) {
|
|
25
|
-
__webpack_require__.federation.attachShareScopeMap(__webpack_require__);
|
|
26
|
-
}
|
|
27
|
-
if (__webpack_require__.federation.installInitialConsumes) {
|
|
28
|
-
__webpack_require__.federation.installInitialConsumes();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
//@ts-ignore
|
|
33
|
-
'webpack/container/entry/createContainer': (//@ts-ignore
|
|
34
|
-
module, //@ts-ignore
|
|
35
|
-
exports, //@ts-ignore
|
|
36
|
-
__webpack_require__)=>{
|
|
37
|
-
const moduleMap = {};
|
|
38
|
-
for(const key in exposes){
|
|
39
|
-
if (Object.prototype.hasOwnProperty.call(exposes, key)) {
|
|
40
|
-
//@ts-ignore
|
|
41
|
-
moduleMap[key] = ()=>Promise.resolve(exposes[key]()).then((m)=>()=>m);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//@ts-ignore
|
|
45
|
-
const get = (module, getScope)=>{
|
|
46
|
-
__webpack_require__.R = getScope;
|
|
47
|
-
getScope = __webpack_require__.o(moduleMap, module) ? moduleMap[module]() : Promise.resolve().then(()=>{
|
|
48
|
-
throw new Error(`Module "${module}" does not exist in container.`);
|
|
49
|
-
});
|
|
50
|
-
__webpack_require__.R = undefined;
|
|
51
|
-
return getScope;
|
|
52
|
-
};
|
|
53
|
-
//@ts-ignore
|
|
54
|
-
const init = (shareScope, initScope, remoteEntryInitOptions)=>{
|
|
55
|
-
return __webpack_require__.federation.bundlerRuntime.initContainerEntry({
|
|
56
|
-
webpackRequire: __webpack_require__,
|
|
57
|
-
shareScope: shareScope,
|
|
58
|
-
initScope: initScope,
|
|
59
|
-
remoteEntryInitOptions: remoteEntryInitOptions,
|
|
60
|
-
shareScopeKey: 'default'
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
__webpack_require__('./node_modules/.federation/entry.1f2288102e035e2ed66b2efaf60ad043.js');
|
|
64
|
-
// This exports getters to disallow modifications
|
|
65
|
-
__webpack_require__.d(exports, {
|
|
66
|
-
get: ()=>get,
|
|
67
|
-
init: ()=>init,
|
|
68
|
-
moduleMap: ()=>moduleMap
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
const __webpack_module_cache__ = {};
|
|
73
|
-
//@ts-ignore
|
|
74
|
-
const __webpack_require__ = (moduleId)=>{
|
|
75
|
-
//@ts-ignore
|
|
76
|
-
let cachedModule = __webpack_module_cache__[moduleId];
|
|
77
|
-
if (cachedModule !== undefined) {
|
|
78
|
-
return cachedModule.exports;
|
|
79
|
-
}
|
|
80
|
-
//@ts-ignore
|
|
81
|
-
let module = __webpack_module_cache__[moduleId] = {
|
|
82
|
-
id: moduleId,
|
|
83
|
-
loaded: false,
|
|
84
|
-
exports: {}
|
|
85
|
-
};
|
|
86
|
-
const execOptions = {
|
|
87
|
-
id: moduleId,
|
|
88
|
-
module: module,
|
|
89
|
-
//@ts-ignore
|
|
90
|
-
factory: __webpack_modules__[moduleId],
|
|
91
|
-
require: __webpack_require__
|
|
92
|
-
};
|
|
93
|
-
__webpack_require__.i.forEach((handler)=>{
|
|
94
|
-
handler(execOptions);
|
|
95
|
-
});
|
|
96
|
-
module = execOptions.module;
|
|
97
|
-
execOptions.factory.call(module.exports, module, module.exports, execOptions.require);
|
|
98
|
-
module.loaded = true;
|
|
99
|
-
return module.exports;
|
|
100
|
-
};
|
|
101
|
-
__webpack_require__.m = __webpack_modules__;
|
|
102
|
-
__webpack_require__.c = __webpack_module_cache__;
|
|
103
|
-
//@ts-ignore
|
|
104
|
-
__webpack_require__.i = [];
|
|
105
|
-
//@ts-ignore
|
|
106
|
-
if (!__webpack_require__.federation) {
|
|
107
|
-
__webpack_require__.federation = {
|
|
108
|
-
initOptions: {
|
|
109
|
-
name: name,
|
|
110
|
-
//@ts-ignore
|
|
111
|
-
remotes: remotes.map((remote)=>({
|
|
112
|
-
type: remote.type,
|
|
113
|
-
alias: remote.alias,
|
|
114
|
-
name: remote.name,
|
|
115
|
-
//@ts-ignore
|
|
116
|
-
entry: remote.entry,
|
|
117
|
-
shareScope: remote.shareScope || 'default'
|
|
118
|
-
}))
|
|
119
|
-
},
|
|
120
|
-
chunkMatcher: ()=>true,
|
|
121
|
-
rootOutputDir: '',
|
|
122
|
-
initialConsumes: undefined,
|
|
123
|
-
bundlerRuntimeOptions: {}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
//@ts-ignore
|
|
127
|
-
__webpack_require__.n = (module)=>{
|
|
128
|
-
const getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
129
|
-
__webpack_require__.d(getter, {
|
|
130
|
-
a: getter
|
|
131
|
-
});
|
|
132
|
-
return getter;
|
|
133
|
-
};
|
|
134
|
-
//@ts-ignore
|
|
135
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
136
|
-
for(const key in definition){
|
|
137
|
-
if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
138
|
-
Object.defineProperty(exports, key, {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
get: definition[key]
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
__webpack_require__.f = {};
|
|
146
|
-
__webpack_require__.g = (()=>{
|
|
147
|
-
if (typeof globalThis === 'object') return globalThis;
|
|
148
|
-
try {
|
|
149
|
-
return undefined || new Function('return this')();
|
|
150
|
-
} catch (e) {
|
|
151
|
-
if (typeof window === 'object') return window;
|
|
152
|
-
}
|
|
153
|
-
})();
|
|
154
|
-
//@ts-ignore
|
|
155
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
156
|
-
//@ts-ignore
|
|
157
|
-
__webpack_require__.r = (exports)=>{
|
|
158
|
-
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
159
|
-
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
160
|
-
value: 'Module'
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
Object.defineProperty(exports, '__esModule', {
|
|
164
|
-
value: true
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
//@ts-ignore
|
|
168
|
-
__webpack_require__.federation.initOptions.shared = shared;
|
|
169
|
-
__webpack_require__.S = {};
|
|
170
|
-
const initPromises = {};
|
|
171
|
-
const initTokens = {};
|
|
172
|
-
//@ts-ignore
|
|
173
|
-
__webpack_require__.I = (name, initScope)=>{
|
|
174
|
-
//@ts-ignore
|
|
175
|
-
return __webpack_require__.federation.bundlerRuntime.I({
|
|
176
|
-
shareScopeName: name,
|
|
177
|
-
webpackRequire: __webpack_require__,
|
|
178
|
-
initPromises: initPromises,
|
|
179
|
-
initTokens: initTokens,
|
|
180
|
-
initScope: initScope
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
const __webpack_exports__ = __webpack_require__('webpack/container/entry/createContainer');
|
|
184
|
-
__webpack_exports__.get;
|
|
185
|
-
__webpack_exports__.init;
|
|
186
|
-
return __webpack_exports__;
|
|
187
|
-
};
|
|
188
|
-
const createContainerAsync = async (federationOptions)=>{
|
|
189
|
-
// todo: consider async startup options here, for "async boundary" provision.
|
|
190
|
-
return createContainer(federationOptions);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
export { createContainer, createContainerAsync };
|
package/dist/polyfills.cjs.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _extends() {
|
|
4
|
-
_extends = Object.assign || function assign(target) {
|
|
5
|
-
for(var i = 1; i < arguments.length; i++){
|
|
6
|
-
var source = arguments[i];
|
|
7
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
8
|
-
}
|
|
9
|
-
return target;
|
|
10
|
-
};
|
|
11
|
-
return _extends.apply(this, arguments);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
exports._extends = _extends;
|
package/dist/polyfills.esm.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
_extends = Object.assign || function assign(target) {
|
|
3
|
-
for(var i = 1; i < arguments.length; i++){
|
|
4
|
-
var source = arguments[i];
|
|
5
|
-
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
6
|
-
}
|
|
7
|
-
return target;
|
|
8
|
-
};
|
|
9
|
-
return _extends.apply(this, arguments);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { _extends as _ };
|