@module-federation/utilities 1.7.6 → 1.8.0
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/CHANGELOG.md +2 -193
- package/package.json +1 -1
- package/src/Logger.js +10 -8
- package/src/Logger.js.map +1 -1
- package/src/components/ErrorBoundary.js +16 -13
- package/src/components/ErrorBoundary.js.map +1 -1
- package/src/components/FederationBoundary.js +15 -13
- package/src/components/FederationBoundary.js.map +1 -1
- package/src/index.d.ts +0 -1
- package/src/index.js +1 -4
- package/src/index.js.map +1 -1
- package/src/types/index.d.ts +1 -3
- package/src/utils/common.d.ts +1 -4
- package/src/utils/common.js +190 -192
- package/src/utils/common.js.map +1 -1
- package/src/utils/correctImportPath.js +5 -5
- package/src/utils/correctImportPath.js.map +1 -1
- package/src/utils/importRemote.js +101 -66
- package/src/utils/importRemote.js.map +1 -1
- package/src/utils/isEmpty.js +2 -2
- package/src/utils/isEmpty.js.map +1 -1
- package/src/plugins/DelegateModulesPlugin.d.ts +0 -26
- package/src/plugins/DelegateModulesPlugin.js +0 -88
- package/src/plugins/DelegateModulesPlugin.js.map +0 -1
- package/src/utils/getRuntimeRemotes.d.ts +0 -2
- package/src/utils/getRuntimeRemotes.js +0 -50
- package/src/utils/getRuntimeRemotes.js.map +0 -1
- package/src/utils/importDelegatedModule.d.ts +0 -2
- package/src/utils/importDelegatedModule.js +0 -77
- package/src/utils/importDelegatedModule.js.map +0 -1
|
@@ -1,78 +1,113 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.importRemote = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
6
|
+
var loadRemote = function (url, scope, bustRemoteEntryCache) {
|
|
7
|
+
return new Promise(function (resolve, reject) {
|
|
8
|
+
var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) : '';
|
|
9
|
+
var webpackRequire = __webpack_require__;
|
|
10
|
+
webpackRequire.l("".concat(url).concat(timestamp), function (event) {
|
|
11
|
+
var _a;
|
|
12
|
+
if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
|
|
13
|
+
// Script loaded successfully:
|
|
14
|
+
return resolve();
|
|
15
|
+
}
|
|
16
|
+
var realSrc = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.src;
|
|
17
|
+
var error = new Error();
|
|
18
|
+
error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
|
|
19
|
+
error.name = 'ScriptExternalLoadError';
|
|
20
|
+
reject(error);
|
|
21
|
+
}, scope);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var initSharing = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
25
|
+
var webpackShareScopes;
|
|
26
|
+
return tslib_1.__generator(this, function (_a) {
|
|
27
|
+
switch (_a.label) {
|
|
28
|
+
case 0:
|
|
29
|
+
webpackShareScopes = __webpack_share_scopes__;
|
|
30
|
+
if (!!(webpackShareScopes === null || webpackShareScopes === void 0 ? void 0 : webpackShareScopes.default)) return [3 /*break*/, 2];
|
|
31
|
+
return [4 /*yield*/, __webpack_init_sharing__('default')];
|
|
32
|
+
case 1:
|
|
33
|
+
_a.sent();
|
|
34
|
+
_a.label = 2;
|
|
35
|
+
case 2: return [2 /*return*/];
|
|
14
36
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
|
|
18
|
-
error.name = 'ScriptExternalLoadError';
|
|
19
|
-
reject(error);
|
|
20
|
-
}, scope);
|
|
21
|
-
});
|
|
22
|
-
const initSharing = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const webpackShareScopes = __webpack_share_scopes__;
|
|
24
|
-
if (!(webpackShareScopes === null || webpackShareScopes === void 0 ? void 0 : webpackShareScopes.default)) {
|
|
25
|
-
yield __webpack_init_sharing__('default');
|
|
26
|
-
}
|
|
27
|
-
});
|
|
37
|
+
});
|
|
38
|
+
}); };
|
|
28
39
|
// __initialized and __initializing flags prevent some concurrent re-initialization corner cases
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
var initContainer = function (containerScope) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var webpackShareScopes, error_1;
|
|
42
|
+
return tslib_1.__generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
_a.trys.push([0, 3, , 4]);
|
|
46
|
+
webpackShareScopes = __webpack_share_scopes__;
|
|
47
|
+
if (!(!containerScope.__initialized && !containerScope.__initializing)) return [3 /*break*/, 2];
|
|
48
|
+
containerScope.__initializing = true;
|
|
49
|
+
return [4 /*yield*/, containerScope.init(webpackShareScopes.default)];
|
|
50
|
+
case 1:
|
|
51
|
+
_a.sent();
|
|
52
|
+
containerScope.__initialized = true;
|
|
53
|
+
delete containerScope.__initializing;
|
|
54
|
+
_a.label = 2;
|
|
55
|
+
case 2: return [3 /*break*/, 4];
|
|
56
|
+
case 3:
|
|
57
|
+
error_1 = _a.sent();
|
|
58
|
+
console.error(error_1);
|
|
59
|
+
return [3 /*break*/, 4];
|
|
60
|
+
case 4: return [2 /*return*/];
|
|
37
61
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.error(error);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
62
|
+
});
|
|
63
|
+
}); };
|
|
43
64
|
/*
|
|
44
65
|
Dynamically import a remote module using Webpack's loading mechanism:
|
|
45
66
|
https://webpack.js.org/concepts/module-federation/
|
|
46
67
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
var importRemote = function (_a) {
|
|
69
|
+
var url = _a.url, scope = _a.scope, module = _a.module, _b = _a.remoteEntryFileName, remoteEntryFileName = _b === void 0 ? REMOTE_ENTRY_FILE : _b, _c = _a.bustRemoteEntryCache, bustRemoteEntryCache = _c === void 0 ? true : _c;
|
|
70
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var remoteScope, remoteUrl, _d, moduleFactory, moduleFactory;
|
|
72
|
+
return tslib_1.__generator(this, function (_e) {
|
|
73
|
+
switch (_e.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
remoteScope = scope;
|
|
76
|
+
if (!!window[remoteScope]) return [3 /*break*/, 6];
|
|
77
|
+
remoteUrl = '';
|
|
78
|
+
if (!(typeof url === 'string')) return [3 /*break*/, 1];
|
|
79
|
+
remoteUrl = url;
|
|
80
|
+
return [3 /*break*/, 3];
|
|
81
|
+
case 1: return [4 /*yield*/, url()];
|
|
82
|
+
case 2:
|
|
83
|
+
remoteUrl = _e.sent();
|
|
84
|
+
_e.label = 3;
|
|
85
|
+
case 3:
|
|
86
|
+
// Load the remote and initialize the share scope if it's empty
|
|
87
|
+
return [4 /*yield*/, Promise.all([
|
|
88
|
+
loadRemote("".concat(remoteUrl, "/").concat(remoteEntryFileName), scope, bustRemoteEntryCache),
|
|
89
|
+
initSharing(),
|
|
90
|
+
])];
|
|
91
|
+
case 4:
|
|
92
|
+
// Load the remote and initialize the share scope if it's empty
|
|
93
|
+
_e.sent();
|
|
94
|
+
if (!window[remoteScope]) {
|
|
95
|
+
throw new Error("Remote loaded successfully but ".concat(scope, " could not be found! Verify that the name is correct in the Webpack configuration!"));
|
|
96
|
+
}
|
|
97
|
+
return [4 /*yield*/, Promise.all([
|
|
98
|
+
initContainer(window[remoteScope]),
|
|
99
|
+
window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module)),
|
|
100
|
+
])];
|
|
101
|
+
case 5:
|
|
102
|
+
_d = _e.sent(), moduleFactory = _d[1];
|
|
103
|
+
return [2 /*return*/, moduleFactory()];
|
|
104
|
+
case 6: return [4 /*yield*/, window[remoteScope].get(module.startsWith('./') ? module : "./".concat(module))];
|
|
105
|
+
case 7:
|
|
106
|
+
moduleFactory = _e.sent();
|
|
107
|
+
return [2 /*return*/, moduleFactory()];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
};
|
|
77
112
|
exports.importRemote = importRemote;
|
|
78
113
|
//# sourceMappingURL=importRemote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":";;;;AAgBA,
|
|
1
|
+
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":";;;;AAgBA,IAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C,IAAM,UAAU,GAAG,UACjB,GAA+B,EAC/B,KAAmC,EACnC,oBAAiE;IAEjE,OAAA,IAAI,OAAO,CAAO,UAAC,OAAO,EAAE,MAAM;QAChC,IAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,aAAM,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,IAAM,cAAc,GAAG,mBAAgD,C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B,MAAM,CAAC,WAAW,CACnB,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAK,MAAM,CAAE,CAAC,EAAA;;oBAFjD,aAAa,GAAG,SAEiC;oBACvD,sBAAO,aAAa,EAAE,EAAC;;;;CAE1B,CAAC;AA7CW,QAAA,YAAY,gBA6CvB"}
|
package/src/utils/isEmpty.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isObjectEmpty = void 0;
|
|
4
|
-
|
|
5
|
-
for (
|
|
4
|
+
var isObjectEmpty = function (obj) {
|
|
5
|
+
for (var x in obj) {
|
|
6
6
|
return false;
|
|
7
7
|
}
|
|
8
8
|
return true;
|
package/src/utils/isEmpty.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEmpty.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/isEmpty.ts"],"names":[],"mappings":";;;AAAO,
|
|
1
|
+
{"version":3,"file":"isEmpty.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/isEmpty.ts"],"names":[],"mappings":";;;AAAO,IAAM,aAAa,GAAG,UAAmB,GAAM;IACpD,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Compiler, Compilation, Chunk, Module } from 'webpack';
|
|
2
|
-
/**
|
|
3
|
-
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
4
|
-
* @class DelegateModulesPlugin
|
|
5
|
-
*/
|
|
6
|
-
declare class DelegateModulesPlugin {
|
|
7
|
-
options: {
|
|
8
|
-
debug: boolean;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
_delegateModules: Set<Module>;
|
|
12
|
-
constructor(options: {
|
|
13
|
-
debug?: boolean;
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
});
|
|
16
|
-
getChunkByName(chunks: Iterable<Chunk>, name: string): Chunk | undefined;
|
|
17
|
-
addDelegatesToChunks(compilation: Compilation, chunks: Chunk[]): void;
|
|
18
|
-
removeDelegatesNonRuntimeChunks(compilation: Compilation, chunks: Iterable<Chunk>): void;
|
|
19
|
-
/**
|
|
20
|
-
* Applies the plugin to the webpack compiler.
|
|
21
|
-
* @param {Compiler} compiler - The webpack compiler instance.
|
|
22
|
-
*/
|
|
23
|
-
apply(compiler: Compiler): void;
|
|
24
|
-
resolveDelegateModules(compilation: Compilation): void;
|
|
25
|
-
}
|
|
26
|
-
export default DelegateModulesPlugin;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* A webpack plugin that moves specified modules from chunks to runtime chunk.
|
|
5
|
-
* @class DelegateModulesPlugin
|
|
6
|
-
*/
|
|
7
|
-
class DelegateModulesPlugin {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.options = Object.assign({ debug: false }, options);
|
|
10
|
-
this._delegateModules = new Set();
|
|
11
|
-
}
|
|
12
|
-
getChunkByName(chunks, name) {
|
|
13
|
-
for (const chunk of chunks) {
|
|
14
|
-
if (chunk.name == name) {
|
|
15
|
-
return chunk;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
addDelegatesToChunks(compilation, chunks) {
|
|
21
|
-
for (const chunk of chunks) {
|
|
22
|
-
this._delegateModules.forEach((module) => {
|
|
23
|
-
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
|
|
24
|
-
this.options.debug &&
|
|
25
|
-
console.log('adding ', module.identifier(), ' to chunk', chunk.name);
|
|
26
|
-
compilation.chunkGraph.connectChunkAndModule(chunk, module);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
removeDelegatesNonRuntimeChunks(compilation, chunks) {
|
|
32
|
-
for (const chunk of chunks) {
|
|
33
|
-
if (!chunk.hasRuntime()) {
|
|
34
|
-
this.options.debug &&
|
|
35
|
-
console.log('non-runtime chunk:', chunk.debugId, chunk.id, chunk.name);
|
|
36
|
-
this._delegateModules.forEach((module) => {
|
|
37
|
-
compilation.chunkGraph.disconnectChunkAndModule(chunk, module);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Applies the plugin to the webpack compiler.
|
|
44
|
-
* @param {Compiler} compiler - The webpack compiler instance.
|
|
45
|
-
*/
|
|
46
|
-
apply(compiler) {
|
|
47
|
-
// Tap into compilation hooks
|
|
48
|
-
compiler.hooks.compilation.tap('DelegateModulesPlugin', (compilation) => {
|
|
49
|
-
// fills this._delegateModules set
|
|
50
|
-
this.resolveDelegateModules(compilation);
|
|
51
|
-
compilation.hooks.optimizeChunks.tap('DelegateModulesPlugin', (chunks) => {
|
|
52
|
-
// Change this line
|
|
53
|
-
const { runtime, container } = this.options;
|
|
54
|
-
const runtimeChunk = this.getChunkByName(chunks, runtime);
|
|
55
|
-
if (!runtimeChunk || !runtimeChunk.hasRuntime())
|
|
56
|
-
return;
|
|
57
|
-
// Get the container chunk if specified
|
|
58
|
-
const remoteContainer = container
|
|
59
|
-
? this.getChunkByName(chunks, container)
|
|
60
|
-
: null;
|
|
61
|
-
this.options.debug &&
|
|
62
|
-
console.log(remoteContainer === null || remoteContainer === void 0 ? void 0 : remoteContainer.name, runtimeChunk.name, this._delegateModules.size);
|
|
63
|
-
this.addDelegatesToChunks(compilation, [remoteContainer, runtimeChunk].filter(Boolean));
|
|
64
|
-
this.removeDelegatesNonRuntimeChunks(compilation, chunks);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
resolveDelegateModules(compilation) {
|
|
69
|
-
// Tap into the 'finish-modules' hook to access the module list after they are all processed
|
|
70
|
-
compilation.hooks.finishModules.tapAsync('ModuleIDFinderPlugin', (modules, callback) => {
|
|
71
|
-
const { remotes } = this.options;
|
|
72
|
-
// Get the delegate module names for remote chunks if specified
|
|
73
|
-
const knownDelegates = new Set(remotes
|
|
74
|
-
? Object.values(remotes).map((remote) => remote.replace('internal ', ''))
|
|
75
|
-
: []);
|
|
76
|
-
for (const module of modules) {
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
if (module.resource && knownDelegates.has(module.resource)) {
|
|
79
|
-
this._delegateModules.add(module);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Continue the process
|
|
83
|
-
callback();
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
exports.default = DelegateModulesPlugin;
|
|
88
|
-
//# sourceMappingURL=DelegateModulesPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DelegateModulesPlugin.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/plugins/DelegateModulesPlugin.ts"],"names":[],"mappings":";;AAQA;;;GAGG;AACH,MAAM,qBAAqB;IAIzB,YAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,mBAAK,KAAK,EAAE,KAAK,IAAK,OAAO,CAAE,CAAC;QAC5C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAED,cAAc,CAAC,MAAuB,EAAE,IAAY;QAClD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,oBAAoB,CAAC,WAAwB,EAAE,MAAe;QAC5D,KAAK,MAAM,KAAK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,EAAE,EAAE,CAAC,CAChC;gBACH,CAAC,CAAC,EAAE,CACP,CAAC;YAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,aAAa;gBACb,IAAI,MAAM,CAAC,QAAQ,IAAI,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;oBAC1D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACnC;aACF;YACD,uBAAuB;YACvB,QAAQ,EAAE,CAAC;QACb,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AACD,kBAAe,qBAAqB,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRuntimeRemotes = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
5
|
-
const getRuntimeRemotes = () => {
|
|
6
|
-
try {
|
|
7
|
-
const runtimeRemotes = Object.entries(common_1.remoteVars).reduce(function (acc, item) {
|
|
8
|
-
const [key, value] = item;
|
|
9
|
-
// if its an object with a thenable (eagerly executing function)
|
|
10
|
-
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
11
|
-
acc[key] = { asyncContainer: value };
|
|
12
|
-
}
|
|
13
|
-
// if its a function that must be called (lazily executing function)
|
|
14
|
-
else if (typeof value === 'function') {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
acc[key] = { asyncContainer: value };
|
|
17
|
-
}
|
|
18
|
-
// if its a delegate module, skip it
|
|
19
|
-
else if (typeof value === 'string' && value.startsWith('internal ')) {
|
|
20
|
-
const [request, query] = value.replace('internal ', '').split('?');
|
|
21
|
-
if (query) {
|
|
22
|
-
const remoteSyntax = new URLSearchParams(query).get('remote');
|
|
23
|
-
if (remoteSyntax) {
|
|
24
|
-
const [url, global] = (0, common_1.extractUrlAndGlobal)(remoteSyntax);
|
|
25
|
-
acc[key] = { global, url };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// if its just a string (global@url)
|
|
30
|
-
else if (typeof value === 'string') {
|
|
31
|
-
const [url, global] = (0, common_1.extractUrlAndGlobal)(value);
|
|
32
|
-
acc[key] = { global, url };
|
|
33
|
-
}
|
|
34
|
-
// we dont know or currently support this type
|
|
35
|
-
else {
|
|
36
|
-
//@ts-ignore
|
|
37
|
-
console.log('remotes process', process.env.REMOTES);
|
|
38
|
-
throw new Error(`[mf] Invalid value received for runtime_remote "${key}"`);
|
|
39
|
-
}
|
|
40
|
-
return acc;
|
|
41
|
-
}, {});
|
|
42
|
-
return runtimeRemotes;
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
console.warn('Unable to retrieve runtime remotes: ', err);
|
|
46
|
-
}
|
|
47
|
-
return {};
|
|
48
|
-
};
|
|
49
|
-
exports.getRuntimeRemotes = getRuntimeRemotes;
|
|
50
|
-
//# sourceMappingURL=getRuntimeRemotes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRuntimeRemotes.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/getRuntimeRemotes.ts"],"names":[],"mappings":";;;AACA,qCAA2D;AAEpD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,IAAI;QACF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAU,CAAC,CAAC,MAAM,CAAC,UACvD,GAAG,EACH,IAAI;YAEJ,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAC1B,gEAAgE;YAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;gBACjE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;aACtC;YACD,oEAAoE;iBAC/D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBACpC,aAAa;gBACb,GAAG,CAAC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AuB,CAAC;AACjC,CAAC,CAAC;AAlDW,QAAA,iBAAiB,qBAkD5B"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.importDelegatedModule = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("./common");
|
|
6
|
-
const importDelegatedModule = (keyOrRuntimeRemoteItem) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
return (0, common_1.loadScript)(keyOrRuntimeRemoteItem)
|
|
9
|
-
.then((asyncContainer) => {
|
|
10
|
-
return asyncContainer;
|
|
11
|
-
})
|
|
12
|
-
.then((asyncContainer) => {
|
|
13
|
-
// most of this is only needed because of legacy promise based implementation
|
|
14
|
-
// can remove proxies once we remove promise based implementations
|
|
15
|
-
if (typeof window === 'undefined') {
|
|
16
|
-
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, 'global')) {
|
|
17
|
-
return asyncContainer;
|
|
18
|
-
}
|
|
19
|
-
// return asyncContainer;
|
|
20
|
-
//TODO: need to solve chunk flushing with delegated modules
|
|
21
|
-
return {
|
|
22
|
-
get: function (arg) {
|
|
23
|
-
//@ts-ignore
|
|
24
|
-
return asyncContainer.get(arg).then((f) => {
|
|
25
|
-
const m = f();
|
|
26
|
-
const result = {
|
|
27
|
-
__esModule: m.__esModule,
|
|
28
|
-
};
|
|
29
|
-
for (const prop in m) {
|
|
30
|
-
if (typeof m[prop] === 'function') {
|
|
31
|
-
Object.defineProperty(result, prop, {
|
|
32
|
-
get: function () {
|
|
33
|
-
return function () {
|
|
34
|
-
//@ts-ignore
|
|
35
|
-
if (global.usedChunks)
|
|
36
|
-
//@ts-ignore
|
|
37
|
-
global.usedChunks.add(
|
|
38
|
-
//@ts-ignore
|
|
39
|
-
`${keyOrRuntimeRemoteItem.global}->${arg}`);
|
|
40
|
-
// eslint-disable-next-line prefer-rest-params
|
|
41
|
-
return m[prop](arguments);
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
enumerable: true,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
Object.defineProperty(result, prop, {
|
|
49
|
-
get: () => {
|
|
50
|
-
//@ts-ignore
|
|
51
|
-
if (global.usedChunks)
|
|
52
|
-
//@ts-ignore
|
|
53
|
-
global.usedChunks.add(
|
|
54
|
-
//@ts-ignore
|
|
55
|
-
`${keyOrRuntimeRemoteItem.global}->${arg}`);
|
|
56
|
-
return m[prop];
|
|
57
|
-
},
|
|
58
|
-
enumerable: true,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (m.then) {
|
|
63
|
-
return Promise.resolve(() => result);
|
|
64
|
-
}
|
|
65
|
-
return () => result;
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
init: asyncContainer.init,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return asyncContainer;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
exports.importDelegatedModule = importDelegatedModule;
|
|
77
|
-
//# sourceMappingURL=importDelegatedModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importDelegatedModule.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importDelegatedModule.ts"],"names":[],"mappings":";;;;AACA,qCAAsC;AAE/B,MAAM,qBAAqB,GAAG,CACnC,sBAA8C,EAC9C,EAAE;IACF,aAAa;IACb,OAAO,IAAA,mBAAU,EAAC,sBAAsB,CAAC;SACtC,IAAI,CAAC,CAAC,cAAsC,EAAE,EAAE;QAC/C,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,cAAsC,EAAE,EAAE;QAC/C,6EAA6E;QAC7E,kEAAkE;QAClE,IAAI,OAAO,MAAM,KAAK,WAAW,EA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