@module-federation/utilities 2.0.1 → 2.0.3
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 +13 -0
- package/package.json +1 -1
- package/src/components/ErrorBoundary.js +4 -2
- package/src/components/ErrorBoundary.js.map +1 -1
- package/src/components/FederationBoundary.js +40 -4
- package/src/components/FederationBoundary.js.map +1 -1
- package/src/index.js +20 -7
- package/src/index.js.map +1 -1
- package/src/plugins/DelegateModulesPlugin.d.ts +2 -1
- package/src/plugins/DelegateModulesPlugin.js +23 -7
- package/src/plugins/DelegateModulesPlugin.js.map +1 -1
- package/src/utils/common.d.ts +3 -3
- package/src/utils/common.js +39 -126
- package/src/utils/common.js.map +1 -1
- package/src/utils/correctImportPath.js.map +1 -1
- package/src/utils/importDelegatedModule.js +13 -5
- package/src/utils/importDelegatedModule.js.map +1 -1
- package/src/utils/importRemote.js +14 -6
- package/src/utils/importRemote.js.map +1 -1
- package/src/utils/pure.d.ts +5 -0
- package/src/utils/pure.js +170 -0
- package/src/utils/pure.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [2.0.3](https://github.com/module-federation/nextjs-mf/compare/utils-2.0.2...utils-2.0.3) (2023-07-19)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* Fix call undefined delegate ([#1149](https://github.com/module-federation/nextjs-mf/issues/1149)) ([87a5896](https://github.com/module-federation/nextjs-mf/commit/87a5896221a726578c3433071755fba3465824f4)), closes [#1151](https://github.com/module-federation/nextjs-mf/issues/1151)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.0.2](https://github.com/module-federation/nextjs-mf/compare/utils-2.0.1...utils-2.0.2) (2023-07-18)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
5
18
|
## [2.0.1](https://github.com/module-federation/nextjs-mf/compare/utils-2.0.0...utils-2.0.1) (2023-07-17)
|
|
6
19
|
|
|
7
20
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const react_1 = __importDefault(require("react"));
|
|
5
7
|
/**
|
|
6
8
|
* Generic error boundary component.
|
|
7
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/ErrorBoundary.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA8C;AAU9C;;GAEG;AACH,MAAM,aAAc,SAAQ,eAAK,CAAC,SAGjC;IACC,YAAY,KAAyB;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,wBAAwB,EAAC,gBAAgB;QAC9C,OAAO;YACL,QAAQ,EAAE,IAAI;SACf,CAAC;IACJ,CAAC;IAEQ,iBAAiB,CAAC,KAAY,EAAE,SAAoB;QAC3D,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAEQ,MAAM;QACb,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,OAAO,wBAAwB,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
2
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const ErrorBoundary_1 = tslib_1.__importDefault(require("./ErrorBoundary"));
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const ErrorBoundary_1 = __importDefault(require("./ErrorBoundary"));
|
|
6
42
|
/**
|
|
7
43
|
* A fallback component that renders nothing.
|
|
8
44
|
*/
|
|
@@ -14,7 +50,7 @@ const FallbackComponent = () => {
|
|
|
14
50
|
* Adds error boundaries and fallback options.
|
|
15
51
|
*/
|
|
16
52
|
const FederationBoundary = (_a) => {
|
|
17
|
-
var { dynamicImporter, fallback = () => Promise.resolve(FallbackComponent), customBoundary: CustomBoundary = ErrorBoundary_1.default } = _a, rest =
|
|
53
|
+
var { dynamicImporter, fallback = () => Promise.resolve(FallbackComponent), customBoundary: CustomBoundary = ErrorBoundary_1.default } = _a, rest = __rest(_a, ["dynamicImporter", "fallback", "customBoundary"]);
|
|
18
54
|
const ImportResult = (0, react_1.useMemo)(() => {
|
|
19
55
|
return (0, react_1.lazy)(() => dynamicImporter()
|
|
20
56
|
.catch((e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FederationBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/FederationBoundary.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FederationBoundary.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/components/FederationBoundary.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAE7C,oEAA4C;AAE5C;;GAEG;AACH,MAAM,iBAAiB,GAAa,GAAG,EAAE;IACvC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAaF;;;GAGG;AACH,MAAM,kBAAkB,GAAsC,CAAC,EAK9D,EAAE,EAAE;QAL0D,EAC7D,eAAe,EACf,QAAQ,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EACnD,cAAc,EAAE,cAAc,GAAG,uBAAa,OAE/C,EADI,IAAI,cAJsD,iDAK9D,CADQ;IAEP,MAAM,YAAY,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAChC,OAAO,IAAA,YAAI,EAAC,GAAG,EAAE,CACf,eAAe,EAAE;aACd,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,OAAO,QAAQ,EAAE,CAAC;QACpB,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACV,OAAO;gBACL,YAAY;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,CAAC;aACxB,CAAC;QACJ,CAAC,CAAC,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEhC,OAAO,CACL,8BAAC,cAAc;QACb,8BAAC,YAAY,oBAAK,IAAI,EAAI,CACX,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.importDelegatedModule = exports.getRuntimeRemotes = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
tslib_1.__exportStar(require("./Logger"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./utils/common"), exports);
|
|
20
|
+
__exportStar(require("./utils/isEmpty"), exports);
|
|
21
|
+
__exportStar(require("./utils/importRemote"), exports);
|
|
22
|
+
__exportStar(require("./utils/correctImportPath"), exports);
|
|
23
|
+
__exportStar(require("./Logger"), exports);
|
|
11
24
|
var getRuntimeRemotes_1 = require("./utils/getRuntimeRemotes");
|
|
12
25
|
Object.defineProperty(exports, "getRuntimeRemotes", { enumerable: true, get: function () { return getRuntimeRemotes_1.getRuntimeRemotes; } });
|
|
13
26
|
var importDelegatedModule_1 = require("./utils/importDelegatedModule");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/utilities/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/utilities/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,4DAA0C;AAC1C,2CAAyB;AACzB,+DAA8D;AAArD,sHAAA,iBAAiB,OAAA;AAC1B,uEAAsE;AAA7D,8HAAA,qBAAqB,OAAA"}
|
|
@@ -14,7 +14,8 @@ declare class DelegateModulesPlugin {
|
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
});
|
|
16
16
|
getChunkByName(chunks: Iterable<Chunk>, name: string): Chunk | undefined;
|
|
17
|
-
addDelegatesToChunks
|
|
17
|
+
private addDelegatesToChunks;
|
|
18
|
+
private addModuleAndDependenciesToChunk;
|
|
18
19
|
removeDelegatesNonRuntimeChunks(compilation: Compilation, chunks: Iterable<Chunk>): void;
|
|
19
20
|
/**
|
|
20
21
|
* Applies the plugin to the webpack compiler.
|
|
@@ -19,13 +19,29 @@ class DelegateModulesPlugin {
|
|
|
19
19
|
}
|
|
20
20
|
addDelegatesToChunks(compilation, chunks) {
|
|
21
21
|
for (const chunk of chunks) {
|
|
22
|
-
this._delegateModules
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
for (const module of Array.from(this._delegateModules)) {
|
|
23
|
+
this.addModuleAndDependenciesToChunk(module, chunk, compilation);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
addModuleAndDependenciesToChunk(module, chunk, compilation) {
|
|
28
|
+
if (!compilation.chunkGraph.isModuleInChunk(module, chunk)) {
|
|
29
|
+
if (this.options.debug) {
|
|
30
|
+
console.log('adding ', module.identifier(), ' to chunk', chunk.name);
|
|
31
|
+
}
|
|
32
|
+
if (module.buildMeta) {
|
|
33
|
+
//@ts-ignore
|
|
34
|
+
module.buildMeta.eager = true; // non-standard way to keep track of initial
|
|
35
|
+
}
|
|
36
|
+
// modules needed by delegate module, so during eager share removal they are perserved
|
|
37
|
+
compilation.chunkGraph.connectChunkAndModule(chunk, module);
|
|
38
|
+
}
|
|
39
|
+
for (const dependency of module.dependencies) {
|
|
40
|
+
const dependencyModule = compilation.moduleGraph.getModule(dependency);
|
|
41
|
+
if (dependencyModule &&
|
|
42
|
+
!compilation.chunkGraph.isModuleInChunk(dependencyModule, chunk)) {
|
|
43
|
+
this.addModuleAndDependenciesToChunk(dependencyModule, chunk, compilation);
|
|
44
|
+
}
|
|
29
45
|
}
|
|
30
46
|
}
|
|
31
47
|
removeDelegatesNonRuntimeChunks(compilation, chunks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DelegateModulesPlugin.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/plugins/DelegateModulesPlugin.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DelegateModulesPlugin.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/plugins/DelegateModulesPlugin.ts"],"names":[],"mappings":";;AAEA;;;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;IAEO,oBAAoB,CAC1B,WAAwB,EACxB,MAAe;QAEf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE;gBACtD,IAAI,CAAC,+BAA+B,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;aAClE;SACF;IACH,CAAC;IAEO,+BAA+B,CACrC,MAAc,EACd,KAAY,EACZ,WAAwB;QAExB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,K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C,OAAO,EAAE,QAAQ,EAAE,EAAE;YACpB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;YAEjC,+DAA+D;YAC/D,MAAM,cAAc,GAAG,IAAI,GAAG,CAC5B,OAAO;gBACL,CAAC,CAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAc,CAAC,GAAG,CAAC,CAAC,MAAc,EAAE,EAAE,CAC1D,MAAM,CAAC,OAAO,CAAC,WAAW,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"}
|
package/src/utils/common.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { GetModuleOptions, RemoteData, Remotes, RuntimeRemote, WebpackRemoteContainer } from '../types';
|
|
2
|
-
|
|
3
|
-
export declare const remoteVars: RemoteVars;
|
|
2
|
+
export declare const remoteVars: import("../types").RemoteVars;
|
|
4
3
|
export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
|
|
4
|
+
export declare const loadScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => any;
|
|
5
|
+
export declare const getRuntimeRemotes: () => import("../types").RuntimeRemotesMap;
|
|
5
6
|
export declare const createDelegatedModule: (delegate: string, params: {
|
|
6
7
|
[key: string]: any;
|
|
7
8
|
}) => string;
|
|
8
|
-
export declare const loadScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => any;
|
|
9
9
|
/**
|
|
10
10
|
* Return initialized remote container by remote's key or its runtime remote item data.
|
|
11
11
|
*
|
package/src/utils/common.js
CHANGED
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
remotesFromProcess = process.env['REMOTES'] || {};
|
|
11
|
-
}
|
|
12
|
-
catch (e) {
|
|
13
|
-
// not in webpack bundle
|
|
14
|
-
}
|
|
15
|
-
exports.remoteVars = remotesFromProcess;
|
|
16
|
-
// split the @ syntax into url and global
|
|
17
|
-
const extractUrlAndGlobal = (urlAndGlobal) => {
|
|
18
|
-
const index = urlAndGlobal.indexOf('@');
|
|
19
|
-
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
20
|
-
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
21
8
|
}
|
|
22
|
-
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
23
34
|
};
|
|
24
|
-
exports
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getModule = exports.getContainer = exports.createRuntimeVariables = exports.injectScript = exports.createDelegatedModule = exports.getRuntimeRemotes = exports.loadScript = exports.extractUrlAndGlobal = exports.remoteVars = void 0;
|
|
37
|
+
const utils = __importStar(require("./pure"));
|
|
38
|
+
exports.remoteVars = utils.remoteVars;
|
|
39
|
+
exports.extractUrlAndGlobal = utils.extractUrlAndGlobal;
|
|
40
|
+
exports.loadScript = utils.loadScript;
|
|
41
|
+
exports.getRuntimeRemotes = utils.getRuntimeRemotes;
|
|
25
42
|
const createDelegatedModule = (delegate, params) => {
|
|
26
43
|
const queries = [];
|
|
27
44
|
for (const [key, value] of Object.entries(params)) {
|
|
@@ -35,110 +52,6 @@ const createDelegatedModule = (delegate, params) => {
|
|
|
35
52
|
return `internal ${delegate}?${queries.join('&')}`;
|
|
36
53
|
};
|
|
37
54
|
exports.createDelegatedModule = createDelegatedModule;
|
|
38
|
-
const loadScript = (keyOrRuntimeRemoteItem) => {
|
|
39
|
-
const runtimeRemotes = (0, getRuntimeRemotes_1.getRuntimeRemotes)();
|
|
40
|
-
// 1) Load remote container if needed
|
|
41
|
-
let asyncContainer;
|
|
42
|
-
const reference = typeof keyOrRuntimeRemoteItem === 'string'
|
|
43
|
-
? runtimeRemotes[keyOrRuntimeRemoteItem]
|
|
44
|
-
: keyOrRuntimeRemoteItem;
|
|
45
|
-
if (reference.asyncContainer) {
|
|
46
|
-
asyncContainer =
|
|
47
|
-
typeof reference.asyncContainer.then === 'function'
|
|
48
|
-
? reference.asyncContainer
|
|
49
|
-
: // @ts-ignore
|
|
50
|
-
reference.asyncContainer();
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// This casting is just to satisfy typescript,
|
|
54
|
-
// In reality remoteGlobal will always be a string;
|
|
55
|
-
const remoteGlobal = reference.global;
|
|
56
|
-
// Check if theres an override for container key if not use remote global
|
|
57
|
-
const containerKey = reference.uniqueKey
|
|
58
|
-
? reference.uniqueKey
|
|
59
|
-
: remoteGlobal;
|
|
60
|
-
const __webpack_error__ = new Error();
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
if (!globalThis.__remote_scope__) {
|
|
63
|
-
// create a global scope for container, similar to how remotes are set on window in the browser
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
globalThis.__remote_scope__ = {
|
|
66
|
-
// @ts-ignore
|
|
67
|
-
_config: {},
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
const globalScope =
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
74
|
-
if (typeof window === 'undefined') {
|
|
75
|
-
globalScope['_config'][containerKey] = reference.url;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// to match promise template system, can be removed once promise template is gone
|
|
79
|
-
if (!globalScope['remoteLoading']) {
|
|
80
|
-
globalScope['remoteLoading'] = {};
|
|
81
|
-
}
|
|
82
|
-
if (globalScope['remoteLoading'][containerKey]) {
|
|
83
|
-
return globalScope['remoteLoading'][containerKey];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
asyncContainer = new Promise(function (resolve, reject) {
|
|
88
|
-
function resolveRemoteGlobal() {
|
|
89
|
-
const asyncContainer = globalScope[remoteGlobal];
|
|
90
|
-
return resolve(asyncContainer);
|
|
91
|
-
}
|
|
92
|
-
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
93
|
-
return resolveRemoteGlobal();
|
|
94
|
-
}
|
|
95
|
-
__webpack_require__.l(reference.url, function (event) {
|
|
96
|
-
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
97
|
-
return resolveRemoteGlobal();
|
|
98
|
-
}
|
|
99
|
-
const errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
100
|
-
const realSrc = event && event.target && event.target.src;
|
|
101
|
-
__webpack_error__.message =
|
|
102
|
-
'Loading script failed.\n(' +
|
|
103
|
-
errorType +
|
|
104
|
-
': ' +
|
|
105
|
-
realSrc +
|
|
106
|
-
' or global var ' +
|
|
107
|
-
remoteGlobal +
|
|
108
|
-
')';
|
|
109
|
-
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
110
|
-
__webpack_error__.type = errorType;
|
|
111
|
-
__webpack_error__.request = realSrc;
|
|
112
|
-
reject(__webpack_error__);
|
|
113
|
-
}, containerKey);
|
|
114
|
-
}).catch(function (err) {
|
|
115
|
-
console.error('container is offline, returning fake remote');
|
|
116
|
-
console.error(err);
|
|
117
|
-
return {
|
|
118
|
-
fake: true,
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
get: (arg) => {
|
|
121
|
-
console.warn('faking', arg, 'module on, its offline');
|
|
122
|
-
return Promise.resolve(() => {
|
|
123
|
-
return {
|
|
124
|
-
__esModule: true,
|
|
125
|
-
default: () => {
|
|
126
|
-
return null;
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
//eslint-disable-next-line
|
|
132
|
-
init: () => { },
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
if (typeof window !== 'undefined') {
|
|
136
|
-
globalScope['remoteLoading'][containerKey] = asyncContainer;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return asyncContainer;
|
|
140
|
-
};
|
|
141
|
-
exports.loadScript = loadScript;
|
|
142
55
|
const createContainerSharingScope = (asyncContainer) => {
|
|
143
56
|
// @ts-ignore
|
|
144
57
|
return asyncContainer
|
|
@@ -208,7 +121,7 @@ exports.createRuntimeVariables = createRuntimeVariables;
|
|
|
208
121
|
* Returns initialized webpack RemoteContainer.
|
|
209
122
|
* If its' script does not loaded - then load & init it firstly.
|
|
210
123
|
*/
|
|
211
|
-
const getContainer = (remoteContainer) =>
|
|
124
|
+
const getContainer = (remoteContainer) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
125
|
if (!remoteContainer) {
|
|
213
126
|
throw Error(`Remote container options is empty`);
|
|
214
127
|
}
|
|
@@ -245,7 +158,7 @@ exports.getContainer = getContainer;
|
|
|
245
158
|
* @example
|
|
246
159
|
* remote.getModule('./pages/index', 'default')
|
|
247
160
|
*/
|
|
248
|
-
const getModule = ({ remoteContainer, modulePath, exportName, }) =>
|
|
161
|
+
const getModule = ({ remoteContainer, modulePath, exportName, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
162
|
const container = yield (0, exports.getContainer)(remoteContainer);
|
|
250
163
|
try {
|
|
251
164
|
const modFactory = yield (container === null || container === void 0 ? void 0 : container.get(modulePath));
|
package/src/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"mappings":";AAAA,sDAAsD
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/common.ts"],"names":[],"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G,MAAM,IAAA,oBAAY,EAAC,eAAe,CAAC,CAAC;IACtD,IAAI;QACF,MAAM,UAAU,GAAG,MAAM,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,UAAU,CAAC,CAAA,CAAC;QACpD,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAClC,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,IAAI,UAAU,EAAE;YACd,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SACrE;aAAM;YACL,OAAO,GAAG,CAAC;SACZ;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAA,CAAC;AAnBW,QAAA,SAAS,aAmBpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"correctImportPath.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/correctImportPath.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"correctImportPath.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/correctImportPath.ts"],"names":[],"mappings":";;;AAAO,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE;IACtE,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;QAClC,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,MAAK,OAAO,EAAE;YACjC,OAAO,SAAS,CAAC;SAClB;QACD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAEpC,IAAI,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE;YACnE,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;SACtC;QAED,8DAA8D;QAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE3C,IAAI,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YACtC,OAAO,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C;QAED,OAAO,KAAK,QAAQ,EAAE,CAAC;KACxB;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAvBW,QAAA,iBAAiB,qBAuB5B"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.importDelegatedModule = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const importDelegatedModule = (keyOrRuntimeRemoteItem) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const pure_1 = require("./pure");
|
|
14
|
+
const importDelegatedModule = (keyOrRuntimeRemoteItem) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
15
|
// @ts-ignore
|
|
8
|
-
return (0,
|
|
16
|
+
return (0, pure_1.loadScript)(keyOrRuntimeRemoteItem)
|
|
9
17
|
.then((asyncContainer) => {
|
|
10
18
|
return asyncContainer;
|
|
11
19
|
})
|
|
@@ -13,7 +21,7 @@ const importDelegatedModule = (keyOrRuntimeRemoteItem) => tslib_1.__awaiter(void
|
|
|
13
21
|
// most of this is only needed because of legacy promise based implementation
|
|
14
22
|
// can remove proxies once we remove promise based implementations
|
|
15
23
|
if (typeof window === 'undefined') {
|
|
16
|
-
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, '
|
|
24
|
+
if (!Object.hasOwnProperty.call(keyOrRuntimeRemoteItem, 'globalThis')) {
|
|
17
25
|
return asyncContainer;
|
|
18
26
|
}
|
|
19
27
|
// return asyncContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importDelegatedModule.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importDelegatedModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"importDelegatedModule.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importDelegatedModule.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,iCAAoC;AAE7B,MAAM,qBAAqB,GAAG,CACnC,sBAA8C,EAC9C,EAAE;IACF,aAAa;IACb,OAAO,IAAA,iBAAU,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,EAAE;YACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI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AE,IAAI;iCACjB,CAAC,CAAC;6BACJ;yBACF;wBAED,IAAI,CAAC,CAAC,IAAI,EAAE;4BACV,OAAO,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;yBACtC;wBAED,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;oBACtB,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,EAAE,cAAc,CAAC,IAAI;aAC1B,CAAC;SACH;aAAM;YACL,OAAO,cAAc,CAAC;SACvB;IACH,CAAC,CAAC,CAAC;AACP,CAAC,CAAA,CAAC;AA5EW,QAAA,qBAAqB,yBA4EhC"}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.importRemote = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
13
|
const REMOTE_ENTRY_FILE = 'remoteEntry.js';
|
|
6
14
|
const loadRemote = (url, scope, bustRemoteEntryCache) => new Promise((resolve, reject) => {
|
|
7
15
|
const timestamp = bustRemoteEntryCache ? `?t=${new Date().getTime()}` : '';
|
|
@@ -19,14 +27,14 @@ const loadRemote = (url, scope, bustRemoteEntryCache) => new Promise((resolve, r
|
|
|
19
27
|
reject(error);
|
|
20
28
|
}, scope);
|
|
21
29
|
});
|
|
22
|
-
const initSharing = () =>
|
|
30
|
+
const initSharing = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
31
|
const webpackShareScopes = __webpack_share_scopes__;
|
|
24
32
|
if (!(webpackShareScopes === null || webpackShareScopes === void 0 ? void 0 : webpackShareScopes.default)) {
|
|
25
33
|
yield __webpack_init_sharing__('default');
|
|
26
34
|
}
|
|
27
35
|
});
|
|
28
36
|
// __initialized and __initializing flags prevent some concurrent re-initialization corner cases
|
|
29
|
-
const initContainer = (containerScope) =>
|
|
37
|
+
const initContainer = (containerScope) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
38
|
try {
|
|
31
39
|
const webpackShareScopes = __webpack_share_scopes__;
|
|
32
40
|
if (!containerScope.__initialized && !containerScope.__initializing) {
|
|
@@ -44,7 +52,7 @@ const initContainer = (containerScope) => tslib_1.__awaiter(void 0, void 0, void
|
|
|
44
52
|
Dynamically import a remote module using Webpack's loading mechanism:
|
|
45
53
|
https://webpack.js.org/concepts/module-federation/
|
|
46
54
|
*/
|
|
47
|
-
const importRemote = ({ url, scope, module, remoteEntryFileName = REMOTE_ENTRY_FILE, bustRemoteEntryCache = true, }) =>
|
|
55
|
+
const importRemote = ({ url, scope, module, remoteEntryFileName = REMOTE_ENTRY_FILE, bustRemoteEntryCache = true, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
56
|
const remoteScope = scope;
|
|
49
57
|
if (!window[remoteScope]) {
|
|
50
58
|
let remoteUrl = '';
|
|
@@ -65,12 +73,12 @@ const importRemote = ({ url, scope, module, remoteEntryFileName = REMOTE_ENTRY_F
|
|
|
65
73
|
// Initialize the container to get shared modules and get the module factory:
|
|
66
74
|
const [, moduleFactory] = yield Promise.all([
|
|
67
75
|
initContainer(window[remoteScope]),
|
|
68
|
-
window[remoteScope].get(
|
|
76
|
+
window[remoteScope].get(module === '.' || module.startsWith('./') ? module : `./${module}`),
|
|
69
77
|
]);
|
|
70
78
|
return moduleFactory();
|
|
71
79
|
}
|
|
72
80
|
else {
|
|
73
|
-
const moduleFactory = yield window[remoteScope].get(
|
|
81
|
+
const moduleFactory = yield window[remoteScope].get(module === '.' || module.startsWith('./') ? module : `./${module}`);
|
|
74
82
|
return moduleFactory();
|
|
75
83
|
}
|
|
76
84
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importRemote.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/importRemote.ts"],"names":[],"mappings":"
|
|
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,8BAA8B;YAC9B,OAAO,OAAO,EAAE,CAAC;SAClB;QACD,MAAM,OAAO,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,0CAAE,GAAG,CAAC;QACnC,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,CAAC,OAAO,GAAG,oCAAoC,GAAG,OAAO,GAAG,GAAG,CAAC;QACrE,KAAK,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACv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+DAA+D;QAC/D,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,UAAU,CACR,GAAG,SAAS,IAAI,mBAAmB,EAAE,EACrC,KAAK,EACL,oBAAoB,CACrB;YACD,WAAW,EAAE;SACd,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,kCAAkC,KAAK,oFAAoF,CAC5H,CAAC;SACH;QACD,6EAA6E;QAC7E,MAAM,CAAC,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1C,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YACjC,MAAM,CAAC,WAAW,CAAuC,CAAC,GAAG,CAC5D,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CACnE;SACF,CAAC,CAAC;QACH,OAAO,aAAa,EAAE,CAAC;KACxB;SAAM;QACL,MAAM,aAAa,GAAG,MACpB,MAAM,CAAC,WAAW,CACnB,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;QAC1E,OAAO,aAAa,EAAE,CAAC;KACxB;AACH,CAAC,CAAA,CAAC;AA7CW,QAAA,YAAY,gBA6CvB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RemoteVars, RuntimeRemote, RuntimeRemotesMap } from '../types/index';
|
|
2
|
+
export declare const remoteVars: RemoteVars;
|
|
3
|
+
export declare const extractUrlAndGlobal: (urlAndGlobal: string) => [string, string];
|
|
4
|
+
export declare const loadScript: (keyOrRuntimeRemoteItem: string | RuntimeRemote) => any;
|
|
5
|
+
export declare const getRuntimeRemotes: () => RuntimeRemotesMap;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRuntimeRemotes = exports.loadScript = exports.extractUrlAndGlobal = exports.remoteVars = void 0;
|
|
4
|
+
let pure = {};
|
|
5
|
+
try {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
pure = process.env['REMOTES'] || {};
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
// not in webpack bundle
|
|
11
|
+
}
|
|
12
|
+
exports.remoteVars = pure;
|
|
13
|
+
const extractUrlAndGlobal = (urlAndGlobal) => {
|
|
14
|
+
const index = urlAndGlobal.indexOf('@');
|
|
15
|
+
if (index <= 0 || index === urlAndGlobal.length - 1) {
|
|
16
|
+
throw new Error(`Invalid request "${urlAndGlobal}"`);
|
|
17
|
+
}
|
|
18
|
+
return [urlAndGlobal.substring(index + 1), urlAndGlobal.substring(0, index)];
|
|
19
|
+
};
|
|
20
|
+
exports.extractUrlAndGlobal = extractUrlAndGlobal;
|
|
21
|
+
const loadScript = (keyOrRuntimeRemoteItem) => {
|
|
22
|
+
const runtimeRemotes = (0, exports.getRuntimeRemotes)();
|
|
23
|
+
// 1) Load remote container if needed
|
|
24
|
+
let asyncContainer;
|
|
25
|
+
const reference = typeof keyOrRuntimeRemoteItem === 'string'
|
|
26
|
+
? runtimeRemotes[keyOrRuntimeRemoteItem]
|
|
27
|
+
: keyOrRuntimeRemoteItem;
|
|
28
|
+
if (reference.asyncContainer) {
|
|
29
|
+
asyncContainer =
|
|
30
|
+
typeof reference.asyncContainer.then === 'function'
|
|
31
|
+
? reference.asyncContainer
|
|
32
|
+
: // @ts-ignore
|
|
33
|
+
reference.asyncContainer();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// This casting is just to satisfy typescript,
|
|
37
|
+
// In reality remoteGlobal will always be a string;
|
|
38
|
+
const remoteGlobal = reference.global;
|
|
39
|
+
// Check if theres an override for container key if not use remote global
|
|
40
|
+
const containerKey = reference.uniqueKey
|
|
41
|
+
? reference.uniqueKey
|
|
42
|
+
: remoteGlobal;
|
|
43
|
+
const __webpack_error__ = new Error();
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
if (!globalThis.__remote_scope__) {
|
|
46
|
+
// create a global scope for container, similar to how remotes are set on window in the browser
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
globalThis.__remote_scope__ = {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
_config: {},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const globalScope =
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
typeof window !== 'undefined' ? window : globalThis.__remote_scope__;
|
|
57
|
+
if (typeof window === 'undefined') {
|
|
58
|
+
globalScope['_config'][containerKey] = reference.url;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// to match promise template system, can be removed once promise template is gone
|
|
62
|
+
if (!globalScope['remoteLoading']) {
|
|
63
|
+
globalScope['remoteLoading'] = {};
|
|
64
|
+
}
|
|
65
|
+
if (globalScope['remoteLoading'][containerKey]) {
|
|
66
|
+
return globalScope['remoteLoading'][containerKey];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
asyncContainer = new Promise(function (resolve, reject) {
|
|
71
|
+
function resolveRemoteGlobal() {
|
|
72
|
+
const asyncContainer = globalScope[remoteGlobal];
|
|
73
|
+
return resolve(asyncContainer);
|
|
74
|
+
}
|
|
75
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
76
|
+
return resolveRemoteGlobal();
|
|
77
|
+
}
|
|
78
|
+
__webpack_require__.l(reference.url, function (event) {
|
|
79
|
+
if (typeof globalScope[remoteGlobal] !== 'undefined') {
|
|
80
|
+
return resolveRemoteGlobal();
|
|
81
|
+
}
|
|
82
|
+
const errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
83
|
+
const realSrc = event && event.target && event.target.src;
|
|
84
|
+
__webpack_error__.message =
|
|
85
|
+
'Loading script failed.\n(' +
|
|
86
|
+
errorType +
|
|
87
|
+
': ' +
|
|
88
|
+
realSrc +
|
|
89
|
+
' or global var ' +
|
|
90
|
+
remoteGlobal +
|
|
91
|
+
')';
|
|
92
|
+
__webpack_error__.name = 'ScriptExternalLoadError';
|
|
93
|
+
__webpack_error__.type = errorType;
|
|
94
|
+
__webpack_error__.request = realSrc;
|
|
95
|
+
reject(__webpack_error__);
|
|
96
|
+
}, containerKey);
|
|
97
|
+
}).catch(function (err) {
|
|
98
|
+
console.error('container is offline, returning fake remote');
|
|
99
|
+
console.error(err);
|
|
100
|
+
return {
|
|
101
|
+
fake: true,
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
get: (arg) => {
|
|
104
|
+
console.warn('faking', arg, 'module on, its offline');
|
|
105
|
+
return Promise.resolve(() => {
|
|
106
|
+
return {
|
|
107
|
+
__esModule: true,
|
|
108
|
+
default: () => {
|
|
109
|
+
return null;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
//eslint-disable-next-line
|
|
115
|
+
init: () => { },
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
if (typeof window !== 'undefined') {
|
|
119
|
+
globalScope['remoteLoading'][containerKey] = asyncContainer;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return asyncContainer;
|
|
123
|
+
};
|
|
124
|
+
exports.loadScript = loadScript;
|
|
125
|
+
const getRuntimeRemotes = () => {
|
|
126
|
+
try {
|
|
127
|
+
const runtimeRemotes = Object.entries(exports.remoteVars).reduce(function (acc, item) {
|
|
128
|
+
const [key, value] = item;
|
|
129
|
+
// if its an object with a thenable (eagerly executing function)
|
|
130
|
+
if (typeof value === 'object' && typeof value.then === 'function') {
|
|
131
|
+
acc[key] = { asyncContainer: value };
|
|
132
|
+
}
|
|
133
|
+
// if its a function that must be called (lazily executing function)
|
|
134
|
+
else if (typeof value === 'function') {
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
acc[key] = { asyncContainer: value };
|
|
137
|
+
}
|
|
138
|
+
// if its a delegate module, skip it
|
|
139
|
+
else if (typeof value === 'string' && value.startsWith('internal ')) {
|
|
140
|
+
const [request, query] = value.replace('internal ', '').split('?');
|
|
141
|
+
if (query) {
|
|
142
|
+
const remoteSyntax = new URLSearchParams(query).get('remote');
|
|
143
|
+
if (remoteSyntax) {
|
|
144
|
+
const [url, global] = (0, exports.extractUrlAndGlobal)(remoteSyntax);
|
|
145
|
+
acc[key] = { global, url };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// if its just a string (global@url)
|
|
150
|
+
else if (typeof value === 'string') {
|
|
151
|
+
const [url, global] = (0, exports.extractUrlAndGlobal)(value);
|
|
152
|
+
acc[key] = { global, url };
|
|
153
|
+
}
|
|
154
|
+
// we dont know or currently support this type
|
|
155
|
+
else {
|
|
156
|
+
//@ts-ignore
|
|
157
|
+
console.warn('remotes process', process.env.REMOTES);
|
|
158
|
+
throw new Error(`[mf] Invalid value received for runtime_remote "${key}"`);
|
|
159
|
+
}
|
|
160
|
+
return acc;
|
|
161
|
+
}, {});
|
|
162
|
+
return runtimeRemotes;
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.warn('Unable to retrieve runtime remotes: ', err);
|
|
166
|
+
}
|
|
167
|
+
return {};
|
|
168
|
+
};
|
|
169
|
+
exports.getRuntimeRemotes = getRuntimeRemotes;
|
|
170
|
+
//# sourceMappingURL=pure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../packages/utilities/src/utils/pure.ts"],"names":[],"mappings":";;;AAOA,IAAI,IAAI,GAAG,EAAgB,CAAC;AAC5B,IAAI;IACF,aAAa;IACb,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;CACrC;AA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