@module-federation/webpack-bundler-runtime 0.0.0-next-20231221095908 → 0.0.0-next-20231222080837
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/LICENSE +21 -0
- package/dist/constant.cjs.d.ts +1 -0
- package/dist/constant.cjs.js +11 -0
- package/dist/constant.esm.js +6 -0
- package/dist/index.cjs.js +21 -73
- package/dist/index.esm.js +20 -69
- package/dist/package.json +21 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/types.d.ts +1 -1
- package/package.json +24 -3
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present zhanghang(2heal1)
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/constant";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var FEDERATION_SUPPORTED_TYPES = [
|
|
6
|
+
"script"
|
|
7
|
+
];
|
|
8
|
+
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
9
|
+
|
|
10
|
+
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
11
|
+
exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var runtime = require('@module-federation/runtime');
|
|
6
4
|
var sdk = require('@module-federation/sdk');
|
|
5
|
+
var constant = require('./constant.cjs.js');
|
|
7
6
|
|
|
8
7
|
function _interopNamespace(e) {
|
|
9
8
|
if (e && e.__esModule) return e;
|
|
@@ -33,57 +32,6 @@ function attachShareScopeMap(webpackRequire) {
|
|
|
33
32
|
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
var FEDERATION_SUPPORTED_TYPES = [
|
|
37
|
-
"script"
|
|
38
|
-
];
|
|
39
|
-
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
40
|
-
|
|
41
|
-
function _array_like_to_array(arr, len) {
|
|
42
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
43
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
44
|
-
return arr2;
|
|
45
|
-
}
|
|
46
|
-
function _array_with_holes(arr) {
|
|
47
|
-
if (Array.isArray(arr)) return arr;
|
|
48
|
-
}
|
|
49
|
-
function _iterable_to_array_limit(arr, i) {
|
|
50
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
51
|
-
if (_i == null) return;
|
|
52
|
-
var _arr = [];
|
|
53
|
-
var _n = true;
|
|
54
|
-
var _d = false;
|
|
55
|
-
var _s, _e;
|
|
56
|
-
try {
|
|
57
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
58
|
-
_arr.push(_s.value);
|
|
59
|
-
if (i && _arr.length === i) break;
|
|
60
|
-
}
|
|
61
|
-
} catch (err) {
|
|
62
|
-
_d = true;
|
|
63
|
-
_e = err;
|
|
64
|
-
} finally{
|
|
65
|
-
try {
|
|
66
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
67
|
-
} finally{
|
|
68
|
-
if (_d) throw _e;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return _arr;
|
|
72
|
-
}
|
|
73
|
-
function _non_iterable_rest() {
|
|
74
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
75
|
-
}
|
|
76
|
-
function _sliced_to_array(arr, i) {
|
|
77
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
78
|
-
}
|
|
79
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
80
|
-
if (!o) return;
|
|
81
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
82
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
83
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
84
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
85
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
86
|
-
}
|
|
87
35
|
function remotes(options) {
|
|
88
36
|
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;
|
|
89
37
|
attachShareScopeMap(webpackRequire);
|
|
@@ -149,20 +97,9 @@ function remotes(options) {
|
|
|
149
97
|
module.exports = factory();
|
|
150
98
|
};
|
|
151
99
|
};
|
|
152
|
-
var extractUrlAndGlobal = function(urlAndGlobal) {
|
|
153
|
-
var index = urlAndGlobal.indexOf("@");
|
|
154
|
-
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
155
|
-
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
|
|
156
|
-
}
|
|
157
|
-
return [
|
|
158
|
-
urlAndGlobal.substring(index + 1),
|
|
159
|
-
urlAndGlobal.substring(0, index)
|
|
160
|
-
];
|
|
161
|
-
};
|
|
162
100
|
var onRemoteLoaded = function() {
|
|
163
101
|
try {
|
|
164
|
-
var
|
|
165
|
-
var remoteName = sdk.decodeName(globalName, ENCODE_NAME_PREFIX);
|
|
102
|
+
var remoteName = sdk.decodeName(remoteInfos[0].name, constant.ENCODE_NAME_PREFIX);
|
|
166
103
|
var remoteModuleName = remoteName + data[1].slice(1);
|
|
167
104
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
168
105
|
loadFactory: false
|
|
@@ -173,7 +110,7 @@ function remotes(options) {
|
|
|
173
110
|
};
|
|
174
111
|
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
175
112
|
"script"
|
|
176
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].
|
|
113
|
+
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
177
114
|
if (useRuntimeLoad) {
|
|
178
115
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
179
116
|
} else {
|
|
@@ -273,7 +210,7 @@ function initializeSharing(param) {
|
|
|
273
210
|
initExternal(externalModuleId);
|
|
274
211
|
} else if (info.length === 1) {
|
|
275
212
|
var remoteInfo = info[0];
|
|
276
|
-
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
213
|
+
if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
277
214
|
initExternal(externalModuleId);
|
|
278
215
|
}
|
|
279
216
|
}
|
|
@@ -319,6 +256,15 @@ function installInitialConsumes(options) {
|
|
|
319
256
|
});
|
|
320
257
|
}
|
|
321
258
|
|
|
259
|
+
function isLegacyHost(shareScope) {
|
|
260
|
+
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
322
268
|
function initContainerEntry(options) {
|
|
323
269
|
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
|
|
324
270
|
if (!webpackRequire.S) return;
|
|
@@ -328,10 +274,13 @@ function initContainerEntry(options) {
|
|
|
328
274
|
name: webpackRequire.federation.initOptions.name,
|
|
329
275
|
remotes: []
|
|
330
276
|
});
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
277
|
+
if (isLegacyHost(shareScope)) {
|
|
278
|
+
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
|
|
279
|
+
if (prevShareScope) {
|
|
280
|
+
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
|
|
335
284
|
}
|
|
336
285
|
webpackRequire.S[name] = shareScope;
|
|
337
286
|
if (webpackRequire.federation.attachShareScopeMap) {
|
|
@@ -357,5 +306,4 @@ var federation = {
|
|
|
357
306
|
bundlerRuntimeOptions: {}
|
|
358
307
|
};
|
|
359
308
|
|
|
360
|
-
exports
|
|
361
|
-
exports["default"] = federation;
|
|
309
|
+
module.exports = federation;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as runtime from '@module-federation/runtime';
|
|
2
2
|
import { decodeName } from '@module-federation/sdk';
|
|
3
|
+
import { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES } from './constant.esm.js';
|
|
3
4
|
|
|
4
5
|
function attachShareScopeMap(webpackRequire) {
|
|
5
6
|
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
|
|
@@ -9,57 +10,6 @@ function attachShareScopeMap(webpackRequire) {
|
|
|
9
10
|
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
var FEDERATION_SUPPORTED_TYPES = [
|
|
13
|
-
"script"
|
|
14
|
-
];
|
|
15
|
-
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
16
|
-
|
|
17
|
-
function _array_like_to_array(arr, len) {
|
|
18
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
20
|
-
return arr2;
|
|
21
|
-
}
|
|
22
|
-
function _array_with_holes(arr) {
|
|
23
|
-
if (Array.isArray(arr)) return arr;
|
|
24
|
-
}
|
|
25
|
-
function _iterable_to_array_limit(arr, i) {
|
|
26
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
27
|
-
if (_i == null) return;
|
|
28
|
-
var _arr = [];
|
|
29
|
-
var _n = true;
|
|
30
|
-
var _d = false;
|
|
31
|
-
var _s, _e;
|
|
32
|
-
try {
|
|
33
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
34
|
-
_arr.push(_s.value);
|
|
35
|
-
if (i && _arr.length === i) break;
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
_d = true;
|
|
39
|
-
_e = err;
|
|
40
|
-
} finally{
|
|
41
|
-
try {
|
|
42
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
43
|
-
} finally{
|
|
44
|
-
if (_d) throw _e;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return _arr;
|
|
48
|
-
}
|
|
49
|
-
function _non_iterable_rest() {
|
|
50
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
51
|
-
}
|
|
52
|
-
function _sliced_to_array(arr, i) {
|
|
53
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
54
|
-
}
|
|
55
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
56
|
-
if (!o) return;
|
|
57
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
58
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
59
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
60
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
61
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
62
|
-
}
|
|
63
13
|
function remotes(options) {
|
|
64
14
|
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire, idToRemoteMap = options.idToRemoteMap;
|
|
65
15
|
attachShareScopeMap(webpackRequire);
|
|
@@ -125,20 +75,9 @@ function remotes(options) {
|
|
|
125
75
|
module.exports = factory();
|
|
126
76
|
};
|
|
127
77
|
};
|
|
128
|
-
var extractUrlAndGlobal = function(urlAndGlobal) {
|
|
129
|
-
var index = urlAndGlobal.indexOf("@");
|
|
130
|
-
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
131
|
-
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
|
|
132
|
-
}
|
|
133
|
-
return [
|
|
134
|
-
urlAndGlobal.substring(index + 1),
|
|
135
|
-
urlAndGlobal.substring(0, index)
|
|
136
|
-
];
|
|
137
|
-
};
|
|
138
78
|
var onRemoteLoaded = function() {
|
|
139
79
|
try {
|
|
140
|
-
var
|
|
141
|
-
var remoteName = decodeName(globalName, ENCODE_NAME_PREFIX);
|
|
80
|
+
var remoteName = decodeName(remoteInfos[0].name, ENCODE_NAME_PREFIX);
|
|
142
81
|
var remoteModuleName = remoteName + data[1].slice(1);
|
|
143
82
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
144
83
|
loadFactory: false
|
|
@@ -149,7 +88,7 @@ function remotes(options) {
|
|
|
149
88
|
};
|
|
150
89
|
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
151
90
|
"script"
|
|
152
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].
|
|
91
|
+
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
153
92
|
if (useRuntimeLoad) {
|
|
154
93
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
155
94
|
} else {
|
|
@@ -295,6 +234,15 @@ function installInitialConsumes(options) {
|
|
|
295
234
|
});
|
|
296
235
|
}
|
|
297
236
|
|
|
237
|
+
function isLegacyHost(shareScope) {
|
|
238
|
+
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
298
246
|
function initContainerEntry(options) {
|
|
299
247
|
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
|
|
300
248
|
if (!webpackRequire.S) return;
|
|
@@ -304,10 +252,13 @@ function initContainerEntry(options) {
|
|
|
304
252
|
name: webpackRequire.federation.initOptions.name,
|
|
305
253
|
remotes: []
|
|
306
254
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
255
|
+
if (isLegacyHost(shareScope)) {
|
|
256
|
+
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
|
|
257
|
+
if (prevShareScope) {
|
|
258
|
+
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
|
|
311
262
|
}
|
|
312
263
|
webpackRequire.S[name] = shareScope;
|
|
313
264
|
if (webpackRequire.federation.attachShareScopeMap) {
|
|
@@ -333,4 +284,4 @@ var federation = {
|
|
|
333
284
|
bundlerRuntimeOptions: {}
|
|
334
285
|
};
|
|
335
286
|
|
|
336
|
-
export {
|
|
287
|
+
export { federation as default };
|
package/dist/package.json
CHANGED
|
@@ -22,5 +22,26 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@module-federation/runtime": "workspace:*",
|
|
24
24
|
"@module-federation/sdk": "workspace:*"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.esm.js",
|
|
29
|
+
"require": "./dist/index.cjs.js"
|
|
30
|
+
},
|
|
31
|
+
"./constant": {
|
|
32
|
+
"import": "./dist/constant.esm.js",
|
|
33
|
+
"require": "./dist/constant.cjs.js"
|
|
34
|
+
},
|
|
35
|
+
"./*": "./*"
|
|
36
|
+
},
|
|
37
|
+
"typesVersions": {
|
|
38
|
+
"*": {
|
|
39
|
+
".": [
|
|
40
|
+
"./dist/index.cjs.d.ts"
|
|
41
|
+
],
|
|
42
|
+
"constant": [
|
|
43
|
+
"./dist/constant.cjs.d.ts"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
25
46
|
}
|
|
26
47
|
}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/types.d.ts
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.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20231222080837",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Module Federation Runtime for webpack",
|
|
7
7
|
"keywords": [
|
|
@@ -20,7 +20,28 @@
|
|
|
20
20
|
"module": "./dist/index.esm.js",
|
|
21
21
|
"types": "./dist/index.cjs.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
24
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
23
|
+
"@module-federation/runtime": "0.0.0-next-20231222080837",
|
|
24
|
+
"@module-federation/sdk": "0.0.0-next-20231222080837"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.esm.js",
|
|
29
|
+
"require": "./dist/index.cjs.js"
|
|
30
|
+
},
|
|
31
|
+
"./constant": {
|
|
32
|
+
"import": "./dist/constant.esm.js",
|
|
33
|
+
"require": "./dist/constant.cjs.js"
|
|
34
|
+
},
|
|
35
|
+
"./*": "./*"
|
|
36
|
+
},
|
|
37
|
+
"typesVersions": {
|
|
38
|
+
"*": {
|
|
39
|
+
".": [
|
|
40
|
+
"./dist/index.cjs.d.ts"
|
|
41
|
+
],
|
|
42
|
+
"constant": [
|
|
43
|
+
"./dist/constant.cjs.d.ts"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
25
46
|
}
|
|
26
47
|
}
|