@module-federation/utilities 1.7.0 → 1.7.1
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 +93 -0
- package/package.json +4 -1
- package/src/Logger.js +8 -10
- package/src/Logger.js.map +1 -1
- package/src/components/ErrorBoundary.js +13 -16
- package/src/components/ErrorBoundary.js.map +1 -1
- package/src/components/FederationBoundary.js +13 -15
- package/src/components/FederationBoundary.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -1
- package/src/index.js.map +1 -1
- package/src/plugins/DelegateModulesPlugin.d.ts +26 -0
- package/src/plugins/DelegateModulesPlugin.js +88 -0
- package/src/plugins/DelegateModulesPlugin.js.map +1 -0
- package/src/types/index.d.ts +3 -0
- package/src/utils/common.d.ts +4 -1
- package/src/utils/common.js +191 -188
- package/src/utils/common.js.map +1 -1
- package/src/utils/correctImportPath.js +7 -7
- package/src/utils/correctImportPath.js.map +1 -1
- package/src/utils/getRuntimeRemotes.d.ts +2 -0
- package/src/utils/getRuntimeRemotes.js +50 -0
- package/src/utils/getRuntimeRemotes.js.map +1 -0
- package/src/utils/importRemote.js +66 -101
- package/src/utils/importRemote.js.map +1 -1
- package/src/utils/isEmpty.js +2 -2
- package/src/utils/isEmpty.js.map +1 -1
|
@@ -1,113 +1,78 @@
|
|
|
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
|
-
|
|
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*/];
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
6
|
+
const loadRemote = (url, scope, bustRemoteEntryCache) => new Promise((resolve, reject) => {
|
|
7
|
+
const timestamp = bustRemoteEntryCache ? `?t=${new Date().getTime()}` : '';
|
|
8
|
+
const webpackRequire = __webpack_require__;
|
|
9
|
+
webpackRequire.l(`${url}${timestamp}`, (event) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
|
|
12
|
+
// Script loaded successfully:
|
|
13
|
+
return resolve();
|
|
36
14
|
}
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
const realSrc = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.src;
|
|
16
|
+
const error = new Error();
|
|
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
|
+
});
|
|
39
28
|
// __initialized and __initializing flags prevent some concurrent re-initialization corner cases
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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*/];
|
|
29
|
+
const initContainer = (containerScope) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
try {
|
|
31
|
+
const webpackShareScopes = __webpack_share_scopes__;
|
|
32
|
+
if (!containerScope.__initialized && !containerScope.__initializing) {
|
|
33
|
+
containerScope.__initializing = true;
|
|
34
|
+
yield containerScope.init(webpackShareScopes.default);
|
|
35
|
+
containerScope.__initialized = true;
|
|
36
|
+
delete containerScope.__initializing;
|
|
61
37
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
console.error(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
64
43
|
/*
|
|
65
44
|
Dynamically import a remote module using Webpack's loading mechanism:
|
|
66
45
|
https://webpack.js.org/concepts/module-federation/
|
|
67
46
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
};
|
|
47
|
+
const importRemote = ({ url, scope, module, remoteEntryFileName = REMOTE_ENTRY_FILE, bustRemoteEntryCache = true, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
const remoteScope = scope;
|
|
49
|
+
if (!window[remoteScope]) {
|
|
50
|
+
let remoteUrl = '';
|
|
51
|
+
if (typeof url === 'string') {
|
|
52
|
+
remoteUrl = url;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
remoteUrl = yield url();
|
|
56
|
+
}
|
|
57
|
+
// Load the remote and initialize the share scope if it's empty
|
|
58
|
+
yield Promise.all([
|
|
59
|
+
loadRemote(`${remoteUrl}/${remoteEntryFileName}`, scope, bustRemoteEntryCache),
|
|
60
|
+
initSharing(),
|
|
61
|
+
]);
|
|
62
|
+
if (!window[remoteScope]) {
|
|
63
|
+
throw new Error(`Remote loaded successfully but ${scope} could not be found! Verify that the name is correct in the Webpack configuration!`);
|
|
64
|
+
}
|
|
65
|
+
// Initialize the container to get shared modules and get the module factory:
|
|
66
|
+
const [, moduleFactory] = yield Promise.all([
|
|
67
|
+
initContainer(window[remoteScope]),
|
|
68
|
+
window[remoteScope].get(module.startsWith('./') ? module : `./${module}`),
|
|
69
|
+
]);
|
|
70
|
+
return moduleFactory();
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const moduleFactory = yield window[remoteScope].get(module.startsWith('./') ? module : `./${module}`);
|
|
74
|
+
return moduleFactory();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
112
77
|
exports.importRemote = importRemote;
|
|
113
78
|
//# 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,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAE3C,MAAM,UAAU,GAAG,CACjB,GAA+B,EAC/B,KAAmC,EACnC,oBAAiE,EACjE,EAAE,CACF,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IACpC,MAAM,SAAS,GAAG,oBAAoB,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,MAAM,cAAc,GAAG,mBAAgD,CAAC;IACxE,cAAc,CAAC,CAAC,CACd,GAAG,GAAG,GAAG,SAAS,EAAE,EACpB,CAAC,KAAK,EAAE,EAAE;;QACR,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,MAAM,EAAE;YAC1B,8BA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+1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isObjectEmpty = void 0;
|
|
4
|
-
|
|
5
|
-
for (
|
|
4
|
+
const isObjectEmpty = (obj) => {
|
|
5
|
+
for (const 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,MAAM,aAAa,GAAG,CAAmB,GAAM,EAAE,EAAE;IACxD,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,aAAa,iBAKxB"}
|