@module-federation/webpack-bundler-runtime 0.0.0-next-20240511031741 → 0.0.0-next-20240515062211
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 +21 -2
- package/dist/constant.esm.js +20 -3
- package/dist/index.cjs.js +13 -15
- package/dist/index.esm.js +14 -16
- package/dist/package.json +1 -1
- package/dist/src/constant.d.ts +4 -0
- package/package.json +3 -3
package/dist/constant.cjs.js
CHANGED
|
@@ -2,10 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
if (key in obj) {
|
|
7
|
+
Object.defineProperty(obj, key, {
|
|
8
|
+
value: value,
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true
|
|
12
|
+
});
|
|
13
|
+
} else {
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
}
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
var ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
19
|
+
// TODO: support rspack
|
|
20
|
+
var FEDERATION_SUPPORTED_TYPES_CJS = 'cjs:webpack';
|
|
21
|
+
var FEDERATION_SUPPORTED_TYPES_CJS_MAP = _define_property({}, FEDERATION_SUPPORTED_TYPES_CJS, 'commonjs-module');
|
|
6
22
|
var FEDERATION_SUPPORTED_TYPES = [
|
|
7
|
-
|
|
23
|
+
'script',
|
|
24
|
+
FEDERATION_SUPPORTED_TYPES_CJS
|
|
8
25
|
];
|
|
9
26
|
|
|
10
27
|
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
11
28
|
exports.FEDERATION_SUPPORTED_TYPES = FEDERATION_SUPPORTED_TYPES;
|
|
29
|
+
exports.FEDERATION_SUPPORTED_TYPES_CJS = FEDERATION_SUPPORTED_TYPES_CJS;
|
|
30
|
+
exports.FEDERATION_SUPPORTED_TYPES_CJS_MAP = FEDERATION_SUPPORTED_TYPES_CJS_MAP;
|
package/dist/constant.esm.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
var ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
15
|
+
// TODO: support rspack
|
|
16
|
+
var FEDERATION_SUPPORTED_TYPES_CJS = 'cjs:webpack';
|
|
17
|
+
var FEDERATION_SUPPORTED_TYPES_CJS_MAP = _define_property({}, FEDERATION_SUPPORTED_TYPES_CJS, 'commonjs-module');
|
|
2
18
|
var FEDERATION_SUPPORTED_TYPES = [
|
|
3
|
-
|
|
19
|
+
'script',
|
|
20
|
+
FEDERATION_SUPPORTED_TYPES_CJS
|
|
4
21
|
];
|
|
5
22
|
|
|
6
|
-
export { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES };
|
|
23
|
+
export { ENCODE_NAME_PREFIX, FEDERATION_SUPPORTED_TYPES, FEDERATION_SUPPORTED_TYPES_CJS, FEDERATION_SUPPORTED_TYPES_CJS_MAP };
|
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,15 +103,13 @@ 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
|
-
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
113
|
-
"script"
|
|
114
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
112
|
+
var useRuntimeLoad = remoteInfos.length === 1 && constant.FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
115
113
|
if (useRuntimeLoad) {
|
|
116
114
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
117
115
|
} else {
|
|
@@ -146,7 +144,7 @@ function consumes(options) {
|
|
|
146
144
|
try {
|
|
147
145
|
var federationInstance = webpackRequire.federation.instance;
|
|
148
146
|
if (!federationInstance) {
|
|
149
|
-
throw new Error(
|
|
147
|
+
throw new Error('Federation instance not found!');
|
|
150
148
|
}
|
|
151
149
|
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo;
|
|
152
150
|
var promise = federationInstance.loadShare(shareKey, {
|
|
@@ -181,11 +179,11 @@ function initializeSharing(param) {
|
|
|
181
179
|
var promise = initPromises[shareScopeName];
|
|
182
180
|
if (promise) return promise;
|
|
183
181
|
var warn = function(msg) {
|
|
184
|
-
return typeof console !==
|
|
182
|
+
return typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
185
183
|
};
|
|
186
184
|
var initExternal = function(id) {
|
|
187
185
|
var handleError = function(err) {
|
|
188
|
-
return warn(
|
|
186
|
+
return warn('Initialization of sharing external failed: ' + err);
|
|
189
187
|
};
|
|
190
188
|
try {
|
|
191
189
|
var module = webpackRequire(id);
|
|
@@ -197,8 +195,8 @@ function initializeSharing(param) {
|
|
|
197
195
|
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
198
196
|
var initResult = initFn(module);
|
|
199
197
|
// @ts-ignore
|
|
200
|
-
if (initResult && typeof initResult !==
|
|
201
|
-
return promises.push(initResult[
|
|
198
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then) // @ts-ignore
|
|
199
|
+
return promises.push(initResult['catch'](handleError));
|
|
202
200
|
} catch (err) {
|
|
203
201
|
handleError(err);
|
|
204
202
|
}
|
|
@@ -232,7 +230,7 @@ function handleInitialConsumes(options) {
|
|
|
232
230
|
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
233
231
|
var federationInstance = webpackRequire.federation.instance;
|
|
234
232
|
if (!federationInstance) {
|
|
235
|
-
throw new Error(
|
|
233
|
+
throw new Error('Federation instance not found!');
|
|
236
234
|
}
|
|
237
235
|
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo;
|
|
238
236
|
try {
|
|
@@ -241,7 +239,7 @@ function handleInitialConsumes(options) {
|
|
|
241
239
|
});
|
|
242
240
|
} catch (err) {
|
|
243
241
|
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(
|
|
242
|
+
console.error('The original error message is as follows: ');
|
|
245
243
|
throw err;
|
|
246
244
|
}
|
|
247
245
|
}
|
|
@@ -257,7 +255,7 @@ function installInitialConsumes(options) {
|
|
|
257
255
|
moduleToHandlerMapping: moduleToHandlerMapping,
|
|
258
256
|
webpackRequire: webpackRequire
|
|
259
257
|
});
|
|
260
|
-
if (typeof factory !==
|
|
258
|
+
if (typeof factory !== 'function') {
|
|
261
259
|
throw new Error("Shared module is not available for eager consumption: ".concat(id));
|
|
262
260
|
}
|
|
263
261
|
module.exports = factory();
|
|
@@ -298,7 +296,7 @@ function initContainerEntry(options) {
|
|
|
298
296
|
if (!webpackRequire.S) return;
|
|
299
297
|
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
300
298
|
var federationInstance = webpackRequire.federation.instance;
|
|
301
|
-
var name = shareScopeKey ||
|
|
299
|
+
var name = shareScopeKey || 'default';
|
|
302
300
|
federationInstance.initOptions(_object_spread({
|
|
303
301
|
name: webpackRequire.federation.initOptions.name,
|
|
304
302
|
remotes: []
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as runtime from '@module-federation/runtime';
|
|
2
2
|
import { decodeName } from '@module-federation/sdk';
|
|
3
|
-
import {
|
|
3
|
+
import { FEDERATION_SUPPORTED_TYPES, ENCODE_NAME_PREFIX } from './constant.esm.js';
|
|
4
4
|
|
|
5
5
|
function attachShareScopeMap(webpackRequire) {
|
|
6
6
|
if (!webpackRequire.S || webpackRequire.federation.hasAttachShareScopeMap || !webpackRequire.federation.instance || !webpackRequire.federation.instance.shareScopeMap) {
|
|
@@ -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,15 +81,13 @@ 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
|
-
var useRuntimeLoad = remoteInfos.length === 1 && [
|
|
91
|
-
"script"
|
|
92
|
-
].includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
90
|
+
var useRuntimeLoad = remoteInfos.length === 1 && FEDERATION_SUPPORTED_TYPES.includes(remoteInfos[0].externalType) && remoteInfos[0].name;
|
|
93
91
|
if (useRuntimeLoad) {
|
|
94
92
|
handleFunction(onRemoteLoaded, data[2], 0, 0, onFactory, 1);
|
|
95
93
|
} else {
|
|
@@ -124,7 +122,7 @@ function consumes(options) {
|
|
|
124
122
|
try {
|
|
125
123
|
var federationInstance = webpackRequire.federation.instance;
|
|
126
124
|
if (!federationInstance) {
|
|
127
|
-
throw new Error(
|
|
125
|
+
throw new Error('Federation instance not found!');
|
|
128
126
|
}
|
|
129
127
|
var _moduleToHandlerMapping_id = moduleToHandlerMapping[id], shareKey = _moduleToHandlerMapping_id.shareKey, getter = _moduleToHandlerMapping_id.getter, shareInfo = _moduleToHandlerMapping_id.shareInfo;
|
|
130
128
|
var promise = federationInstance.loadShare(shareKey, {
|
|
@@ -159,11 +157,11 @@ function initializeSharing(param) {
|
|
|
159
157
|
var promise = initPromises[shareScopeName];
|
|
160
158
|
if (promise) return promise;
|
|
161
159
|
var warn = function(msg) {
|
|
162
|
-
return typeof console !==
|
|
160
|
+
return typeof console !== 'undefined' && console.warn && console.warn(msg);
|
|
163
161
|
};
|
|
164
162
|
var initExternal = function(id) {
|
|
165
163
|
var handleError = function(err) {
|
|
166
|
-
return warn(
|
|
164
|
+
return warn('Initialization of sharing external failed: ' + err);
|
|
167
165
|
};
|
|
168
166
|
try {
|
|
169
167
|
var module = webpackRequire(id);
|
|
@@ -175,8 +173,8 @@ function initializeSharing(param) {
|
|
|
175
173
|
if (module.then) return promises.push(module.then(initFn, handleError));
|
|
176
174
|
var initResult = initFn(module);
|
|
177
175
|
// @ts-ignore
|
|
178
|
-
if (initResult && typeof initResult !==
|
|
179
|
-
return promises.push(initResult[
|
|
176
|
+
if (initResult && typeof initResult !== 'boolean' && initResult.then) // @ts-ignore
|
|
177
|
+
return promises.push(initResult['catch'](handleError));
|
|
180
178
|
} catch (err) {
|
|
181
179
|
handleError(err);
|
|
182
180
|
}
|
|
@@ -210,7 +208,7 @@ function handleInitialConsumes(options) {
|
|
|
210
208
|
var moduleId = options.moduleId, moduleToHandlerMapping = options.moduleToHandlerMapping, webpackRequire = options.webpackRequire;
|
|
211
209
|
var federationInstance = webpackRequire.federation.instance;
|
|
212
210
|
if (!federationInstance) {
|
|
213
|
-
throw new Error(
|
|
211
|
+
throw new Error('Federation instance not found!');
|
|
214
212
|
}
|
|
215
213
|
var _moduleToHandlerMapping_moduleId = moduleToHandlerMapping[moduleId], shareKey = _moduleToHandlerMapping_moduleId.shareKey, shareInfo = _moduleToHandlerMapping_moduleId.shareInfo;
|
|
216
214
|
try {
|
|
@@ -219,7 +217,7 @@ function handleInitialConsumes(options) {
|
|
|
219
217
|
});
|
|
220
218
|
} catch (err) {
|
|
221
219
|
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(
|
|
220
|
+
console.error('The original error message is as follows: ');
|
|
223
221
|
throw err;
|
|
224
222
|
}
|
|
225
223
|
}
|
|
@@ -235,7 +233,7 @@ function installInitialConsumes(options) {
|
|
|
235
233
|
moduleToHandlerMapping: moduleToHandlerMapping,
|
|
236
234
|
webpackRequire: webpackRequire
|
|
237
235
|
});
|
|
238
|
-
if (typeof factory !==
|
|
236
|
+
if (typeof factory !== 'function') {
|
|
239
237
|
throw new Error("Shared module is not available for eager consumption: ".concat(id));
|
|
240
238
|
}
|
|
241
239
|
module.exports = factory();
|
|
@@ -276,7 +274,7 @@ function initContainerEntry(options) {
|
|
|
276
274
|
if (!webpackRequire.S) return;
|
|
277
275
|
if (!webpackRequire.federation || !webpackRequire.federation.instance || !webpackRequire.federation.initOptions) return;
|
|
278
276
|
var federationInstance = webpackRequire.federation.instance;
|
|
279
|
-
var name = shareScopeKey ||
|
|
277
|
+
var name = shareScopeKey || 'default';
|
|
280
278
|
federationInstance.initOptions(_object_spread({
|
|
281
279
|
name: webpackRequire.federation.initOptions.name,
|
|
282
280
|
remotes: []
|
package/dist/package.json
CHANGED
package/dist/src/constant.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
2
|
+
export declare const FEDERATION_SUPPORTED_TYPES_CJS = "cjs:webpack";
|
|
3
|
+
export declare const FEDERATION_SUPPORTED_TYPES_CJS_MAP: {
|
|
4
|
+
"cjs:webpack": string;
|
|
5
|
+
};
|
|
2
6
|
export declare const FEDERATION_SUPPORTED_TYPES: string[];
|
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-20240515062211",
|
|
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.0.0-next-
|
|
24
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
23
|
+
"@module-federation/runtime": "0.0.0-next-20240515062211",
|
|
24
|
+
"@module-federation/sdk": "0.0.0-next-20240515062211"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|