@module-federation/webpack-bundler-runtime 0.0.0-next-20231228055514 → 0.0.0-next-20231229074949
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/index.cjs.js +27 -115
- package/dist/index.esm.js +27 -115
- package/dist/package.json +2 -24
- package/dist/src/index.d.ts +0 -1
- package/dist/src/initializeSharing.d.ts +2 -2
- package/dist/src/types.d.ts +9 -32
- package/package.json +5 -27
- package/dist/LICENSE +0 -21
- package/dist/constant.cjs.d.ts +0 -1
- package/dist/constant.cjs.js +0 -11
- package/dist/constant.esm.js +0 -6
- package/dist/src/attachShareScopeMap.d.ts +0 -2
- package/dist/src/constant.d.ts +0 -2
- package/dist/src/initContainerEntry.d.ts +0 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var runtime = require('@module-federation/runtime');
|
|
4
|
-
var sdk = require('@module-federation/sdk');
|
|
5
|
-
var constant = require('./constant.cjs.js');
|
|
6
4
|
|
|
7
5
|
function _interopNamespace(e) {
|
|
8
6
|
if (e && e.__esModule) return e;
|
|
@@ -24,17 +22,8 @@ function _interopNamespace(e) {
|
|
|
24
22
|
|
|
25
23
|
var runtime__namespace = /*#__PURE__*/_interopNamespace(runtime);
|
|
26
24
|
|
|
27
|
-
function attachShareScopeMap(webpackRequire) {
|
|
28
|
-
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
|
|
32
|
-
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
25
|
function remotes(options) {
|
|
36
|
-
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire
|
|
37
|
-
attachShareScopeMap(webpackRequire);
|
|
26
|
+
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire;
|
|
38
27
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
39
28
|
chunkMapping[chunkId].forEach(function(id) {
|
|
40
29
|
var getScope = webpackRequire.R;
|
|
@@ -42,7 +31,6 @@ function remotes(options) {
|
|
|
42
31
|
getScope = [];
|
|
43
32
|
}
|
|
44
33
|
var data = idToExternalAndNameMapping[id];
|
|
45
|
-
var remoteInfos = idToRemoteMap[id];
|
|
46
34
|
// @ts-ignore seems not work
|
|
47
35
|
if (getScope.indexOf(data) >= 0) {
|
|
48
36
|
return;
|
|
@@ -90,6 +78,9 @@ function remotes(options) {
|
|
|
90
78
|
var onInitialized = function(_, external, first) {
|
|
91
79
|
return handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
92
80
|
};
|
|
81
|
+
var useRuntimeLoad = [
|
|
82
|
+
"script"
|
|
83
|
+
].includes(data[3]) && data[4];
|
|
93
84
|
// eslint-disable-next-line no-var
|
|
94
85
|
var onFactory = function(factory) {
|
|
95
86
|
data.p = 1;
|
|
@@ -99,19 +90,14 @@ function remotes(options) {
|
|
|
99
90
|
};
|
|
100
91
|
var onRemoteLoaded = function() {
|
|
101
92
|
try {
|
|
102
|
-
var
|
|
103
|
-
var remoteModuleName = remoteName + data[1].slice(1);
|
|
93
|
+
var remoteModuleName = data[4] + data[1].slice(1);
|
|
104
94
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
105
|
-
loadFactory: false
|
|
106
|
-
from: "build"
|
|
95
|
+
loadFactory: false
|
|
107
96
|
});
|
|
108
97
|
} catch (error) {
|
|
109
98
|
onError(error);
|
|
110
99
|
}
|
|
111
100
|
};
|
|
112
|
-
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
113
|
-
"script"
|
|
114
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
115
101
|
if (useRuntimeLoad) {
|
|
116
102
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
117
103
|
} else {
|
|
@@ -121,9 +107,25 @@ function remotes(options) {
|
|
|
121
107
|
}
|
|
122
108
|
}
|
|
123
109
|
|
|
110
|
+
function proxyShareScopeMap(__webpack_require__) {
|
|
111
|
+
if (!__webpack_require__.S) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// @ts-ignore FIXME: ideal situation is import type from @module-federation/runtime/type ,but the compile will throw error
|
|
115
|
+
__webpack_require__.S = new Proxy(globalThis.__VMOK__.__SHARE__, {
|
|
116
|
+
get: function get(target, prop, receiver) {
|
|
117
|
+
return globalThis.__VMOK__.__SHARE__[prop];
|
|
118
|
+
},
|
|
119
|
+
set: function set(target, prop, value) {
|
|
120
|
+
globalThis.__VMOK__.__SHARE__[prop] = value;
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
124
126
|
function consumes(options) {
|
|
125
127
|
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
126
|
-
|
|
128
|
+
proxyShareScopeMap(webpackRequire);
|
|
127
129
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
128
130
|
chunkMapping[chunkId].forEach(function(id) {
|
|
129
131
|
if (webpackRequire.o(installedModules, id)) {
|
|
@@ -168,61 +170,8 @@ function consumes(options) {
|
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
|
|
171
|
-
function initializeSharing(
|
|
172
|
-
|
|
173
|
-
if (!initScope) initScope = [];
|
|
174
|
-
// handling circular init calls
|
|
175
|
-
var initToken = initTokens[shareScopeName];
|
|
176
|
-
if (!initToken) initToken = initTokens[shareScopeName] = {};
|
|
177
|
-
if (initScope.indexOf(initToken) >= 0) return;
|
|
178
|
-
initScope.push(initToken);
|
|
179
|
-
var promise = initPromises[shareScopeName];
|
|
180
|
-
if (promise) return promise;
|
|
181
|
-
var warn = function(msg) {
|
|
182
|
-
return typeof console !== "undefined" && console.warn && console.warn(msg);
|
|
183
|
-
};
|
|
184
|
-
var initExternal = function(id) {
|
|
185
|
-
var handleError = function(err) {
|
|
186
|
-
return warn("Initialization of sharing external failed: " + err);
|
|
187
|
-
};
|
|
188
|
-
try {
|
|
189
|
-
var module = webpackRequire(id);
|
|
190
|
-
if (!module) return;
|
|
191
|
-
var initFn = function(module) {
|
|
192
|
-
return module && module.init && module.init(webpackRequire.S[shareScopeName], initScope);
|
|
193
|
-
};
|
|
194
|
-
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
195
|
-
var initResult = initFn(module);
|
|
196
|
-
// @ts-ignore
|
|
197
|
-
if (initResult && typeof initResult !== "boolean" && initResult.then) // @ts-ignore
|
|
198
|
-
return promises.push(initResult["catch"](handleError));
|
|
199
|
-
} catch (err) {
|
|
200
|
-
handleError(err);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var promises = webpackRequire.federation.instance.initializeSharing(shareScopeName);
|
|
204
|
-
attachShareScopeMap(webpackRequire);
|
|
205
|
-
var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
|
|
206
|
-
if (bundlerRuntimeRemotesOptions) {
|
|
207
|
-
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) {
|
|
208
|
-
var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
|
|
209
|
-
var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
|
|
210
|
-
if (info.length > 1) {
|
|
211
|
-
initExternal(externalModuleId);
|
|
212
|
-
} else if (info.length === 1) {
|
|
213
|
-
var remoteInfo = info[0];
|
|
214
|
-
if (!constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
215
|
-
initExternal(externalModuleId);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
if (!promises.length) {
|
|
221
|
-
return initPromises[shareScopeName] = true;
|
|
222
|
-
}
|
|
223
|
-
return initPromises[shareScopeName] = Promise.all(promises).then(function() {
|
|
224
|
-
return initPromises[shareScopeName] = true;
|
|
225
|
-
});
|
|
173
|
+
function initializeSharing(shareScopeName, webpackRequire) {
|
|
174
|
+
return webpackRequire.federation.instance.initializeSharing(shareScopeName);
|
|
226
175
|
}
|
|
227
176
|
|
|
228
177
|
function handleInitialConsumes(options) {
|
|
@@ -257,40 +206,6 @@ function installInitialConsumes(options) {
|
|
|
257
206
|
});
|
|
258
207
|
}
|
|
259
208
|
|
|
260
|
-
function isLegacyHost(shareScope) {
|
|
261
|
-
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
|
|
265
|
-
return true;
|
|
266
|
-
}
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
function initContainerEntry(options) {
|
|
270
|
-
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
|
|
271
|
-
if (!webpackRequire.S) return;
|
|
272
|
-
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
273
|
-
var name = shareScopeKey || "default";
|
|
274
|
-
webpackRequire.federation.instance.initOptions({
|
|
275
|
-
name: webpackRequire.federation.initOptions.name,
|
|
276
|
-
remotes: []
|
|
277
|
-
});
|
|
278
|
-
if (isLegacyHost(shareScope)) {
|
|
279
|
-
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
|
|
280
|
-
if (prevShareScope) {
|
|
281
|
-
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
|
|
285
|
-
}
|
|
286
|
-
webpackRequire.S[name] = shareScope;
|
|
287
|
-
if (webpackRequire.federation.attachShareScopeMap) {
|
|
288
|
-
webpackRequire.federation.attachShareScopeMap(webpackRequire);
|
|
289
|
-
}
|
|
290
|
-
// @ts-ignore
|
|
291
|
-
return webpackRequire.I(name, initScope);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
209
|
var federation = {
|
|
295
210
|
runtime: runtime__namespace,
|
|
296
211
|
instance: undefined,
|
|
@@ -300,11 +215,8 @@ var federation = {
|
|
|
300
215
|
consumes: consumes,
|
|
301
216
|
I: initializeSharing,
|
|
302
217
|
S: {},
|
|
303
|
-
installInitialConsumes: installInitialConsumes
|
|
304
|
-
|
|
305
|
-
},
|
|
306
|
-
attachShareScopeMap: attachShareScopeMap,
|
|
307
|
-
bundlerRuntimeOptions: {}
|
|
218
|
+
installInitialConsumes: installInitialConsumes
|
|
219
|
+
}
|
|
308
220
|
};
|
|
309
221
|
|
|
310
222
|
module.exports = federation;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import * as runtime from '@module-federation/runtime';
|
|
2
|
-
import { decodeName } from '@module-federation/sdk';
|
|
3
|
-
import { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES } from './constant.esm.js';
|
|
4
|
-
|
|
5
|
-
function attachShareScopeMap(webpackRequire) {
|
|
6
|
-
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
webpackRequire.S = webpackRequire.federation.instance.shareScopeMap;
|
|
10
|
-
webpackRequire.federation.hasAttachShareScopeMap = true;
|
|
11
|
-
}
|
|
12
2
|
|
|
13
3
|
function remotes(options) {
|
|
14
|
-
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire
|
|
15
|
-
attachShareScopeMap(webpackRequire);
|
|
4
|
+
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, idToExternalAndNameMapping = options.idToExternalAndNameMapping, webpackRequire = options.webpackRequire;
|
|
16
5
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
17
6
|
chunkMapping[chunkId].forEach(function(id) {
|
|
18
7
|
var getScope = webpackRequire.R;
|
|
@@ -20,7 +9,6 @@ function remotes(options) {
|
|
|
20
9
|
getScope = [];
|
|
21
10
|
}
|
|
22
11
|
var data = idToExternalAndNameMapping[id];
|
|
23
|
-
var remoteInfos = idToRemoteMap[id];
|
|
24
12
|
// @ts-ignore seems not work
|
|
25
13
|
if (getScope.indexOf(data) >= 0) {
|
|
26
14
|
return;
|
|
@@ -68,6 +56,9 @@ function remotes(options) {
|
|
|
68
56
|
var onInitialized = function(_, external, first) {
|
|
69
57
|
return handleFunction(external.get, data[1], getScope, 0, onFactory, first);
|
|
70
58
|
};
|
|
59
|
+
var useRuntimeLoad = [
|
|
60
|
+
"script"
|
|
61
|
+
].includes(data[3]) && data[4];
|
|
71
62
|
// eslint-disable-next-line no-var
|
|
72
63
|
var onFactory = function(factory) {
|
|
73
64
|
data.p = 1;
|
|
@@ -77,19 +68,14 @@ function remotes(options) {
|
|
|
77
68
|
};
|
|
78
69
|
var onRemoteLoaded = function() {
|
|
79
70
|
try {
|
|
80
|
-
var
|
|
81
|
-
var remoteModuleName = remoteName + data[1].slice(1);
|
|
71
|
+
var remoteModuleName = data[4] + data[1].slice(1);
|
|
82
72
|
return webpackRequire.federation.instance.loadRemote(remoteModuleName, {
|
|
83
|
-
loadFactory: false
|
|
84
|
-
from: "build"
|
|
73
|
+
loadFactory: false
|
|
85
74
|
});
|
|
86
75
|
} catch (error) {
|
|
87
76
|
onError(error);
|
|
88
77
|
}
|
|
89
78
|
};
|
|
90
|
-
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
91
|
-
"script"
|
|
92
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
93
79
|
if (useRuntimeLoad) {
|
|
94
80
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
95
81
|
} else {
|
|
@@ -99,9 +85,25 @@ function remotes(options) {
|
|
|
99
85
|
}
|
|
100
86
|
}
|
|
101
87
|
|
|
88
|
+
function proxyShareScopeMap(__webpack_require__) {
|
|
89
|
+
if (!__webpack_require__.S) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// @ts-ignore FIXME: ideal situation is import type from @module-federation/runtime/type ,but the compile will throw error
|
|
93
|
+
__webpack_require__.S = new Proxy(globalThis.__VMOK__.__SHARE__, {
|
|
94
|
+
get: function get(target, prop, receiver) {
|
|
95
|
+
return globalThis.__VMOK__.__SHARE__[prop];
|
|
96
|
+
},
|
|
97
|
+
set: function set(target, prop, value) {
|
|
98
|
+
globalThis.__VMOK__.__SHARE__[prop] = value;
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
102
104
|
function consumes(options) {
|
|
103
105
|
var chunkId = options.chunkId, promises = options.promises, chunkMapping = options.chunkMapping, installedModules = options.installedModules, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
104
|
-
|
|
106
|
+
proxyShareScopeMap(webpackRequire);
|
|
105
107
|
if (webpackRequire.o(chunkMapping, chunkId)) {
|
|
106
108
|
chunkMapping[chunkId].forEach(function(id) {
|
|
107
109
|
if (webpackRequire.o(installedModules, id)) {
|
|
@@ -146,61 +148,8 @@ function consumes(options) {
|
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
function initializeSharing(
|
|
150
|
-
|
|
151
|
-
if (!initScope) initScope = [];
|
|
152
|
-
// handling circular init calls
|
|
153
|
-
var initToken = initTokens[shareScopeName];
|
|
154
|
-
if (!initToken) initToken = initTokens[shareScopeName] = {};
|
|
155
|
-
if (initScope.indexOf(initToken) >= 0) return;
|
|
156
|
-
initScope.push(initToken);
|
|
157
|
-
var promise = initPromises[shareScopeName];
|
|
158
|
-
if (promise) return promise;
|
|
159
|
-
var warn = function(msg) {
|
|
160
|
-
return typeof console !== "undefined" && console.warn && console.warn(msg);
|
|
161
|
-
};
|
|
162
|
-
var initExternal = function(id) {
|
|
163
|
-
var handleError = function(err) {
|
|
164
|
-
return warn("Initialization of sharing external failed: " + err);
|
|
165
|
-
};
|
|
166
|
-
try {
|
|
167
|
-
var module = webpackRequire(id);
|
|
168
|
-
if (!module) return;
|
|
169
|
-
var initFn = function(module) {
|
|
170
|
-
return module && module.init && module.init(webpackRequire.S[shareScopeName], initScope);
|
|
171
|
-
};
|
|
172
|
-
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
173
|
-
var initResult = initFn(module);
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
if (initResult && typeof initResult !== "boolean" && initResult.then) // @ts-ignore
|
|
176
|
-
return promises.push(initResult["catch"](handleError));
|
|
177
|
-
} catch (err) {
|
|
178
|
-
handleError(err);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var promises = webpackRequire.federation.instance.initializeSharing(shareScopeName);
|
|
182
|
-
attachShareScopeMap(webpackRequire);
|
|
183
|
-
var bundlerRuntimeRemotesOptions = webpackRequire.federation.bundlerRuntimeOptions.remotes;
|
|
184
|
-
if (bundlerRuntimeRemotesOptions) {
|
|
185
|
-
Object.keys(bundlerRuntimeRemotesOptions.idToRemoteMap).forEach(function(moduleId) {
|
|
186
|
-
var info = bundlerRuntimeRemotesOptions.idToRemoteMap[moduleId];
|
|
187
|
-
var externalModuleId = bundlerRuntimeRemotesOptions.idToExternalAndNameMapping[moduleId][2];
|
|
188
|
-
if (info.length > 1) {
|
|
189
|
-
initExternal(externalModuleId);
|
|
190
|
-
} else if (info.length === 1) {
|
|
191
|
-
var remoteInfo = info[0];
|
|
192
|
-
if (!FEDERATION_SUPPORTED_TYPES.includes(remoteInfo.externalType)) {
|
|
193
|
-
initExternal(externalModuleId);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
if (!promises.length) {
|
|
199
|
-
return initPromises[shareScopeName] = true;
|
|
200
|
-
}
|
|
201
|
-
return initPromises[shareScopeName] = Promise.all(promises).then(function() {
|
|
202
|
-
return initPromises[shareScopeName] = true;
|
|
203
|
-
});
|
|
151
|
+
function initializeSharing(shareScopeName, webpackRequire) {
|
|
152
|
+
return webpackRequire.federation.instance.initializeSharing(shareScopeName);
|
|
204
153
|
}
|
|
205
154
|
|
|
206
155
|
function handleInitialConsumes(options) {
|
|
@@ -235,40 +184,6 @@ function installInitialConsumes(options) {
|
|
|
235
184
|
});
|
|
236
185
|
}
|
|
237
186
|
|
|
238
|
-
function isLegacyHost(shareScope) {
|
|
239
|
-
if ("version" in shareScope && typeof shareScope["version"] !== "object") {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
if ("region" in shareScope && typeof shareScope["region"] !== "object") {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
function initContainerEntry(options) {
|
|
248
|
-
var webpackRequire = options.webpackRequire, shareScope = options.shareScope, initScope = options.initScope, shareScopeKey = options.shareScopeKey;
|
|
249
|
-
if (!webpackRequire.S) return;
|
|
250
|
-
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
251
|
-
var name = shareScopeKey || "default";
|
|
252
|
-
webpackRequire.federation.instance.initOptions({
|
|
253
|
-
name: webpackRequire.federation.initOptions.name,
|
|
254
|
-
remotes: []
|
|
255
|
-
});
|
|
256
|
-
if (isLegacyHost(shareScope)) {
|
|
257
|
-
var prevShareScope = globalThis.__FEDERATION__.__SHARE__["default"];
|
|
258
|
-
if (prevShareScope) {
|
|
259
|
-
webpackRequire.federation.instance.initShareScopeMap(name, prevShareScope);
|
|
260
|
-
}
|
|
261
|
-
} else {
|
|
262
|
-
webpackRequire.federation.instance.initShareScopeMap(name, shareScope);
|
|
263
|
-
}
|
|
264
|
-
webpackRequire.S[name] = shareScope;
|
|
265
|
-
if (webpackRequire.federation.attachShareScopeMap) {
|
|
266
|
-
webpackRequire.federation.attachShareScopeMap(webpackRequire);
|
|
267
|
-
}
|
|
268
|
-
// @ts-ignore
|
|
269
|
-
return webpackRequire.I(name, initScope);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
187
|
var federation = {
|
|
273
188
|
runtime: runtime,
|
|
274
189
|
instance: undefined,
|
|
@@ -278,11 +193,8 @@ var federation = {
|
|
|
278
193
|
consumes: consumes,
|
|
279
194
|
I: initializeSharing,
|
|
280
195
|
S: {},
|
|
281
|
-
installInitialConsumes: installInitialConsumes
|
|
282
|
-
|
|
283
|
-
},
|
|
284
|
-
attachShareScopeMap: attachShareScopeMap,
|
|
285
|
-
bundlerRuntimeOptions: {}
|
|
196
|
+
installInitialConsumes: installInitialConsumes
|
|
197
|
+
}
|
|
286
198
|
};
|
|
287
199
|
|
|
288
200
|
export { federation as default };
|
package/dist/package.json
CHANGED
|
@@ -18,30 +18,8 @@
|
|
|
18
18
|
"author": "zhanghang <hanric.zhang@gmail.com>",
|
|
19
19
|
"main": "./index.cjs.js",
|
|
20
20
|
"module": "./index.esm.js",
|
|
21
|
-
"types": "./
|
|
21
|
+
"types": "./index.cjs.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@module-federation/runtime": "workspace:*"
|
|
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
|
-
}
|
|
23
|
+
"@module-federation/runtime": "workspace:*"
|
|
46
24
|
}
|
|
47
25
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function initializeSharing(
|
|
1
|
+
import { WebpackRequire } from './types';
|
|
2
|
+
export declare function initializeSharing(shareScopeName: string, webpackRequire: WebpackRequire): Promise<boolean> | boolean;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as runtime from '@module-federation/runtime';
|
|
2
2
|
import { initializeSharing } from './initializeSharing';
|
|
3
|
-
import { attachShareScopeMap } from './attachShareScopeMap';
|
|
4
|
-
import { initContainerEntry } from './initContainerEntry';
|
|
5
3
|
type ExcludeUndefined<T> = T extends undefined ? never : T;
|
|
6
4
|
type NonUndefined<T = Shared> = ExcludeUndefined<T>;
|
|
7
5
|
type InitOptions = Parameters<typeof runtime.init>[0];
|
|
@@ -10,15 +8,6 @@ type SharedConfig = NonUndefined<NonUndefined[string]['shareConfig']>;
|
|
|
10
8
|
type ModuleCache = runtime.FederationHost['moduleCache'];
|
|
11
9
|
type InferModule<T> = T extends Map<string, infer U> ? U : never;
|
|
12
10
|
type InferredModule = InferModule<ModuleCache>;
|
|
13
|
-
export type ShareScopeMap = runtime.FederationHost['shareScopeMap'];
|
|
14
|
-
type InitToken = Record<string, Record<string, any>>;
|
|
15
|
-
export interface InitializeSharingOptions {
|
|
16
|
-
shareScopeName: string;
|
|
17
|
-
webpackRequire: WebpackRequire;
|
|
18
|
-
initPromises: Record<string, Promise<boolean> | boolean>;
|
|
19
|
-
initTokens: InitToken;
|
|
20
|
-
initScope: InitToken[];
|
|
21
|
-
}
|
|
22
11
|
export type RemoteEntryExports = NonUndefined<InferredModule['remoteEntryExports']>;
|
|
23
12
|
type ExtractInitParameters<T> = T extends {
|
|
24
13
|
init: (shareScope: infer U, ...args: any[]) => void;
|
|
@@ -27,7 +16,13 @@ type InferredShareScope = ExtractInitParameters<RemoteEntryExports>;
|
|
|
27
16
|
type InferredGlobalShareScope = {
|
|
28
17
|
[scope: string]: InferredShareScope;
|
|
29
18
|
};
|
|
30
|
-
type IdToExternalAndNameMappingItem = [
|
|
19
|
+
type IdToExternalAndNameMappingItem = [
|
|
20
|
+
string,
|
|
21
|
+
string,
|
|
22
|
+
string | number,
|
|
23
|
+
string,
|
|
24
|
+
string
|
|
25
|
+
];
|
|
31
26
|
interface IdToExternalAndNameMappingItemWithPromise extends IdToExternalAndNameMappingItem {
|
|
32
27
|
p?: Promise<any> | number;
|
|
33
28
|
}
|
|
@@ -37,7 +32,7 @@ export interface WebpackRequire {
|
|
|
37
32
|
R: Array<string | number>;
|
|
38
33
|
m: Record<string, (mod: any) => any>;
|
|
39
34
|
c: Record<string, any>;
|
|
40
|
-
I:
|
|
35
|
+
I: typeof initializeSharing;
|
|
41
36
|
S?: InferredGlobalShareScope;
|
|
42
37
|
federation: Federation;
|
|
43
38
|
}
|
|
@@ -50,17 +45,11 @@ interface ModuleToHandlerMappingItem {
|
|
|
50
45
|
shareInfo: ShareInfo;
|
|
51
46
|
shareKey: string;
|
|
52
47
|
}
|
|
53
|
-
interface IdToRemoteMapItem {
|
|
54
|
-
externalType: string;
|
|
55
|
-
name: string;
|
|
56
|
-
externalModuleId?: string | number;
|
|
57
|
-
}
|
|
58
48
|
export interface RemotesOptions {
|
|
59
49
|
chunkId: string | number;
|
|
60
50
|
promises: Promise<any>[];
|
|
61
51
|
chunkMapping: Record<string, Array<string | number>>;
|
|
62
52
|
idToExternalAndNameMapping: Record<string, IdToExternalAndNameMappingItemWithPromise>;
|
|
63
|
-
idToRemoteMap: Record<string, IdToRemoteMapItem[]>;
|
|
64
53
|
webpackRequire: WebpackRequire;
|
|
65
54
|
}
|
|
66
55
|
export interface HandleInitialConsumesOptions {
|
|
@@ -82,12 +71,6 @@ export interface ConsumesOptions {
|
|
|
82
71
|
moduleToHandlerMapping: Record<string, ModuleToHandlerMappingItem>;
|
|
83
72
|
webpackRequire: WebpackRequire;
|
|
84
73
|
}
|
|
85
|
-
export interface InitContainerEntryOptions {
|
|
86
|
-
shareScope: ShareScopeMap[string];
|
|
87
|
-
shareScopeKey: string;
|
|
88
|
-
webpackRequire: WebpackRequire;
|
|
89
|
-
initScope?: InitializeSharingOptions['initScope'];
|
|
90
|
-
}
|
|
91
74
|
export interface Federation {
|
|
92
75
|
runtime?: typeof runtime;
|
|
93
76
|
instance?: runtime.FederationHost;
|
|
@@ -96,15 +79,9 @@ export interface Federation {
|
|
|
96
79
|
bundlerRuntime?: {
|
|
97
80
|
remotes: (options: RemotesOptions) => void;
|
|
98
81
|
consumes: (options: ConsumesOptions) => void;
|
|
99
|
-
I:
|
|
82
|
+
I: (name: string, webpackRequire: WebpackRequire) => Promise<boolean> | boolean;
|
|
100
83
|
S: InferredGlobalShareScope;
|
|
101
84
|
installInitialConsumes: (options: InstallInitialConsumesOptions) => any;
|
|
102
|
-
initContainerEntry: typeof initContainerEntry;
|
|
103
|
-
};
|
|
104
|
-
bundlerRuntimeOptions: {
|
|
105
|
-
remotes?: Exclude<RemotesOptions, 'chunkId' | 'promises'>;
|
|
106
85
|
};
|
|
107
|
-
attachShareScopeMap?: typeof attachShareScopeMap;
|
|
108
|
-
hasAttachShareScopeMap?: boolean;
|
|
109
86
|
}
|
|
110
87
|
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.0.0-next-
|
|
4
|
+
"version": "0.0.0-next-20231229074949",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Module Federation Runtime for webpack",
|
|
7
7
|
"keywords": [
|
|
@@ -16,32 +16,10 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"author": "zhanghang <hanric.zhang@gmail.com>",
|
|
19
|
-
"main": "./
|
|
20
|
-
"module": "./
|
|
21
|
-
"types": "./
|
|
19
|
+
"main": "./index.cjs.js",
|
|
20
|
+
"module": "./index.esm.js",
|
|
21
|
+
"types": "./index.cjs.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
24
|
-
"@module-federation/sdk": "0.0.0-next-20231228055514"
|
|
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
|
-
}
|
|
23
|
+
"@module-federation/runtime": "0.0.0-next-20231229074949"
|
|
46
24
|
}
|
|
47
25
|
}
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
package/dist/constant.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/constant";
|
package/dist/constant.cjs.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
6
|
-
var FEDERATION_SUPPORTED_TYPES = [
|
|
7
|
-
"script"
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
11
|
-
exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
|
package/dist/constant.esm.js
DELETED
package/dist/src/constant.d.ts
DELETED