@module-federation/utilities 3.1.83 → 3.1.84
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/cjs/Logger.js +60 -0
- package/dist/cjs/components/ErrorBoundary.js +96 -0
- package/dist/cjs/components/FederationBoundary.js +101 -0
- package/dist/cjs/index.js +170 -0
- package/dist/cjs/plugins/DelegateModulesPlugin.js +130 -0
- package/dist/cjs/types/index.js +33 -0
- package/dist/cjs/utils/common.js +173 -0
- package/dist/cjs/utils/getRuntimeRemotes.js +102 -0
- package/dist/cjs/utils/getRuntimeRemotes.test.js +98 -0
- package/dist/cjs/utils/importDelegateModule.test.js +101 -0
- package/dist/cjs/utils/importDelegatedModule.js +124 -0
- package/dist/cjs/utils/importRemote.js +174 -0
- package/dist/cjs/utils/isEmpty.js +56 -0
- package/dist/cjs/utils/pure.js +212 -0
- package/dist/cjs/utils/react.js +71 -0
- package/dist/esm/Logger.mjs +14 -0
- package/dist/esm/components/ErrorBoundary.mjs +33 -0
- package/dist/esm/components/FederationBoundary.mjs +38 -0
- package/dist/esm/index.mjs +34 -0
- package/dist/esm/plugins/DelegateModulesPlugin.mjs +84 -0
- package/dist/esm/types/index.mjs +6 -0
- package/dist/esm/utils/common.mjs +126 -0
- package/dist/esm/utils/getRuntimeRemotes.mjs +52 -0
- package/dist/esm/utils/getRuntimeRemotes.test.mjs +87 -0
- package/dist/esm/utils/importDelegateModule.test.mjs +90 -0
- package/dist/esm/utils/importDelegatedModule.mjs +74 -0
- package/dist/esm/utils/importRemote.mjs +137 -0
- package/dist/esm/utils/isEmpty.mjs +10 -0
- package/dist/esm/utils/pure.mjs +164 -0
- package/dist/esm/utils/react.mjs +8 -0
- package/package.json +2 -2
- package/dist/index.cjs.js +0 -555
- package/dist/index.d.ts +0 -1
- package/dist/index.esm.js +0 -543
- /package/dist/{src → types}/Logger.d.ts +0 -0
- /package/dist/{src → types}/components/ErrorBoundary.d.ts +0 -0
- /package/dist/{src → types}/components/FederationBoundary.d.ts +0 -0
- /package/dist/{src → types}/index.d.ts +0 -0
- /package/dist/{src → types}/plugins/DelegateModulesPlugin.d.ts +0 -0
- /package/dist/{src → types}/types/index.d.ts +0 -0
- /package/dist/{src → types}/utils/common.d.ts +0 -0
- /package/dist/{src → types}/utils/getRuntimeRemotes.d.ts +0 -0
- /package/dist/{src → types}/utils/importDelegatedModule.d.ts +0 -0
- /package/dist/{src → types}/utils/importRemote.d.ts +0 -0
- /package/dist/{src → types}/utils/isEmpty.d.ts +0 -0
- /package/dist/{src → types}/utils/pure.d.ts +0 -0
- /package/dist/{src → types}/utils/react.d.ts +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
var __webpack_modules__ = ({});
|
|
10
|
+
/************************************************************************/
|
|
11
|
+
// The module cache
|
|
12
|
+
var __webpack_module_cache__ = {};
|
|
13
|
+
|
|
14
|
+
// The require function
|
|
15
|
+
function __webpack_require__(moduleId) {
|
|
16
|
+
|
|
17
|
+
// Check if module is in cache
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (cachedModule !== undefined) {
|
|
20
|
+
return cachedModule.exports;
|
|
21
|
+
}
|
|
22
|
+
// Create a new module (and put it into the cache)
|
|
23
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
24
|
+
exports: {}
|
|
25
|
+
});
|
|
26
|
+
// Execute the module function
|
|
27
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
28
|
+
|
|
29
|
+
// Return the exports of the module
|
|
30
|
+
return module.exports;
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/************************************************************************/
|
|
35
|
+
// webpack/runtime/define_property_getters
|
|
36
|
+
(() => {
|
|
37
|
+
__webpack_require__.d = (exports, definition) => {
|
|
38
|
+
for(var key in definition) {
|
|
39
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
40
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
// webpack/runtime/has_own_property
|
|
46
|
+
(() => {
|
|
47
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
48
|
+
})();
|
|
49
|
+
// webpack/runtime/make_namespace_object
|
|
50
|
+
(() => {
|
|
51
|
+
// define __esModule on exports
|
|
52
|
+
__webpack_require__.r = (exports) => {
|
|
53
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
54
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
/************************************************************************/
|
|
60
|
+
var __webpack_exports__ = {};
|
|
61
|
+
__webpack_require__.r(__webpack_exports__);
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
63
|
+
importRemote: () => (importRemote)
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Constant for remote entry file
|
|
67
|
+
* @constant {string}
|
|
68
|
+
*/ const REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
69
|
+
/**
|
|
70
|
+
* Function to load remote
|
|
71
|
+
* @function
|
|
72
|
+
* @param {ImportRemoteOptions['url']} url - The url of the remote module
|
|
73
|
+
* @param {ImportRemoteOptions['scope']} scope - The scope of the remote module
|
|
74
|
+
* @param {ImportRemoteOptions['bustRemoteEntryCache']} bustRemoteEntryCache - Flag to bust the remote entry cache
|
|
75
|
+
* @returns {Promise<void>} A promise that resolves when the remote is loaded
|
|
76
|
+
*/ const loadRemote = (url, scope, bustRemoteEntryCache)=>new Promise((resolve, reject)=>{
|
|
77
|
+
const timestamp = bustRemoteEntryCache ? `?t=${new Date().getTime()}` : '';
|
|
78
|
+
const webpackRequire = __webpack_require__;
|
|
79
|
+
webpackRequire.l(`${url}${timestamp}`, (event)=>{
|
|
80
|
+
var _event_target;
|
|
81
|
+
if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
|
|
82
|
+
// Script loaded successfully:
|
|
83
|
+
return resolve();
|
|
84
|
+
}
|
|
85
|
+
const realSrc = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.src;
|
|
86
|
+
const error = new Error();
|
|
87
|
+
error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
|
|
88
|
+
error.name = 'ScriptExternalLoadError';
|
|
89
|
+
reject(error);
|
|
90
|
+
}, scope);
|
|
91
|
+
});
|
|
92
|
+
const loadEsmRemote = async (url, scope)=>{
|
|
93
|
+
const module = await import(/* webpackIgnore: true */ url);
|
|
94
|
+
if (!module) {
|
|
95
|
+
throw new Error(`Unable to load requested remote from ${url} with scope ${scope}`);
|
|
96
|
+
}
|
|
97
|
+
window[scope] = {
|
|
98
|
+
...module,
|
|
99
|
+
__initializing: false,
|
|
100
|
+
__initialized: false
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Function to initialize sharing
|
|
105
|
+
* @async
|
|
106
|
+
* @function
|
|
107
|
+
*/ const initSharing = async ()=>{
|
|
108
|
+
const webpackShareScopes = __webpack_require__.S;
|
|
109
|
+
if (!(webpackShareScopes === null || webpackShareScopes === void 0 ? void 0 : webpackShareScopes.default)) {
|
|
110
|
+
await __webpack_require__.I('default');
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Function to initialize container
|
|
115
|
+
* @async
|
|
116
|
+
* @function
|
|
117
|
+
* @param {WebpackRemoteContainer} containerScope - The container scope
|
|
118
|
+
*/ const initContainer = async (containerScope)=>{
|
|
119
|
+
try {
|
|
120
|
+
const webpackShareScopes = __webpack_require__.S;
|
|
121
|
+
if (!containerScope.__initialized && !containerScope.__initializing) {
|
|
122
|
+
containerScope.__initializing = true;
|
|
123
|
+
await containerScope.init(webpackShareScopes.default);
|
|
124
|
+
containerScope.__initialized = true;
|
|
125
|
+
delete containerScope.__initializing;
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(error);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Function to import remote
|
|
133
|
+
* @async
|
|
134
|
+
* @function
|
|
135
|
+
* @param {ImportRemoteOptions} options - The options for importing the remote
|
|
136
|
+
* @returns {Promise<T>} A promise that resolves with the imported module
|
|
137
|
+
*/ const importRemote = async ({ url, scope, module, remoteEntryFileName = REMOTE_ENTRY_FILE, bustRemoteEntryCache = true, esm = false })=>{
|
|
138
|
+
const remoteScope = scope;
|
|
139
|
+
if (!window[remoteScope]) {
|
|
140
|
+
let remoteUrl = '';
|
|
141
|
+
if (typeof url === 'string') {
|
|
142
|
+
remoteUrl = url;
|
|
143
|
+
} else {
|
|
144
|
+
remoteUrl = await url();
|
|
145
|
+
}
|
|
146
|
+
const remoteUrlWithEntryFile = `${remoteUrl}/${remoteEntryFileName}`;
|
|
147
|
+
const asyncContainer = !esm ? loadRemote(remoteUrlWithEntryFile, scope, bustRemoteEntryCache) : loadEsmRemote(remoteUrlWithEntryFile, scope);
|
|
148
|
+
// Load the remote and initialize the share scope if it's empty
|
|
149
|
+
await Promise.all([
|
|
150
|
+
asyncContainer,
|
|
151
|
+
initSharing()
|
|
152
|
+
]);
|
|
153
|
+
if (!window[remoteScope]) {
|
|
154
|
+
throw new Error(`Remote loaded successfully but ${scope} could not be found! Verify that the name is correct in the Webpack configuration!`);
|
|
155
|
+
}
|
|
156
|
+
// Initialize the container to get shared modules and get the module factory:
|
|
157
|
+
const [, moduleFactory] = await Promise.all([
|
|
158
|
+
initContainer(window[remoteScope]),
|
|
159
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : `./${module}`)
|
|
160
|
+
]);
|
|
161
|
+
return moduleFactory();
|
|
162
|
+
} else {
|
|
163
|
+
const moduleFactory = await window[remoteScope].get(module === '.' || module.startsWith('./') ? module : `./${module}`);
|
|
164
|
+
return moduleFactory();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
exports.importRemote = __webpack_exports__.importRemote;
|
|
169
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
170
|
+
if(["importRemote"].indexOf(__webpack_i__) === -1) {
|
|
171
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
// webpack/runtime/define_property_getters
|
|
14
|
+
(() => {
|
|
15
|
+
__webpack_require__.d = (exports, definition) => {
|
|
16
|
+
for(var key in definition) {
|
|
17
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
18
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
})();
|
|
23
|
+
// webpack/runtime/has_own_property
|
|
24
|
+
(() => {
|
|
25
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
26
|
+
})();
|
|
27
|
+
// webpack/runtime/make_namespace_object
|
|
28
|
+
(() => {
|
|
29
|
+
// define __esModule on exports
|
|
30
|
+
__webpack_require__.r = (exports) => {
|
|
31
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
32
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
/************************************************************************/
|
|
38
|
+
var __webpack_exports__ = {};
|
|
39
|
+
__webpack_require__.r(__webpack_exports__);
|
|
40
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
41
|
+
isObjectEmpty: () => (isObjectEmpty)
|
|
42
|
+
});
|
|
43
|
+
const isObjectEmpty = (obj)=>{
|
|
44
|
+
for(const x in obj){
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
exports.isObjectEmpty = __webpack_exports__.isObjectEmpty;
|
|
51
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
52
|
+
if(["isObjectEmpty"].indexOf(__webpack_i__) === -1) {
|
|
53
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
var __webpack_modules__ = ({});
|
|
10
|
+
/************************************************************************/
|
|
11
|
+
// The module cache
|
|
12
|
+
var __webpack_module_cache__ = {};
|
|
13
|
+
|
|
14
|
+
// The require function
|
|
15
|
+
function __webpack_require__(moduleId) {
|
|
16
|
+
|
|
17
|
+
// Check if module is in cache
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (cachedModule !== undefined) {
|
|
20
|
+
return cachedModule.exports;
|
|
21
|
+
}
|
|
22
|
+
// Create a new module (and put it into the cache)
|
|
23
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
24
|
+
exports: {}
|
|
25
|
+
});
|
|
26
|
+
// Execute the module function
|
|
27
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
28
|
+
|
|
29
|
+
// Return the exports of the module
|
|
30
|
+
return module.exports;
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/************************************************************************/
|
|
35
|
+
// webpack/runtime/define_property_getters
|
|
36
|
+
(() => {
|
|
37
|
+
__webpack_require__.d = (exports, definition) => {
|
|
38
|
+
for(var key in definition) {
|
|
39
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
40
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
// webpack/runtime/has_own_property
|
|
46
|
+
(() => {
|
|
47
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
48
|
+
})();
|
|
49
|
+
// webpack/runtime/make_namespace_object
|
|
50
|
+
(() => {
|
|
51
|
+
// define __esModule on exports
|
|
52
|
+
__webpack_require__.r = (exports) => {
|
|
53
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
54
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
57
|
+
};
|
|
58
|
+
})();
|
|
59
|
+
/************************************************************************/
|
|
60
|
+
var __webpack_exports__ = {};
|
|
61
|
+
__webpack_require__.r(__webpack_exports__);
|
|
62
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
63
|
+
extractUrlAndGlobal: () => (extractUrlAndGlobal),
|
|
64
|
+
getRuntimeRemotes: () => (getRuntimeRemotes),
|
|
65
|
+
loadScript: () => (loadScript),
|
|
66
|
+
remoteVars: () => (remoteVars)
|
|
67
|
+
});
|
|
68
|
+
const pure = typeof process !== 'undefined' ? process.env['REMOTES'] || {} : {};
|
|
69
|
+
const remoteVars = pure;
|
|
70
|
+
const extractUrlAndGlobal = (urlAndGlobal)=>{
|
|
71
|
+
const index = urlAndGlobal.indexOf('@');
|
|
72
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
73
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
urlAndGlobal.substring(index + 1),
|
|
77
|
+
urlAndGlobal.substring(0, index)
|
|
78
|
+
];
|
|
79
|
+
};
|
|
80
|
+
const loadScript = (keyOrRuntimeRemoteItem)=>{
|
|
81
|
+
const runtimeRemotes = getRuntimeRemotes();
|
|
82
|
+
// 1) Load remote container if needed
|
|
83
|
+
let asyncContainer;
|
|
84
|
+
const reference = typeof keyOrRuntimeRemoteItem === 'string' ? runtimeRemotes[keyOrRuntimeRemoteItem] : keyOrRuntimeRemoteItem;
|
|
85
|
+
if (reference.asyncContainer) {
|
|
86
|
+
asyncContainer = typeof reference.asyncContainer.then === 'function' ? reference.asyncContainer : reference.asyncContainer();
|
|
87
|
+
} else {
|
|
88
|
+
// This casting is just to satisfy typescript,
|
|
89
|
+
// In reality remoteGlobal will always be a string;
|
|
90
|
+
const remoteGlobal = reference.global;
|
|
91
|
+
// Check if theres an override for container key if not use remote global
|
|
92
|
+
const containerKey = reference.uniqueKey ? reference.uniqueKey : remoteGlobal;
|
|
93
|
+
const __webpack_error__ = new Error();
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
const globalScope = // @ts-ignore
|
|
96
|
+
typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
97
|
+
if (typeof window === 'undefined') {
|
|
98
|
+
//@ts-ignore
|
|
99
|
+
globalScope['_config'][containerKey] = reference.url;
|
|
100
|
+
} else {
|
|
101
|
+
// to match promise template system, can be removed once promise template is gone
|
|
102
|
+
//@ts-ignore
|
|
103
|
+
if (!globalScope['remoteLoading']) {
|
|
104
|
+
//@ts-ignore
|
|
105
|
+
globalScope['remoteLoading'] = {};
|
|
106
|
+
}
|
|
107
|
+
//@ts-ignore
|
|
108
|
+
if (globalScope['remoteLoading'][containerKey]) {
|
|
109
|
+
//@ts-ignore
|
|
110
|
+
return globalScope['remoteLoading'][containerKey];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
asyncContainer = new Promise(function(resolve, reject) {
|
|
115
|
+
function resolveRemoteGlobal() {
|
|
116
|
+
//@ts-ignore
|
|
117
|
+
const asyncContainer = globalScope[remoteGlobal];
|
|
118
|
+
return resolve(asyncContainer);
|
|
119
|
+
}
|
|
120
|
+
//@ts-ignore
|
|
121
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
122
|
+
return resolveRemoteGlobal();
|
|
123
|
+
}
|
|
124
|
+
__webpack_require__.l(reference.url, function(event) {
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
127
|
+
return resolveRemoteGlobal();
|
|
128
|
+
}
|
|
129
|
+
const errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
130
|
+
const realSrc = event && event.target && event.target.src;
|
|
131
|
+
__webpack_error__.message = 'Loading script failed.\n(' + errorType + ': ' + realSrc + ' or global var ' + remoteGlobal + ')';
|
|
132
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
133
|
+
__webpack_error__.type = errorType;
|
|
134
|
+
__webpack_error__.request = realSrc;
|
|
135
|
+
reject(__webpack_error__);
|
|
136
|
+
}, containerKey);
|
|
137
|
+
}).catch(function(err) {
|
|
138
|
+
console.error('container is offline, returning fake remote');
|
|
139
|
+
console.error(err);
|
|
140
|
+
return {
|
|
141
|
+
fake: true,
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
get: (arg)=>{
|
|
144
|
+
console.warn('faking', arg, 'module on, its offline');
|
|
145
|
+
return Promise.resolve(()=>{
|
|
146
|
+
return {
|
|
147
|
+
__esModule: true,
|
|
148
|
+
default: ()=>{
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
//eslint-disable-next-line
|
|
155
|
+
init: ()=>{}
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
if (typeof window !== 'undefined') {
|
|
159
|
+
//@ts-ignore
|
|
160
|
+
globalScope['remoteLoading'][containerKey] = asyncContainer;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return asyncContainer;
|
|
164
|
+
};
|
|
165
|
+
const getRuntimeRemotes = ()=>{
|
|
166
|
+
return Object.entries(remoteVars).reduce((acc, [key, value])=>{
|
|
167
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
168
|
+
acc[key] = {
|
|
169
|
+
asyncContainer: value
|
|
170
|
+
};
|
|
171
|
+
} else if (typeof value === 'function') {
|
|
172
|
+
acc[key] = {
|
|
173
|
+
asyncContainer: Promise.resolve(value())
|
|
174
|
+
};
|
|
175
|
+
} else if (typeof value === 'string') {
|
|
176
|
+
if (value.startsWith('internal ')) {
|
|
177
|
+
const [request, query] = value.replace('internal ', '').split('?');
|
|
178
|
+
if (query) {
|
|
179
|
+
const remoteSyntax = new URLSearchParams(query).get('remote');
|
|
180
|
+
if (remoteSyntax) {
|
|
181
|
+
const [url, global] = extractUrlAndGlobal(remoteSyntax);
|
|
182
|
+
acc[key] = {
|
|
183
|
+
global,
|
|
184
|
+
url
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
const [url, global] = extractUrlAndGlobal(value);
|
|
190
|
+
acc[key] = {
|
|
191
|
+
global,
|
|
192
|
+
url
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
console.warn('remotes process', process.env['REMOTES']);
|
|
197
|
+
throw new Error(`[mf] Invalid value received for runtime_remote "${key}"`);
|
|
198
|
+
}
|
|
199
|
+
return acc;
|
|
200
|
+
}, {});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
exports.extractUrlAndGlobal = __webpack_exports__.extractUrlAndGlobal;
|
|
204
|
+
exports.getRuntimeRemotes = __webpack_exports__.getRuntimeRemotes;
|
|
205
|
+
exports.loadScript = __webpack_exports__.loadScript;
|
|
206
|
+
exports.remoteVars = __webpack_exports__.remoteVars;
|
|
207
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
208
|
+
if(["extractUrlAndGlobal","getRuntimeRemotes","loadScript","remoteVars"].indexOf(__webpack_i__) === -1) {
|
|
209
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
/************************************************************************/
|
|
13
|
+
// webpack/runtime/compat_get_default_export
|
|
14
|
+
(() => {
|
|
15
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
16
|
+
__webpack_require__.n = (module) => {
|
|
17
|
+
var getter = module && module.__esModule ?
|
|
18
|
+
() => (module['default']) :
|
|
19
|
+
() => (module);
|
|
20
|
+
__webpack_require__.d(getter, { a: getter });
|
|
21
|
+
return getter;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
})();
|
|
25
|
+
// webpack/runtime/define_property_getters
|
|
26
|
+
(() => {
|
|
27
|
+
__webpack_require__.d = (exports, definition) => {
|
|
28
|
+
for(var key in definition) {
|
|
29
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
30
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
// webpack/runtime/has_own_property
|
|
36
|
+
(() => {
|
|
37
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
38
|
+
})();
|
|
39
|
+
// webpack/runtime/make_namespace_object
|
|
40
|
+
(() => {
|
|
41
|
+
// define __esModule on exports
|
|
42
|
+
__webpack_require__.r = (exports) => {
|
|
43
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
44
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
45
|
+
}
|
|
46
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
/************************************************************************/
|
|
50
|
+
var __webpack_exports__ = {};
|
|
51
|
+
// ESM COMPAT FLAG
|
|
52
|
+
__webpack_require__.r(__webpack_exports__);
|
|
53
|
+
|
|
54
|
+
// EXPORTS
|
|
55
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
56
|
+
FederationBoundary: () => (/* reexport */ (FederationBoundary_js_default()))
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
;// CONCATENATED MODULE: external "../components/FederationBoundary.js"
|
|
60
|
+
const FederationBoundary_js_namespaceObject = require("../components/FederationBoundary.js");
|
|
61
|
+
var FederationBoundary_js_default = /*#__PURE__*/__webpack_require__.n(FederationBoundary_js_namespaceObject);
|
|
62
|
+
;// CONCATENATED MODULE: ./src/utils/react.tsx
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
exports.FederationBoundary = __webpack_exports__.FederationBoundary;
|
|
66
|
+
for(var __webpack_i__ in __webpack_exports__) {
|
|
67
|
+
if(["FederationBoundary"].indexOf(__webpack_i__) === -1) {
|
|
68
|
+
exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
;// CONCATENATED MODULE: ./src/Logger.ts
|
|
3
|
+
class Logger {
|
|
4
|
+
static getLogger() {
|
|
5
|
+
return this.loggerInstance;
|
|
6
|
+
}
|
|
7
|
+
static setLogger(logger) {
|
|
8
|
+
this.loggerInstance = logger || console;
|
|
9
|
+
return logger;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
Logger.loggerInstance = console;
|
|
13
|
+
|
|
14
|
+
export { Logger };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
|
|
3
|
+
;// CONCATENATED MODULE: external "react"
|
|
4
|
+
|
|
5
|
+
;// CONCATENATED MODULE: ./src/components/ErrorBoundary.tsx
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generic error boundary component.
|
|
9
|
+
*/ class ErrorBoundary extends react.Component {
|
|
10
|
+
static getDerivedStateFromError() {
|
|
11
|
+
return {
|
|
12
|
+
hasError: true
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
componentDidCatch(error, errorInfo) {
|
|
16
|
+
console.error(error, errorInfo);
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
if (this.state.hasError) {
|
|
20
|
+
return 'An error has occurred.';
|
|
21
|
+
}
|
|
22
|
+
return this.props.children;
|
|
23
|
+
}
|
|
24
|
+
constructor(props){
|
|
25
|
+
super(props);
|
|
26
|
+
this.state = {
|
|
27
|
+
hasError: false
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/* ESM default export */ const components_ErrorBoundary = (ErrorBoundary);
|
|
32
|
+
|
|
33
|
+
export { components_ErrorBoundary as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import react, { lazy, useMemo } from "react";
|
|
2
|
+
import ErrorBoundary from "./ErrorBoundary.mjs";
|
|
3
|
+
|
|
4
|
+
;// CONCATENATED MODULE: external "react"
|
|
5
|
+
|
|
6
|
+
;// CONCATENATED MODULE: external "./ErrorBoundary.mjs"
|
|
7
|
+
|
|
8
|
+
;// CONCATENATED MODULE: ./src/components/FederationBoundary.tsx
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A fallback component that renders nothing.
|
|
13
|
+
*/ const FallbackComponent = ()=>{
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper around dynamic import.
|
|
18
|
+
* Adds error boundaries and fallback options.
|
|
19
|
+
*/ const FederationBoundary = ({ dynamicImporter, fallback = ()=>Promise.resolve(FallbackComponent), customBoundary: CustomBoundary = ErrorBoundary, ...rest })=>{
|
|
20
|
+
const ImportResult = useMemo(()=>{
|
|
21
|
+
return /*#__PURE__*/ lazy(()=>dynamicImporter().catch((e)=>{
|
|
22
|
+
console.error(e);
|
|
23
|
+
return fallback();
|
|
24
|
+
}).then((m)=>{
|
|
25
|
+
return {
|
|
26
|
+
//@ts-ignore
|
|
27
|
+
default: m.default || m
|
|
28
|
+
};
|
|
29
|
+
}));
|
|
30
|
+
}, [
|
|
31
|
+
dynamicImporter,
|
|
32
|
+
fallback
|
|
33
|
+
]);
|
|
34
|
+
return /*#__PURE__*/ react.createElement(CustomBoundary, null, /*#__PURE__*/ react.createElement(ImportResult, rest));
|
|
35
|
+
};
|
|
36
|
+
/* ESM default export */ const components_FederationBoundary = (FederationBoundary);
|
|
37
|
+
|
|
38
|
+
export { components_FederationBoundary as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRuntimeVariables, getContainer, getModule, injectScript } from "./utils/common.mjs";
|
|
2
|
+
import { isObjectEmpty } from "./utils/isEmpty.mjs";
|
|
3
|
+
import { importRemote } from "./utils/importRemote.mjs";
|
|
4
|
+
import { Logger } from "./Logger.mjs";
|
|
5
|
+
import { getRuntimeRemotes } from "./utils/getRuntimeRemotes.mjs";
|
|
6
|
+
import { importDelegatedModule } from "./utils/importDelegatedModule.mjs";
|
|
7
|
+
import { extractUrlAndGlobal, loadScript } from "./utils/pure.mjs";
|
|
8
|
+
export * from "./types/index.mjs";
|
|
9
|
+
|
|
10
|
+
;// CONCATENATED MODULE: external "./utils/common.mjs"
|
|
11
|
+
|
|
12
|
+
;// CONCATENATED MODULE: external "./utils/isEmpty.mjs"
|
|
13
|
+
|
|
14
|
+
;// CONCATENATED MODULE: external "./utils/importRemote.mjs"
|
|
15
|
+
|
|
16
|
+
;// CONCATENATED MODULE: external "./Logger.mjs"
|
|
17
|
+
|
|
18
|
+
;// CONCATENATED MODULE: external "./utils/getRuntimeRemotes.mjs"
|
|
19
|
+
|
|
20
|
+
;// CONCATENATED MODULE: external "./utils/importDelegatedModule.mjs"
|
|
21
|
+
|
|
22
|
+
;// CONCATENATED MODULE: external "./utils/pure.mjs"
|
|
23
|
+
|
|
24
|
+
;// CONCATENATED MODULE: ./src/index.ts
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export { Logger, createRuntimeVariables, extractUrlAndGlobal, getContainer, getModule, getRuntimeRemotes, importDelegatedModule, importRemote, injectScript, isObjectEmpty, loadScript };
|