@module-federation/utilities 3.0.16 → 3.0.18
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 +56 -56
- package/dist/index.esm.js +56 -56
- package/dist/package.json +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -66,10 +66,10 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
66
66
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
67
67
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
68
68
|
}
|
|
69
|
-
var pure = typeof process !==
|
|
69
|
+
var pure = typeof process !== 'undefined' ? process.env['REMOTES'] || {} : {};
|
|
70
70
|
var remoteVars = pure;
|
|
71
71
|
var extractUrlAndGlobal = function(urlAndGlobal) {
|
|
72
|
-
var index = urlAndGlobal.indexOf(
|
|
72
|
+
var index = urlAndGlobal.indexOf('@');
|
|
73
73
|
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
74
74
|
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
|
|
75
75
|
}
|
|
@@ -82,9 +82,9 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
82
82
|
var runtimeRemotes = getRuntimeRemotes$1();
|
|
83
83
|
// 1) Load remote container if needed
|
|
84
84
|
var asyncContainer;
|
|
85
|
-
var reference = typeof keyOrRuntimeRemoteItem ===
|
|
85
|
+
var reference = typeof keyOrRuntimeRemoteItem === 'string' ? runtimeRemotes[keyOrRuntimeRemoteItem] : keyOrRuntimeRemoteItem;
|
|
86
86
|
if (reference.asyncContainer) {
|
|
87
|
-
asyncContainer = typeof reference.asyncContainer.then ===
|
|
87
|
+
asyncContainer = typeof reference.asyncContainer.then === 'function' ? reference.asyncContainer : reference.asyncContainer();
|
|
88
88
|
} else {
|
|
89
89
|
// This casting is just to satisfy typescript,
|
|
90
90
|
// In reality remoteGlobal will always be a string;
|
|
@@ -94,21 +94,21 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
94
94
|
var __webpack_error__ = new Error();
|
|
95
95
|
// @ts-ignore
|
|
96
96
|
var globalScope = // @ts-ignore
|
|
97
|
-
typeof window !==
|
|
98
|
-
if (typeof window ===
|
|
97
|
+
typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
98
|
+
if (typeof window === 'undefined') {
|
|
99
99
|
//@ts-ignore
|
|
100
|
-
globalScope[
|
|
100
|
+
globalScope['_config'][containerKey] = reference.url;
|
|
101
101
|
} else {
|
|
102
102
|
// to match promise template system, can be removed once promise template is gone
|
|
103
103
|
//@ts-ignore
|
|
104
|
-
if (!globalScope[
|
|
104
|
+
if (!globalScope['remoteLoading']) {
|
|
105
105
|
//@ts-ignore
|
|
106
|
-
globalScope[
|
|
106
|
+
globalScope['remoteLoading'] = {};
|
|
107
107
|
}
|
|
108
108
|
//@ts-ignore
|
|
109
|
-
if (globalScope[
|
|
109
|
+
if (globalScope['remoteLoading'][containerKey]) {
|
|
110
110
|
//@ts-ignore
|
|
111
|
-
return globalScope[
|
|
111
|
+
return globalScope['remoteLoading'][containerKey];
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
// @ts-ignore
|
|
@@ -119,30 +119,30 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
119
119
|
return resolve(asyncContainer);
|
|
120
120
|
}
|
|
121
121
|
//@ts-ignore
|
|
122
|
-
if (typeof globalScope[remoteGlobal] !==
|
|
122
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
123
123
|
return resolveRemoteGlobal();
|
|
124
124
|
}
|
|
125
125
|
__webpack_require__.l(reference.url, function(event) {
|
|
126
126
|
//@ts-ignore
|
|
127
|
-
if (typeof globalScope[remoteGlobal] !==
|
|
127
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
128
128
|
return resolveRemoteGlobal();
|
|
129
129
|
}
|
|
130
|
-
var errorType = event && (event.type ===
|
|
130
|
+
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
131
131
|
var realSrc = event && event.target && event.target.src;
|
|
132
|
-
__webpack_error__.message =
|
|
133
|
-
__webpack_error__.name =
|
|
132
|
+
__webpack_error__.message = 'Loading script failed.\n(' + errorType + ': ' + realSrc + ' or global var ' + remoteGlobal + ')';
|
|
133
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
134
134
|
__webpack_error__.type = errorType;
|
|
135
135
|
__webpack_error__.request = realSrc;
|
|
136
136
|
reject(__webpack_error__);
|
|
137
137
|
}, containerKey);
|
|
138
138
|
}).catch(function(err) {
|
|
139
|
-
console.error(
|
|
139
|
+
console.error('container is offline, returning fake remote');
|
|
140
140
|
console.error(err);
|
|
141
141
|
return {
|
|
142
142
|
fake: true,
|
|
143
143
|
// @ts-ignore
|
|
144
144
|
get: function(arg) {
|
|
145
|
-
console.warn(
|
|
145
|
+
console.warn('faking', arg, 'module on, its offline');
|
|
146
146
|
return Promise.resolve(function() {
|
|
147
147
|
return {
|
|
148
148
|
__esModule: true,
|
|
@@ -156,9 +156,9 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
156
156
|
init: function() {}
|
|
157
157
|
};
|
|
158
158
|
});
|
|
159
|
-
if (typeof window !==
|
|
159
|
+
if (typeof window !== 'undefined') {
|
|
160
160
|
//@ts-ignore
|
|
161
|
-
globalScope[
|
|
161
|
+
globalScope['remoteLoading'][containerKey] = asyncContainer;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
return asyncContainer;
|
|
@@ -166,19 +166,19 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
166
166
|
var getRuntimeRemotes$1 = function() {
|
|
167
167
|
return Object.entries(remoteVars).reduce(function(acc, param) {
|
|
168
168
|
var _param = _sliced_to_array$3(param, 2), key = _param[0], value = _param[1];
|
|
169
|
-
if (typeof value ===
|
|
169
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
170
170
|
acc[key] = {
|
|
171
171
|
asyncContainer: value
|
|
172
172
|
};
|
|
173
|
-
} else if (typeof value ===
|
|
173
|
+
} else if (typeof value === 'function') {
|
|
174
174
|
acc[key] = {
|
|
175
175
|
asyncContainer: Promise.resolve(value())
|
|
176
176
|
};
|
|
177
|
-
} else if (typeof value ===
|
|
178
|
-
if (value.startsWith(
|
|
179
|
-
var _value_replace_split = _sliced_to_array$3(value.replace(
|
|
177
|
+
} else if (typeof value === 'string') {
|
|
178
|
+
if (value.startsWith('internal ')) {
|
|
179
|
+
var _value_replace_split = _sliced_to_array$3(value.replace('internal ', '').split('?'), 2); _value_replace_split[0]; var query = _value_replace_split[1];
|
|
180
180
|
if (query) {
|
|
181
|
-
var remoteSyntax = new URLSearchParams(query).get(
|
|
181
|
+
var remoteSyntax = new URLSearchParams(query).get('remote');
|
|
182
182
|
if (remoteSyntax) {
|
|
183
183
|
var _extractUrlAndGlobal = _sliced_to_array$3(extractUrlAndGlobal(remoteSyntax), 2), url = _extractUrlAndGlobal[0], global = _extractUrlAndGlobal[1];
|
|
184
184
|
acc[key] = {
|
|
@@ -195,7 +195,7 @@ var getRuntimeRemotes$1 = function() {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
} else {
|
|
198
|
-
console.warn(
|
|
198
|
+
console.warn('remotes process', process.env['REMOTES']);
|
|
199
199
|
throw new Error('[mf] Invalid value received for runtime_remote "'.concat(key, '"'));
|
|
200
200
|
}
|
|
201
201
|
return acc;
|
|
@@ -375,9 +375,9 @@ function _ts_generator$2(thisArg, body) {
|
|
|
375
375
|
var createContainerSharingScope = function(asyncContainer) {
|
|
376
376
|
// @ts-ignore
|
|
377
377
|
return asyncContainer.then(function(container) {
|
|
378
|
-
if (!__webpack_share_scopes__[
|
|
378
|
+
if (!__webpack_share_scopes__['default']) {
|
|
379
379
|
// not always a promise, so we wrap it in a resolve
|
|
380
|
-
return Promise.resolve(__webpack_init_sharing__(
|
|
380
|
+
return Promise.resolve(__webpack_init_sharing__('default')).then(function() {
|
|
381
381
|
return container;
|
|
382
382
|
});
|
|
383
383
|
} else {
|
|
@@ -392,7 +392,7 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
392
392
|
// The problem may be in Proxy in NextFederationPlugin.js.
|
|
393
393
|
// or maybe a bug in the webpack itself - instead of returning rejected promise it just throws an error.
|
|
394
394
|
// But now everything works properly and we keep this code as is.
|
|
395
|
-
container.init(__webpack_share_scopes__[
|
|
395
|
+
container.init(__webpack_share_scopes__['default']);
|
|
396
396
|
} catch (e) {
|
|
397
397
|
// maybe container already initialized so nothing to throw
|
|
398
398
|
}
|
|
@@ -433,8 +433,8 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
433
433
|
}
|
|
434
434
|
return Object.entries(remotes).reduce(function(acc, param) {
|
|
435
435
|
var _param = _sliced_to_array$2(param, 2), key = _param[0], value = _param[1];
|
|
436
|
-
if (value.startsWith(
|
|
437
|
-
var promiseCall = value.split(
|
|
436
|
+
if (value.startsWith('promise ') || value.startsWith('external ')) {
|
|
437
|
+
var promiseCall = value.split(' ')[1];
|
|
438
438
|
acc[key] = "function() {\n return ".concat(promiseCall, "\n }");
|
|
439
439
|
} else {
|
|
440
440
|
acc[key] = JSON.stringify(value);
|
|
@@ -454,8 +454,8 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
454
454
|
if (!remoteContainer) {
|
|
455
455
|
throw Error("Remote container options is empty");
|
|
456
456
|
}
|
|
457
|
-
containerScope = typeof window !==
|
|
458
|
-
if (!(typeof remoteContainer ===
|
|
457
|
+
containerScope = typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
458
|
+
if (!(typeof remoteContainer === 'string')) return [
|
|
459
459
|
3,
|
|
460
460
|
1
|
|
461
461
|
];
|
|
@@ -538,7 +538,7 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
538
538
|
if (exportName) {
|
|
539
539
|
return [
|
|
540
540
|
2,
|
|
541
|
-
mod && typeof mod ===
|
|
541
|
+
mod && typeof mod === 'object' ? mod[exportName] : undefined
|
|
542
542
|
];
|
|
543
543
|
} else {
|
|
544
544
|
return [
|
|
@@ -797,7 +797,7 @@ function _ts_generator$1(thisArg, body) {
|
|
|
797
797
|
/**
|
|
798
798
|
* Constant for remote entry file
|
|
799
799
|
* @constant {string}
|
|
800
|
-
*/ var REMOTE_ENTRY_FILE =
|
|
800
|
+
*/ var REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
801
801
|
/**
|
|
802
802
|
* Function to load remote
|
|
803
803
|
* @function
|
|
@@ -807,18 +807,18 @@ function _ts_generator$1(thisArg, body) {
|
|
|
807
807
|
* @returns {Promise<void>} A promise that resolves when the remote is loaded
|
|
808
808
|
*/ var loadRemote = function(url, scope, bustRemoteEntryCache) {
|
|
809
809
|
return new Promise(function(resolve, reject) {
|
|
810
|
-
var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) :
|
|
810
|
+
var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) : '';
|
|
811
811
|
var webpackRequire = __webpack_require__;
|
|
812
812
|
webpackRequire.l("".concat(url).concat(timestamp), function(event) {
|
|
813
813
|
var _event_target;
|
|
814
|
-
if ((event === null || event === void 0 ? void 0 : event.type) ===
|
|
814
|
+
if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
|
|
815
815
|
// Script loaded successfully:
|
|
816
816
|
return resolve();
|
|
817
817
|
}
|
|
818
818
|
var realSrc = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.src;
|
|
819
819
|
var error = new Error();
|
|
820
|
-
error.message =
|
|
821
|
-
error.name =
|
|
820
|
+
error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
|
|
821
|
+
error.name = 'ScriptExternalLoadError';
|
|
822
822
|
reject(error);
|
|
823
823
|
}, scope);
|
|
824
824
|
});
|
|
@@ -869,7 +869,7 @@ var loadEsmRemote = function() {
|
|
|
869
869
|
];
|
|
870
870
|
return [
|
|
871
871
|
4,
|
|
872
|
-
__webpack_init_sharing__(
|
|
872
|
+
__webpack_init_sharing__('default')
|
|
873
873
|
];
|
|
874
874
|
case 1:
|
|
875
875
|
_state.sent();
|
|
@@ -958,8 +958,8 @@ var loadEsmRemote = function() {
|
|
|
958
958
|
3,
|
|
959
959
|
6
|
|
960
960
|
];
|
|
961
|
-
remoteUrl =
|
|
962
|
-
if (!(typeof url ===
|
|
961
|
+
remoteUrl = '';
|
|
962
|
+
if (!(typeof url === 'string')) return [
|
|
963
963
|
3,
|
|
964
964
|
1
|
|
965
965
|
];
|
|
@@ -996,7 +996,7 @@ var loadEsmRemote = function() {
|
|
|
996
996
|
4,
|
|
997
997
|
Promise.all([
|
|
998
998
|
initContainer(window[remoteScope]),
|
|
999
|
-
window[remoteScope].get(module ===
|
|
999
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : "./".concat(module))
|
|
1000
1000
|
])
|
|
1001
1001
|
];
|
|
1002
1002
|
case 5:
|
|
@@ -1011,7 +1011,7 @@ var loadEsmRemote = function() {
|
|
|
1011
1011
|
case 6:
|
|
1012
1012
|
return [
|
|
1013
1013
|
4,
|
|
1014
|
-
window[remoteScope].get(module ===
|
|
1014
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : "./".concat(module))
|
|
1015
1015
|
];
|
|
1016
1016
|
case 7:
|
|
1017
1017
|
moduleFactory1 = _state.sent();
|
|
@@ -1137,19 +1137,19 @@ var getRuntimeRemotes = function() {
|
|
|
1137
1137
|
return Object.entries(remoteVars).reduce(function(acc, item) {
|
|
1138
1138
|
var _item = _sliced_to_array(item, 2), key = _item[0], value = _item[1];
|
|
1139
1139
|
// if its an object with a thenable (eagerly executing function)
|
|
1140
|
-
if (typeof value ===
|
|
1140
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
1141
1141
|
acc[key] = {
|
|
1142
1142
|
asyncContainer: value
|
|
1143
1143
|
};
|
|
1144
|
-
} else if (typeof value ===
|
|
1144
|
+
} else if (typeof value === 'function') {
|
|
1145
1145
|
// @ts-ignore
|
|
1146
1146
|
acc[key] = {
|
|
1147
1147
|
asyncContainer: value
|
|
1148
1148
|
};
|
|
1149
|
-
} else if (typeof value ===
|
|
1150
|
-
var _value_replace_split = _sliced_to_array(value.replace(
|
|
1149
|
+
} else if (typeof value === 'string' && value.startsWith('internal ')) {
|
|
1150
|
+
var _value_replace_split = _sliced_to_array(value.replace('internal ', '').split('?'), 2), request = _value_replace_split[0], query = _value_replace_split[1];
|
|
1151
1151
|
if (query) {
|
|
1152
|
-
var remoteSyntax = new URLSearchParams(query).get(
|
|
1152
|
+
var remoteSyntax = new URLSearchParams(query).get('remote');
|
|
1153
1153
|
if (remoteSyntax) {
|
|
1154
1154
|
var _extractUrlAndGlobal = _sliced_to_array(extractUrlAndGlobal(remoteSyntax), 2), url = _extractUrlAndGlobal[0], global = _extractUrlAndGlobal[1];
|
|
1155
1155
|
acc[key] = {
|
|
@@ -1158,7 +1158,7 @@ var getRuntimeRemotes = function() {
|
|
|
1158
1158
|
};
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
|
-
} else if (typeof value ===
|
|
1161
|
+
} else if (typeof value === 'string') {
|
|
1162
1162
|
var _extractUrlAndGlobal1 = _sliced_to_array(extractUrlAndGlobal(value), 2), url1 = _extractUrlAndGlobal1[0], global1 = _extractUrlAndGlobal1[1];
|
|
1163
1163
|
acc[key] = {
|
|
1164
1164
|
global: global1,
|
|
@@ -1166,13 +1166,13 @@ var getRuntimeRemotes = function() {
|
|
|
1166
1166
|
};
|
|
1167
1167
|
} else {
|
|
1168
1168
|
//@ts-ignore
|
|
1169
|
-
console.warn(
|
|
1169
|
+
console.warn('remotes process', process.env.REMOTES);
|
|
1170
1170
|
throw new Error('[mf] Invalid value received for runtime_remote "'.concat(key, '"'));
|
|
1171
1171
|
}
|
|
1172
1172
|
return acc;
|
|
1173
1173
|
}, {});
|
|
1174
1174
|
} catch (err) {
|
|
1175
|
-
console.warn(
|
|
1175
|
+
console.warn('Unable to retrieve runtime remotes: ', err);
|
|
1176
1176
|
}
|
|
1177
1177
|
return {};
|
|
1178
1178
|
};
|
|
@@ -1312,8 +1312,8 @@ var importDelegatedModule = function() {
|
|
|
1312
1312
|
}).then(function(asyncContainer) {
|
|
1313
1313
|
// most of this is only needed because of legacy promise based implementation
|
|
1314
1314
|
// can remove proxies once we remove promise based implementations
|
|
1315
|
-
if (typeof window ===
|
|
1316
|
-
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem,
|
|
1315
|
+
if (typeof window === 'undefined') {
|
|
1316
|
+
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, 'globalThis')) {
|
|
1317
1317
|
return asyncContainer;
|
|
1318
1318
|
}
|
|
1319
1319
|
// return asyncContainer;
|
|
@@ -1323,7 +1323,7 @@ var importDelegatedModule = function() {
|
|
|
1323
1323
|
//@ts-ignore
|
|
1324
1324
|
return asyncContainer.get(arg).then(function(f) {
|
|
1325
1325
|
var _loop = function(prop) {
|
|
1326
|
-
if (typeof m[prop] ===
|
|
1326
|
+
if (typeof m[prop] === 'function') {
|
|
1327
1327
|
Object.defineProperty(result, prop, {
|
|
1328
1328
|
get: function get() {
|
|
1329
1329
|
return function() {
|
package/dist/index.esm.js
CHANGED
|
@@ -44,10 +44,10 @@ function _unsupported_iterable_to_array$3(o, minLen) {
|
|
|
44
44
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
45
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
46
46
|
}
|
|
47
|
-
var pure = typeof process !==
|
|
47
|
+
var pure = typeof process !== 'undefined' ? process.env['REMOTES'] || {} : {};
|
|
48
48
|
var remoteVars = pure;
|
|
49
49
|
var extractUrlAndGlobal = function(urlAndGlobal) {
|
|
50
|
-
var index = urlAndGlobal.indexOf(
|
|
50
|
+
var index = urlAndGlobal.indexOf('@');
|
|
51
51
|
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
52
52
|
throw new Error('Invalid request "'.concat(urlAndGlobal, '"'));
|
|
53
53
|
}
|
|
@@ -60,9 +60,9 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
60
60
|
var runtimeRemotes = getRuntimeRemotes$1();
|
|
61
61
|
// 1) Load remote container if needed
|
|
62
62
|
var asyncContainer;
|
|
63
|
-
var reference = typeof keyOrRuntimeRemoteItem ===
|
|
63
|
+
var reference = typeof keyOrRuntimeRemoteItem === 'string' ? runtimeRemotes[keyOrRuntimeRemoteItem] : keyOrRuntimeRemoteItem;
|
|
64
64
|
if (reference.asyncContainer) {
|
|
65
|
-
asyncContainer = typeof reference.asyncContainer.then ===
|
|
65
|
+
asyncContainer = typeof reference.asyncContainer.then === 'function' ? reference.asyncContainer : reference.asyncContainer();
|
|
66
66
|
} else {
|
|
67
67
|
// This casting is just to satisfy typescript,
|
|
68
68
|
// In reality remoteGlobal will always be a string;
|
|
@@ -72,21 +72,21 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
72
72
|
var __webpack_error__ = new Error();
|
|
73
73
|
// @ts-ignore
|
|
74
74
|
var globalScope = // @ts-ignore
|
|
75
|
-
typeof window !==
|
|
76
|
-
if (typeof window ===
|
|
75
|
+
typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
76
|
+
if (typeof window === 'undefined') {
|
|
77
77
|
//@ts-ignore
|
|
78
|
-
globalScope[
|
|
78
|
+
globalScope['_config'][containerKey] = reference.url;
|
|
79
79
|
} else {
|
|
80
80
|
// to match promise template system, can be removed once promise template is gone
|
|
81
81
|
//@ts-ignore
|
|
82
|
-
if (!globalScope[
|
|
82
|
+
if (!globalScope['remoteLoading']) {
|
|
83
83
|
//@ts-ignore
|
|
84
|
-
globalScope[
|
|
84
|
+
globalScope['remoteLoading'] = {};
|
|
85
85
|
}
|
|
86
86
|
//@ts-ignore
|
|
87
|
-
if (globalScope[
|
|
87
|
+
if (globalScope['remoteLoading'][containerKey]) {
|
|
88
88
|
//@ts-ignore
|
|
89
|
-
return globalScope[
|
|
89
|
+
return globalScope['remoteLoading'][containerKey];
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
// @ts-ignore
|
|
@@ -97,30 +97,30 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
97
97
|
return resolve(asyncContainer);
|
|
98
98
|
}
|
|
99
99
|
//@ts-ignore
|
|
100
|
-
if (typeof globalScope[remoteGlobal] !==
|
|
100
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
101
101
|
return resolveRemoteGlobal();
|
|
102
102
|
}
|
|
103
103
|
__webpack_require__.l(reference.url, function(event) {
|
|
104
104
|
//@ts-ignore
|
|
105
|
-
if (typeof globalScope[remoteGlobal] !==
|
|
105
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
106
106
|
return resolveRemoteGlobal();
|
|
107
107
|
}
|
|
108
|
-
var errorType = event && (event.type ===
|
|
108
|
+
var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
109
109
|
var realSrc = event && event.target && event.target.src;
|
|
110
|
-
__webpack_error__.message =
|
|
111
|
-
__webpack_error__.name =
|
|
110
|
+
__webpack_error__.message = 'Loading script failed.\n(' + errorType + ': ' + realSrc + ' or global var ' + remoteGlobal + ')';
|
|
111
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
112
112
|
__webpack_error__.type = errorType;
|
|
113
113
|
__webpack_error__.request = realSrc;
|
|
114
114
|
reject(__webpack_error__);
|
|
115
115
|
}, containerKey);
|
|
116
116
|
}).catch(function(err) {
|
|
117
|
-
console.error(
|
|
117
|
+
console.error('container is offline, returning fake remote');
|
|
118
118
|
console.error(err);
|
|
119
119
|
return {
|
|
120
120
|
fake: true,
|
|
121
121
|
// @ts-ignore
|
|
122
122
|
get: function(arg) {
|
|
123
|
-
console.warn(
|
|
123
|
+
console.warn('faking', arg, 'module on, its offline');
|
|
124
124
|
return Promise.resolve(function() {
|
|
125
125
|
return {
|
|
126
126
|
__esModule: true,
|
|
@@ -134,9 +134,9 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
134
134
|
init: function() {}
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
|
-
if (typeof window !==
|
|
137
|
+
if (typeof window !== 'undefined') {
|
|
138
138
|
//@ts-ignore
|
|
139
|
-
globalScope[
|
|
139
|
+
globalScope['remoteLoading'][containerKey] = asyncContainer;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
return asyncContainer;
|
|
@@ -144,19 +144,19 @@ var loadScript = function(keyOrRuntimeRemoteItem) {
|
|
|
144
144
|
var getRuntimeRemotes$1 = function() {
|
|
145
145
|
return Object.entries(remoteVars).reduce(function(acc, param) {
|
|
146
146
|
var _param = _sliced_to_array$3(param, 2), key = _param[0], value = _param[1];
|
|
147
|
-
if (typeof value ===
|
|
147
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
148
148
|
acc[key] = {
|
|
149
149
|
asyncContainer: value
|
|
150
150
|
};
|
|
151
|
-
} else if (typeof value ===
|
|
151
|
+
} else if (typeof value === 'function') {
|
|
152
152
|
acc[key] = {
|
|
153
153
|
asyncContainer: Promise.resolve(value())
|
|
154
154
|
};
|
|
155
|
-
} else if (typeof value ===
|
|
156
|
-
if (value.startsWith(
|
|
157
|
-
var _value_replace_split = _sliced_to_array$3(value.replace(
|
|
155
|
+
} else if (typeof value === 'string') {
|
|
156
|
+
if (value.startsWith('internal ')) {
|
|
157
|
+
var _value_replace_split = _sliced_to_array$3(value.replace('internal ', '').split('?'), 2); _value_replace_split[0]; var query = _value_replace_split[1];
|
|
158
158
|
if (query) {
|
|
159
|
-
var remoteSyntax = new URLSearchParams(query).get(
|
|
159
|
+
var remoteSyntax = new URLSearchParams(query).get('remote');
|
|
160
160
|
if (remoteSyntax) {
|
|
161
161
|
var _extractUrlAndGlobal = _sliced_to_array$3(extractUrlAndGlobal(remoteSyntax), 2), url = _extractUrlAndGlobal[0], global = _extractUrlAndGlobal[1];
|
|
162
162
|
acc[key] = {
|
|
@@ -173,7 +173,7 @@ var getRuntimeRemotes$1 = function() {
|
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
} else {
|
|
176
|
-
console.warn(
|
|
176
|
+
console.warn('remotes process', process.env['REMOTES']);
|
|
177
177
|
throw new Error('[mf] Invalid value received for runtime_remote "'.concat(key, '"'));
|
|
178
178
|
}
|
|
179
179
|
return acc;
|
|
@@ -353,9 +353,9 @@ function _ts_generator$2(thisArg, body) {
|
|
|
353
353
|
var createContainerSharingScope = function(asyncContainer) {
|
|
354
354
|
// @ts-ignore
|
|
355
355
|
return asyncContainer.then(function(container) {
|
|
356
|
-
if (!__webpack_share_scopes__[
|
|
356
|
+
if (!__webpack_share_scopes__['default']) {
|
|
357
357
|
// not always a promise, so we wrap it in a resolve
|
|
358
|
-
return Promise.resolve(__webpack_init_sharing__(
|
|
358
|
+
return Promise.resolve(__webpack_init_sharing__('default')).then(function() {
|
|
359
359
|
return container;
|
|
360
360
|
});
|
|
361
361
|
} else {
|
|
@@ -370,7 +370,7 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
370
370
|
// The problem may be in Proxy in NextFederationPlugin.js.
|
|
371
371
|
// or maybe a bug in the webpack itself - instead of returning rejected promise it just throws an error.
|
|
372
372
|
// But now everything works properly and we keep this code as is.
|
|
373
|
-
container.init(__webpack_share_scopes__[
|
|
373
|
+
container.init(__webpack_share_scopes__['default']);
|
|
374
374
|
} catch (e) {
|
|
375
375
|
// maybe container already initialized so nothing to throw
|
|
376
376
|
}
|
|
@@ -411,8 +411,8 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
411
411
|
}
|
|
412
412
|
return Object.entries(remotes).reduce(function(acc, param) {
|
|
413
413
|
var _param = _sliced_to_array$2(param, 2), key = _param[0], value = _param[1];
|
|
414
|
-
if (value.startsWith(
|
|
415
|
-
var promiseCall = value.split(
|
|
414
|
+
if (value.startsWith('promise ') || value.startsWith('external ')) {
|
|
415
|
+
var promiseCall = value.split(' ')[1];
|
|
416
416
|
acc[key] = "function() {\n return ".concat(promiseCall, "\n }");
|
|
417
417
|
} else {
|
|
418
418
|
acc[key] = JSON.stringify(value);
|
|
@@ -432,8 +432,8 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
432
432
|
if (!remoteContainer) {
|
|
433
433
|
throw Error("Remote container options is empty");
|
|
434
434
|
}
|
|
435
|
-
containerScope = typeof window !==
|
|
436
|
-
if (!(typeof remoteContainer ===
|
|
435
|
+
containerScope = typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
436
|
+
if (!(typeof remoteContainer === 'string')) return [
|
|
437
437
|
3,
|
|
438
438
|
1
|
|
439
439
|
];
|
|
@@ -516,7 +516,7 @@ var createContainerSharingScope = function(asyncContainer) {
|
|
|
516
516
|
if (exportName) {
|
|
517
517
|
return [
|
|
518
518
|
2,
|
|
519
|
-
mod && typeof mod ===
|
|
519
|
+
mod && typeof mod === 'object' ? mod[exportName] : undefined
|
|
520
520
|
];
|
|
521
521
|
} else {
|
|
522
522
|
return [
|
|
@@ -775,7 +775,7 @@ function _ts_generator$1(thisArg, body) {
|
|
|
775
775
|
/**
|
|
776
776
|
* Constant for remote entry file
|
|
777
777
|
* @constant {string}
|
|
778
|
-
*/ var REMOTE_ENTRY_FILE =
|
|
778
|
+
*/ var REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
779
779
|
/**
|
|
780
780
|
* Function to load remote
|
|
781
781
|
* @function
|
|
@@ -785,18 +785,18 @@ function _ts_generator$1(thisArg, body) {
|
|
|
785
785
|
* @returns {Promise<void>} A promise that resolves when the remote is loaded
|
|
786
786
|
*/ var loadRemote = function(url, scope, bustRemoteEntryCache) {
|
|
787
787
|
return new Promise(function(resolve, reject) {
|
|
788
|
-
var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) :
|
|
788
|
+
var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) : '';
|
|
789
789
|
var webpackRequire = __webpack_require__;
|
|
790
790
|
webpackRequire.l("".concat(url).concat(timestamp), function(event) {
|
|
791
791
|
var _event_target;
|
|
792
|
-
if ((event === null || event === void 0 ? void 0 : event.type) ===
|
|
792
|
+
if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
|
|
793
793
|
// Script loaded successfully:
|
|
794
794
|
return resolve();
|
|
795
795
|
}
|
|
796
796
|
var realSrc = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.src;
|
|
797
797
|
var error = new Error();
|
|
798
|
-
error.message =
|
|
799
|
-
error.name =
|
|
798
|
+
error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
|
|
799
|
+
error.name = 'ScriptExternalLoadError';
|
|
800
800
|
reject(error);
|
|
801
801
|
}, scope);
|
|
802
802
|
});
|
|
@@ -847,7 +847,7 @@ var loadEsmRemote = function() {
|
|
|
847
847
|
];
|
|
848
848
|
return [
|
|
849
849
|
4,
|
|
850
|
-
__webpack_init_sharing__(
|
|
850
|
+
__webpack_init_sharing__('default')
|
|
851
851
|
];
|
|
852
852
|
case 1:
|
|
853
853
|
_state.sent();
|
|
@@ -936,8 +936,8 @@ var loadEsmRemote = function() {
|
|
|
936
936
|
3,
|
|
937
937
|
6
|
|
938
938
|
];
|
|
939
|
-
remoteUrl =
|
|
940
|
-
if (!(typeof url ===
|
|
939
|
+
remoteUrl = '';
|
|
940
|
+
if (!(typeof url === 'string')) return [
|
|
941
941
|
3,
|
|
942
942
|
1
|
|
943
943
|
];
|
|
@@ -974,7 +974,7 @@ var loadEsmRemote = function() {
|
|
|
974
974
|
4,
|
|
975
975
|
Promise.all([
|
|
976
976
|
initContainer(window[remoteScope]),
|
|
977
|
-
window[remoteScope].get(module ===
|
|
977
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : "./".concat(module))
|
|
978
978
|
])
|
|
979
979
|
];
|
|
980
980
|
case 5:
|
|
@@ -989,7 +989,7 @@ var loadEsmRemote = function() {
|
|
|
989
989
|
case 6:
|
|
990
990
|
return [
|
|
991
991
|
4,
|
|
992
|
-
window[remoteScope].get(module ===
|
|
992
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : "./".concat(module))
|
|
993
993
|
];
|
|
994
994
|
case 7:
|
|
995
995
|
moduleFactory1 = _state.sent();
|
|
@@ -1115,19 +1115,19 @@ var getRuntimeRemotes = function() {
|
|
|
1115
1115
|
return Object.entries(remoteVars).reduce(function(acc, item) {
|
|
1116
1116
|
var _item = _sliced_to_array(item, 2), key = _item[0], value = _item[1];
|
|
1117
1117
|
// if its an object with a thenable (eagerly executing function)
|
|
1118
|
-
if (typeof value ===
|
|
1118
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
1119
1119
|
acc[key] = {
|
|
1120
1120
|
asyncContainer: value
|
|
1121
1121
|
};
|
|
1122
|
-
} else if (typeof value ===
|
|
1122
|
+
} else if (typeof value === 'function') {
|
|
1123
1123
|
// @ts-ignore
|
|
1124
1124
|
acc[key] = {
|
|
1125
1125
|
asyncContainer: value
|
|
1126
1126
|
};
|
|
1127
|
-
} else if (typeof value ===
|
|
1128
|
-
var _value_replace_split = _sliced_to_array(value.replace(
|
|
1127
|
+
} else if (typeof value === 'string' && value.startsWith('internal ')) {
|
|
1128
|
+
var _value_replace_split = _sliced_to_array(value.replace('internal ', '').split('?'), 2), request = _value_replace_split[0], query = _value_replace_split[1];
|
|
1129
1129
|
if (query) {
|
|
1130
|
-
var remoteSyntax = new URLSearchParams(query).get(
|
|
1130
|
+
var remoteSyntax = new URLSearchParams(query).get('remote');
|
|
1131
1131
|
if (remoteSyntax) {
|
|
1132
1132
|
var _extractUrlAndGlobal = _sliced_to_array(extractUrlAndGlobal(remoteSyntax), 2), url = _extractUrlAndGlobal[0], global = _extractUrlAndGlobal[1];
|
|
1133
1133
|
acc[key] = {
|
|
@@ -1136,7 +1136,7 @@ var getRuntimeRemotes = function() {
|
|
|
1136
1136
|
};
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
} else if (typeof value ===
|
|
1139
|
+
} else if (typeof value === 'string') {
|
|
1140
1140
|
var _extractUrlAndGlobal1 = _sliced_to_array(extractUrlAndGlobal(value), 2), url1 = _extractUrlAndGlobal1[0], global1 = _extractUrlAndGlobal1[1];
|
|
1141
1141
|
acc[key] = {
|
|
1142
1142
|
global: global1,
|
|
@@ -1144,13 +1144,13 @@ var getRuntimeRemotes = function() {
|
|
|
1144
1144
|
};
|
|
1145
1145
|
} else {
|
|
1146
1146
|
//@ts-ignore
|
|
1147
|
-
console.warn(
|
|
1147
|
+
console.warn('remotes process', process.env.REMOTES);
|
|
1148
1148
|
throw new Error('[mf] Invalid value received for runtime_remote "'.concat(key, '"'));
|
|
1149
1149
|
}
|
|
1150
1150
|
return acc;
|
|
1151
1151
|
}, {});
|
|
1152
1152
|
} catch (err) {
|
|
1153
|
-
console.warn(
|
|
1153
|
+
console.warn('Unable to retrieve runtime remotes: ', err);
|
|
1154
1154
|
}
|
|
1155
1155
|
return {};
|
|
1156
1156
|
};
|
|
@@ -1290,8 +1290,8 @@ var importDelegatedModule = function() {
|
|
|
1290
1290
|
}).then(function(asyncContainer) {
|
|
1291
1291
|
// most of this is only needed because of legacy promise based implementation
|
|
1292
1292
|
// can remove proxies once we remove promise based implementations
|
|
1293
|
-
if (typeof window ===
|
|
1294
|
-
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem,
|
|
1293
|
+
if (typeof window === 'undefined') {
|
|
1294
|
+
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, 'globalThis')) {
|
|
1295
1295
|
return asyncContainer;
|
|
1296
1296
|
}
|
|
1297
1297
|
// return asyncContainer;
|
|
@@ -1301,7 +1301,7 @@ var importDelegatedModule = function() {
|
|
|
1301
1301
|
//@ts-ignore
|
|
1302
1302
|
return asyncContainer.get(arg).then(function(f) {
|
|
1303
1303
|
var _loop = function(prop) {
|
|
1304
|
-
if (typeof m[prop] ===
|
|
1304
|
+
if (typeof m[prop] === 'function') {
|
|
1305
1305
|
Object.defineProperty(result, prop, {
|
|
1306
1306
|
get: function get() {
|
|
1307
1307
|
return function() {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/utilities",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"types": "./dist/index.cjs.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"react": "18.2.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@module-federation/sdk": "0.1.
|
|
20
|
+
"@module-federation/sdk": "0.1.13"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"webpack": "^5.40.0",
|