@module-federation/webpack-bundler-runtime 0.1.11 → 0.1.13
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 +2 -2
- package/dist/constant.esm.js +2 -2
- package/dist/index.cjs.js +21 -15
- package/dist/index.esm.js +21 -15
- package/dist/package.json +1 -1
- package/package.json +3 -3
package/dist/constant.cjs.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ENCODE_NAME_PREFIX =
|
|
5
|
+
var ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
6
6
|
var FEDERATION_SUPPORTED_TYPES = [
|
|
7
|
-
|
|
7
|
+
'script'
|
|
8
8
|
];
|
|
9
9
|
|
|
10
10
|
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
package/dist/constant.esm.js
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -54,9 +54,9 @@ function remotes(options) {
|
|
|
54
54
|
}
|
|
55
55
|
var onError = function(error) {
|
|
56
56
|
if (!error) {
|
|
57
|
-
error = new Error(
|
|
57
|
+
error = new Error('Container missing');
|
|
58
58
|
}
|
|
59
|
-
if (typeof error.message ===
|
|
59
|
+
if (typeof error.message === 'string') {
|
|
60
60
|
error.message += '\nwhile loading "'.concat(data[1], '" from ').concat(data[2]);
|
|
61
61
|
}
|
|
62
62
|
webpackRequire.m[id] = function() {
|
|
@@ -103,14 +103,14 @@ function remotes(options) {
|
|
|
103
103
|
var remoteModuleName = remoteName + data[1].slice(1);
|
|
104
104
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
105
105
|
loadFactory: false,
|
|
106
|
-
from:
|
|
106
|
+
from: 'build'
|
|
107
107
|
});
|
|
108
108
|
} catch (error) {
|
|
109
109
|
onError(error);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
112
|
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
113
|
-
|
|
113
|
+
'script'
|
|
114
114
|
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
115
115
|
if (useRuntimeLoad) {
|
|
116
116
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
@@ -146,7 +146,7 @@ function consumes(options) {
|
|
|
146
146
|
try {
|
|
147
147
|
var federationInstance = webpackRequire.federation.instance;
|
|
148
148
|
if (!federationInstance) {
|
|
149
|
-
throw new Error(
|
|
149
|
+
throw new Error('Federation instance not found!');
|
|
150
150
|
}
|
|
151
151
|
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo;
|
|
152
152
|
var promise = federationInstance.loadShare(shareKey, {
|
|
@@ -181,11 +181,11 @@ function initializeSharing(param) {
|
|
|
181
181
|
var promise = initPromises[shareScopeName];
|
|
182
182
|
if (promise) return promise;
|
|
183
183
|
var warn = function(msg) {
|
|
184
|
-
return typeof console !==
|
|
184
|
+
return typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
185
185
|
};
|
|
186
186
|
var initExternal = function(id) {
|
|
187
187
|
var handleError = function(err) {
|
|
188
|
-
return warn(
|
|
188
|
+
return warn('Initialization of sharing external failed: ' + err);
|
|
189
189
|
};
|
|
190
190
|
try {
|
|
191
191
|
var module = webpackRequire(id);
|
|
@@ -197,8 +197,8 @@ function initializeSharing(param) {
|
|
|
197
197
|
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
198
198
|
var initResult = initFn(module);
|
|
199
199
|
// @ts-ignore
|
|
200
|
-
if (initResult && typeof initResult !==
|
|
201
|
-
return promises.push(initResult[
|
|
200
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then) // @ts-ignore
|
|
201
|
+
return promises.push(initResult['catch'](handleError));
|
|
202
202
|
} catch (err) {
|
|
203
203
|
handleError(err);
|
|
204
204
|
}
|
|
@@ -232,12 +232,18 @@ function handleInitialConsumes(options) {
|
|
|
232
232
|
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
233
233
|
var federationInstance = webpackRequire.federation.instance;
|
|
234
234
|
if (!federationInstance) {
|
|
235
|
-
throw new Error(
|
|
235
|
+
throw new Error('Federation instance not found!');
|
|
236
236
|
}
|
|
237
237
|
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo;
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
try {
|
|
239
|
+
return federationInstance.loadShareSync(shareKey, {
|
|
240
|
+
customShareInfo: shareInfo
|
|
241
|
+
});
|
|
242
|
+
} catch (err) {
|
|
243
|
+
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.');
|
|
244
|
+
console.error('The original error message is as follows: ');
|
|
245
|
+
throw err;
|
|
246
|
+
}
|
|
241
247
|
}
|
|
242
248
|
function installInitialConsumes(options) {
|
|
243
249
|
var moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire, installedModules = options.installedModules, initialConsumes = options.initialConsumes;
|
|
@@ -251,7 +257,7 @@ function installInitialConsumes(options) {
|
|
|
251
257
|
moduleToHandlerMapping: moduleToHandlerMapping,
|
|
252
258
|
webpackRequire: webpackRequire
|
|
253
259
|
});
|
|
254
|
-
if (typeof factory !==
|
|
260
|
+
if (typeof factory !== 'function') {
|
|
255
261
|
throw new Error("Shared module is not available for eager consumption: ".concat(id));
|
|
256
262
|
}
|
|
257
263
|
module.exports = factory();
|
|
@@ -292,7 +298,7 @@ function initContainerEntry(options) {
|
|
|
292
298
|
if (!webpackRequire.S) return;
|
|
293
299
|
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
294
300
|
var federationInstance = webpackRequire.federation.instance;
|
|
295
|
-
var name = shareScopeKey ||
|
|
301
|
+
var name = shareScopeKey || 'default';
|
|
296
302
|
federationInstance.initOptions(_object_spread({
|
|
297
303
|
name: webpackRequire.federation.initOptions.name,
|
|
298
304
|
remotes: []
|
package/dist/index.esm.js
CHANGED
|
@@ -32,9 +32,9 @@ function remotes(options) {
|
|
|
32
32
|
}
|
|
33
33
|
var onError = function(error) {
|
|
34
34
|
if (!error) {
|
|
35
|
-
error = new Error(
|
|
35
|
+
error = new Error('Container missing');
|
|
36
36
|
}
|
|
37
|
-
if (typeof error.message ===
|
|
37
|
+
if (typeof error.message === 'string') {
|
|
38
38
|
error.message += '\nwhile loading "'.concat(data[1], '" from ').concat(data[2]);
|
|
39
39
|
}
|
|
40
40
|
webpackRequire.m[id] = function() {
|
|
@@ -81,14 +81,14 @@ function remotes(options) {
|
|
|
81
81
|
var remoteModuleName = remoteName + data[1].slice(1);
|
|
82
82
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
83
83
|
loadFactory: false,
|
|
84
|
-
from:
|
|
84
|
+
from: 'build'
|
|
85
85
|
});
|
|
86
86
|
} catch (error) {
|
|
87
87
|
onError(error);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
91
|
-
|
|
91
|
+
'script'
|
|
92
92
|
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
93
93
|
if (useRuntimeLoad) {
|
|
94
94
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
@@ -124,7 +124,7 @@ function consumes(options) {
|
|
|
124
124
|
try {
|
|
125
125
|
var federationInstance = webpackRequire.federation.instance;
|
|
126
126
|
if (!federationInstance) {
|
|
127
|
-
throw new Error(
|
|
127
|
+
throw new Error('Federation instance not found!');
|
|
128
128
|
}
|
|
129
129
|
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo;
|
|
130
130
|
var promise = federationInstance.loadShare(shareKey, {
|
|
@@ -159,11 +159,11 @@ function initializeSharing(param) {
|
|
|
159
159
|
var promise = initPromises[shareScopeName];
|
|
160
160
|
if (promise) return promise;
|
|
161
161
|
var warn = function(msg) {
|
|
162
|
-
return typeof console !==
|
|
162
|
+
return typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
163
163
|
};
|
|
164
164
|
var initExternal = function(id) {
|
|
165
165
|
var handleError = function(err) {
|
|
166
|
-
return warn(
|
|
166
|
+
return warn('Initialization of sharing external failed: ' + err);
|
|
167
167
|
};
|
|
168
168
|
try {
|
|
169
169
|
var module = webpackRequire(id);
|
|
@@ -175,8 +175,8 @@ function initializeSharing(param) {
|
|
|
175
175
|
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
176
176
|
var initResult = initFn(module);
|
|
177
177
|
// @ts-ignore
|
|
178
|
-
if (initResult && typeof initResult !==
|
|
179
|
-
return promises.push(initResult[
|
|
178
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then) // @ts-ignore
|
|
179
|
+
return promises.push(initResult['catch'](handleError));
|
|
180
180
|
} catch (err) {
|
|
181
181
|
handleError(err);
|
|
182
182
|
}
|
|
@@ -210,12 +210,18 @@ function handleInitialConsumes(options) {
|
|
|
210
210
|
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
211
211
|
var federationInstance = webpackRequire.federation.instance;
|
|
212
212
|
if (!federationInstance) {
|
|
213
|
-
throw new Error(
|
|
213
|
+
throw new Error('Federation instance not found!');
|
|
214
214
|
}
|
|
215
215
|
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo;
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
try {
|
|
217
|
+
return federationInstance.loadShareSync(shareKey, {
|
|
218
|
+
customShareInfo: shareInfo
|
|
219
|
+
});
|
|
220
|
+
} catch (err) {
|
|
221
|
+
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.');
|
|
222
|
+
console.error('The original error message is as follows: ');
|
|
223
|
+
throw err;
|
|
224
|
+
}
|
|
219
225
|
}
|
|
220
226
|
function installInitialConsumes(options) {
|
|
221
227
|
var moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire, installedModules = options.installedModules, initialConsumes = options.initialConsumes;
|
|
@@ -229,7 +235,7 @@ function installInitialConsumes(options) {
|
|
|
229
235
|
moduleToHandlerMapping: moduleToHandlerMapping,
|
|
230
236
|
webpackRequire: webpackRequire
|
|
231
237
|
});
|
|
232
|
-
if (typeof factory !==
|
|
238
|
+
if (typeof factory !== 'function') {
|
|
233
239
|
throw new Error("Shared module is not available for eager consumption: ".concat(id));
|
|
234
240
|
}
|
|
235
241
|
module.exports = factory();
|
|
@@ -270,7 +276,7 @@ function initContainerEntry(options) {
|
|
|
270
276
|
if (!webpackRequire.S) return;
|
|
271
277
|
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
272
278
|
var federationInstance = webpackRequire.federation.instance;
|
|
273
|
-
var name = shareScopeKey ||
|
|
279
|
+
var name = shareScopeKey || 'default';
|
|
274
280
|
federationInstance.initOptions(_object_spread({
|
|
275
281
|
name: webpackRequire.federation.initOptions.name,
|
|
276
282
|
remotes: []
|
package/dist/package.json
CHANGED
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.1.
|
|
4
|
+
"version": "0.1.13",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Module Federation Runtime for webpack",
|
|
7
7
|
"keywords": [
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"module": "./dist/index.esm.js",
|
|
21
21
|
"types": "./dist/index.cjs.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@module-federation/runtime": "0.1.
|
|
24
|
-
"@module-federation/sdk": "0.1.
|
|
23
|
+
"@module-federation/runtime": "0.1.13",
|
|
24
|
+
"@module-federation/sdk": "0.1.13"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|