@module-federation/runtime 0.0.0-next-20240824225724 → 0.0.0-next-20240826075118
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/helpers.cjs.js +0 -3
- package/dist/helpers.esm.js +1 -4
- package/dist/index.cjs.js +167 -28
- package/dist/index.esm.js +168 -29
- package/dist/package.json +1 -6
- package/dist/retry-plugin.cjs.js +15 -3
- package/dist/retry-plugin.esm.js +15 -3
- package/dist/share.cjs.js +64 -12
- package/dist/share.esm.js +61 -11
- package/dist/src/core.d.ts +7 -3
- package/dist/src/remote/index.d.ts +4 -4
- package/dist/src/shared/index.d.ts +7 -2
- package/dist/src/type/config.d.ts +3 -1
- package/dist/src/utils/env.d.ts +2 -1
- package/dist/src/utils/tool.d.ts +1 -0
- package/package.json +2 -7
- package/dist/embedded.cjs.d.ts +0 -1
- package/dist/embedded.cjs.js +0 -20
- package/dist/embedded.esm.js +0 -3
- package/dist/src/embedded.d.ts +0 -2
package/dist/share.esm.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { _ as _$1 } from '@swc/helpers/_/_extends';
|
|
2
|
-
import { _ } from '@swc/helpers/_/_object_without_properties_loose';
|
|
3
|
-
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
4
|
-
|
|
5
1
|
function getBuilderId() {
|
|
6
2
|
//@ts-ignore
|
|
7
3
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
8
4
|
}
|
|
5
|
+
function isDebugMode() {
|
|
6
|
+
return Boolean("");
|
|
7
|
+
}
|
|
8
|
+
function isBrowserEnv() {
|
|
9
|
+
return typeof window !== 'undefined';
|
|
10
|
+
}
|
|
9
11
|
|
|
10
12
|
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
11
13
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
@@ -51,6 +53,14 @@ function isRemoteInfoWithEntry(remote) {
|
|
|
51
53
|
function isPureRemoteEntry(remote) {
|
|
52
54
|
return !remote.entry.includes('.json') && remote.entry.includes('.js');
|
|
53
55
|
}
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
57
|
+
function safeToString(info) {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.stringify(info, null, 2);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
54
64
|
function isObject(val) {
|
|
55
65
|
return val && typeof val === 'object';
|
|
56
66
|
}
|
|
@@ -87,6 +97,32 @@ function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
|
87
97
|
return defaultRemoteEntryInfo;
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
function _extends$1() {
|
|
101
|
+
_extends$1 = Object.assign || function(target) {
|
|
102
|
+
for(var i = 1; i < arguments.length; i++){
|
|
103
|
+
var source = arguments[i];
|
|
104
|
+
for(var key in source){
|
|
105
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
106
|
+
target[key] = source[key];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return target;
|
|
111
|
+
};
|
|
112
|
+
return _extends$1.apply(this, arguments);
|
|
113
|
+
}
|
|
114
|
+
function _object_without_properties_loose(source, excluded) {
|
|
115
|
+
if (source == null) return {};
|
|
116
|
+
var target = {};
|
|
117
|
+
var sourceKeys = Object.keys(source);
|
|
118
|
+
var key, i;
|
|
119
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
120
|
+
key = sourceKeys[i];
|
|
121
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
122
|
+
target[key] = source[key];
|
|
123
|
+
}
|
|
124
|
+
return target;
|
|
125
|
+
}
|
|
90
126
|
const nativeGlobal = (()=>{
|
|
91
127
|
try {
|
|
92
128
|
return new Function('return this')();
|
|
@@ -174,7 +210,7 @@ function getGlobalFederationConstructor() {
|
|
|
174
210
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
175
211
|
if (isDebug) {
|
|
176
212
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
177
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.
|
|
213
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.2";
|
|
178
214
|
}
|
|
179
215
|
}
|
|
180
216
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -222,7 +258,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
|
|
|
222
258
|
}
|
|
223
259
|
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
|
|
224
260
|
if ('version' in moduleInfo && moduleInfo['version']) {
|
|
225
|
-
const { version } = moduleInfo, resModuleInfo =
|
|
261
|
+
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
|
|
226
262
|
"version"
|
|
227
263
|
]);
|
|
228
264
|
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
@@ -240,7 +276,7 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
|
|
|
240
276
|
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
241
277
|
};
|
|
242
278
|
const addGlobalSnapshot = (moduleInfos)=>{
|
|
243
|
-
nativeGlobal.__FEDERATION__.moduleInfo =
|
|
279
|
+
nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
244
280
|
return ()=>{
|
|
245
281
|
const keys = Object.keys(moduleInfos);
|
|
246
282
|
for (const key of keys){
|
|
@@ -633,6 +669,20 @@ function satisfy(version, range) {
|
|
|
633
669
|
return true;
|
|
634
670
|
}
|
|
635
671
|
|
|
672
|
+
function _extends() {
|
|
673
|
+
_extends = Object.assign || function(target) {
|
|
674
|
+
for(var i = 1; i < arguments.length; i++){
|
|
675
|
+
var source = arguments[i];
|
|
676
|
+
for(var key in source){
|
|
677
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
678
|
+
target[key] = source[key];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return target;
|
|
683
|
+
};
|
|
684
|
+
return _extends.apply(this, arguments);
|
|
685
|
+
}
|
|
636
686
|
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
637
687
|
let get;
|
|
638
688
|
if ('get' in shareArgs) {
|
|
@@ -649,13 +699,13 @@ function formatShare(shareArgs, from, name, shareStrategy) {
|
|
|
649
699
|
warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
|
|
650
700
|
}
|
|
651
701
|
var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
|
|
652
|
-
return
|
|
702
|
+
return _extends({
|
|
653
703
|
deps: [],
|
|
654
704
|
useIn: [],
|
|
655
705
|
from,
|
|
656
706
|
loading: null
|
|
657
707
|
}, shareArgs, {
|
|
658
|
-
shareConfig:
|
|
708
|
+
shareConfig: _extends({
|
|
659
709
|
requiredVersion: `^${shareArgs.version}`,
|
|
660
710
|
singleton: false,
|
|
661
711
|
eager: false,
|
|
@@ -681,7 +731,7 @@ function formatShareConfigs(globalOptions, userOptions) {
|
|
|
681
731
|
});
|
|
682
732
|
return res;
|
|
683
733
|
}, {});
|
|
684
|
-
const shared =
|
|
734
|
+
const shared = _extends({}, globalOptions.shared);
|
|
685
735
|
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
686
736
|
if (!shared[shareKey]) {
|
|
687
737
|
shared[shareKey] = shareInfos[shareKey];
|
|
@@ -845,4 +895,4 @@ function getTargetSharedOptions(options) {
|
|
|
845
895
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
846
896
|
}
|
|
847
897
|
|
|
848
|
-
export {
|
|
898
|
+
export { getGlobalShareScope as A, addUniqueItem as B, getBuilderId as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationConstructor as E, getGlobalFederationInstance as F, Global as G, getGlobalFederationConstructor as H, setGlobalFederationInstance as I, registerGlobalPlugins as J, nativeGlobal as K, resetFederationGlobalInfo as L, getTargetSnapshotInfoByModuleInfo as M, globalLoading as a, DEFAULT_SCOPE as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRemoteEntryInfoFromSnapshot as l, isBrowserEnv as m, getInfoWithoutType as n, getPreloaded as o, setPreloaded as p, getRegisteredShare as q, arrayOptions as r, safeToString as s, getGlobalSnapshotInfoByModuleInfo as t, addGlobalSnapshot as u, setGlobalSnapshotInfoByModuleInfo as v, warn as w, getGlobalSnapshot as x, formatShareConfigs as y, getTargetSharedOptions as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CreateScriptHookReturn } from '@module-federation/sdk';
|
|
2
|
-
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions } from './type';
|
|
2
|
+
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
|
|
3
3
|
import { Module } from './module';
|
|
4
4
|
import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
|
|
5
5
|
import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
|
|
@@ -69,11 +69,15 @@ export declare class FederationHost {
|
|
|
69
69
|
customShareInfo?: Partial<Shared>;
|
|
70
70
|
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
71
71
|
}): () => T | never;
|
|
72
|
-
initializeSharing(shareScopeName?: string,
|
|
72
|
+
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
73
|
+
initScope?: InitScope;
|
|
74
|
+
from?: CallFrom;
|
|
75
|
+
strategy?: Shared['strategy'];
|
|
76
|
+
}): Array<Promise<void>>;
|
|
73
77
|
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module;
|
|
74
78
|
loadRemote<T>(id: string, options?: {
|
|
75
79
|
loadFactory?: boolean;
|
|
76
|
-
from:
|
|
80
|
+
from: CallFrom;
|
|
77
81
|
}): Promise<T | null>;
|
|
78
82
|
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
79
83
|
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports } from '../type';
|
|
1
|
+
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
+
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports, CallFrom } from '../type';
|
|
3
3
|
import { FederationHost } from '../core';
|
|
4
4
|
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
5
|
import { Module, ModuleOptions } from '../module';
|
|
@@ -56,7 +56,7 @@ export declare class RemoteHandler {
|
|
|
56
56
|
id: string;
|
|
57
57
|
error: unknown;
|
|
58
58
|
options?: any;
|
|
59
|
-
from:
|
|
59
|
+
from: CallFrom;
|
|
60
60
|
lifecycle: "onLoad" | "beforeRequest";
|
|
61
61
|
origin: FederationHost;
|
|
62
62
|
}], unknown>;
|
|
@@ -89,7 +89,7 @@ export declare class RemoteHandler {
|
|
|
89
89
|
setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
|
|
90
90
|
loadRemote<T>(id: string, options?: {
|
|
91
91
|
loadFactory?: boolean;
|
|
92
|
-
from:
|
|
92
|
+
from: CallFrom;
|
|
93
93
|
}): Promise<T | null>;
|
|
94
94
|
preloadRemote(preloadOptions: Array<PreloadRemoteArgs>): Promise<void>;
|
|
95
95
|
registerRemotes(remotes: Remote[], options?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Federation } from '../global';
|
|
2
|
-
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy } from '../type';
|
|
2
|
+
import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy, InitScope, InitTokens, CallFrom } from '../type';
|
|
3
3
|
import { FederationHost } from '../core';
|
|
4
4
|
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
5
|
import { LoadRemoteMatch } from '../remote';
|
|
@@ -31,6 +31,7 @@ export declare class SharedHandler {
|
|
|
31
31
|
hostShareScopeMap?: ShareScopeMap;
|
|
32
32
|
}>;
|
|
33
33
|
}>;
|
|
34
|
+
initTokens: InitTokens;
|
|
34
35
|
constructor(host: FederationHost);
|
|
35
36
|
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
36
37
|
shareInfos: ShareInfos;
|
|
@@ -47,7 +48,11 @@ export declare class SharedHandler {
|
|
|
47
48
|
* It accepts one argument, the name of the share scope.
|
|
48
49
|
* If the share scope does not exist, it creates one.
|
|
49
50
|
*/
|
|
50
|
-
initializeSharing(shareScopeName?: string,
|
|
51
|
+
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
52
|
+
initScope?: InitScope;
|
|
53
|
+
from?: CallFrom;
|
|
54
|
+
strategy?: ShareStrategy;
|
|
55
|
+
}): Array<Promise<void>>;
|
|
51
56
|
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
52
57
|
customShareInfo?: Partial<Shared>;
|
|
53
58
|
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
@@ -102,7 +102,9 @@ export type RemoteEntryInitOptions = {
|
|
|
102
102
|
version: string;
|
|
103
103
|
shareScopeMap: ShareScopeMap;
|
|
104
104
|
};
|
|
105
|
-
export type
|
|
105
|
+
export type InitTokens = Record<string, Record<string, any>>;
|
|
106
|
+
export type InitScope = InitTokens[];
|
|
107
|
+
export type CallFrom = 'build' | 'runtime';
|
|
106
108
|
export type RemoteEntryExports = {
|
|
107
109
|
get: (id: string) => () => Promise<Module>;
|
|
108
110
|
init: (shareScope: ShareScopeMap[string], initScope?: InitScope, remoteEntryInitOPtions?: RemoteEntryInitOptions) => void | Promise<void>;
|
package/dist/src/utils/env.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
2
1
|
export declare function isDevelopmentMode(): boolean;
|
|
3
2
|
export declare function getBuilderId(): string;
|
|
3
|
+
export declare function isDebugMode(): boolean;
|
|
4
|
+
export declare function isBrowserEnv(): boolean;
|
package/dist/src/utils/tool.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function getFMId(remoteInfo: RemoteInfoOptionalVersion | RemoteWi
|
|
|
5
5
|
export declare function isRemoteInfoWithEntry(remote: Remote): remote is RemoteWithEntry;
|
|
6
6
|
export declare function isPureRemoteEntry(remote: RemoteWithEntry): boolean;
|
|
7
7
|
export declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
|
|
8
|
+
export declare function safeToString(info: any): string;
|
|
8
9
|
export declare function isObject(val: any): boolean;
|
|
9
10
|
export declare const objectToString: () => string;
|
|
10
11
|
export declare function isPlainObject(val: any): val is object;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240826075118",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -34,11 +34,6 @@
|
|
|
34
34
|
"import": "./dist/retry-plugin.esm.js",
|
|
35
35
|
"require": "./dist/retry-plugin.cjs.js"
|
|
36
36
|
},
|
|
37
|
-
"./embedded": {
|
|
38
|
-
"types": "./dist/embedded.cjs.d.ts",
|
|
39
|
-
"import": "./dist/embedded.esm.js",
|
|
40
|
-
"require": "./dist/embedded.cjs.js"
|
|
41
|
-
},
|
|
42
37
|
"./*": "./*"
|
|
43
38
|
},
|
|
44
39
|
"typesVersions": {
|
|
@@ -58,6 +53,6 @@
|
|
|
58
53
|
}
|
|
59
54
|
},
|
|
60
55
|
"dependencies": {
|
|
61
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
56
|
+
"@module-federation/sdk": "0.0.0-next-20240826075118"
|
|
62
57
|
}
|
|
63
58
|
}
|
package/dist/embedded.cjs.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/embedded";
|
package/dist/embedded.cjs.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance } = __webpack_require__.federation.runtime;
|
|
6
|
-
|
|
7
|
-
exports.FederationHost = FederationHost;
|
|
8
|
-
exports.getInstance = getInstance;
|
|
9
|
-
exports.getRemoteEntry = getRemoteEntry;
|
|
10
|
-
exports.getRemoteInfo = getRemoteInfo;
|
|
11
|
-
exports.init = init;
|
|
12
|
-
exports.loadRemote = loadRemote;
|
|
13
|
-
exports.loadScript = loadScript;
|
|
14
|
-
exports.loadScriptNode = loadScriptNode;
|
|
15
|
-
exports.loadShare = loadShare;
|
|
16
|
-
exports.loadShareSync = loadShareSync;
|
|
17
|
-
exports.preloadRemote = preloadRemote;
|
|
18
|
-
exports.registerGlobalPlugins = registerGlobalPlugins;
|
|
19
|
-
exports.registerPlugins = registerPlugins;
|
|
20
|
-
exports.registerRemotes = registerRemotes;
|
package/dist/embedded.esm.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance } = __webpack_require__.federation.runtime;
|
|
2
|
-
|
|
3
|
-
export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadScript, loadScriptNode, loadShare, loadShareSync, preloadRemote, registerGlobalPlugins, registerPlugins, registerRemotes };
|
package/dist/src/embedded.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
declare const FederationHost: any, registerGlobalPlugins: any, getRemoteEntry: any, getRemoteInfo: any, loadScript: any, loadScriptNode: any, init: any, loadRemote: any, loadShare: any, loadShareSync: any, preloadRemote: any, registerRemotes: any, registerPlugins: any, getInstance: any;
|
|
2
|
-
export { FederationHost, registerGlobalPlugins, getRemoteEntry, getRemoteInfo, loadScript, loadScriptNode, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes, registerPlugins, getInstance, };
|