@module-federation/dts-plugin 2.8.2 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @module-federation/dts-plugin
|
|
2
2
|
|
|
3
|
+
## 2.9.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @module-federation/sdk@2.9.0
|
|
8
|
+
- @module-federation/managers@2.9.0
|
|
9
|
+
- @module-federation/third-party-dts-extractor@2.9.0
|
|
10
|
+
- @module-federation/error-codes@2.9.0
|
|
11
|
+
|
|
3
12
|
## 2.8.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -44,14 +44,13 @@ declare class AsyncWaterfallHook<T extends object> extends SyncHook<[T], Callbac
|
|
|
44
44
|
type Plugin<T extends Record<string, any>> = { [k in keyof T]?: Parameters<T[k]['on']>[0] } & {
|
|
45
45
|
name: string;
|
|
46
46
|
version?: string;
|
|
47
|
-
apply?: (instance: ModuleFederation) => void;
|
|
48
47
|
};
|
|
49
48
|
declare class PluginSystem<T extends Record<string, any>> {
|
|
50
49
|
lifecycle: T;
|
|
51
50
|
lifecycleKeys: Array<keyof T>;
|
|
52
51
|
registerPlugins: Record<string, Plugin<T>>;
|
|
53
52
|
constructor(lifecycle: T);
|
|
54
|
-
applyPlugin(plugin: Plugin<T
|
|
53
|
+
applyPlugin(plugin: Plugin<T>): void;
|
|
55
54
|
removePlugin(pluginName: string): void;
|
|
56
55
|
} //#endregion
|
|
57
56
|
//#endregion
|
|
@@ -65,6 +64,18 @@ interface RemoteInfoCommon {
|
|
|
65
64
|
entryGlobalName?: string;
|
|
66
65
|
}
|
|
67
66
|
type Remote = (RemoteWithEntry | RemoteWithVersion) & RemoteInfoCommon;
|
|
67
|
+
type LoadShareExtraOptions = {
|
|
68
|
+
from?: CallFrom;
|
|
69
|
+
customShareInfo?: Partial<Shared>;
|
|
70
|
+
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
71
|
+
context?: SharedLoadContext;
|
|
72
|
+
};
|
|
73
|
+
type SharedLoadTrigger = CallFrom | 'container-init';
|
|
74
|
+
interface SharedLoadContext {
|
|
75
|
+
trigger?: SharedLoadTrigger;
|
|
76
|
+
moduleId?: string | number;
|
|
77
|
+
chunkId?: string | number;
|
|
78
|
+
}
|
|
68
79
|
interface RemoteInfo {
|
|
69
80
|
alias?: string;
|
|
70
81
|
name: string;
|
|
@@ -177,19 +188,25 @@ interface PreloadRemoteArgs {
|
|
|
177
188
|
share?: boolean;
|
|
178
189
|
depsRemote?: boolean | Array<depsPreloadArg>;
|
|
179
190
|
filter?: (assetUrl: string) => boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Record preloaded JS and CSS URLs to skip duplicate resource loading.
|
|
193
|
+
* @default true
|
|
194
|
+
*/
|
|
195
|
+
recordPreloadedAssets?: boolean;
|
|
180
196
|
}
|
|
181
197
|
type PreloadConfig = PreloadRemoteArgs;
|
|
182
198
|
type PreloadOptions = Array<{
|
|
183
199
|
remote: Remote;
|
|
184
200
|
preloadConfig: PreloadConfig;
|
|
185
201
|
}>;
|
|
186
|
-
type ResourceLoadInitiator = 'loadRemote' | 'preloadRemote';
|
|
202
|
+
type ResourceLoadInitiator = 'loadRemote' | 'preloadRemote' | 'loadShare';
|
|
187
203
|
type ResourceLoadType = 'manifest' | 'remoteEntry' | 'js' | 'css';
|
|
188
|
-
interface ResourceLoadContext {
|
|
204
|
+
interface ResourceLoadContext$1 {
|
|
189
205
|
initiator: ResourceLoadInitiator;
|
|
190
206
|
id: string;
|
|
191
207
|
resourceType: ResourceLoadType;
|
|
192
208
|
url?: string;
|
|
209
|
+
expose?: string;
|
|
193
210
|
}
|
|
194
211
|
type PreloadAssetStatus = 'success' | 'error' | 'timeout' | 'cached';
|
|
195
212
|
interface PreloadAssetResult {
|
|
@@ -325,6 +342,7 @@ declare class RemoteHandler {
|
|
|
325
342
|
loaderHook: ModuleFederation["loaderHook"];
|
|
326
343
|
remoteInfo: RemoteInfo;
|
|
327
344
|
remoteEntryExports?: RemoteEntryExports;
|
|
345
|
+
resourceContext?: ResourceLoadContext;
|
|
328
346
|
}], void | RemoteEntryExports | Promise<void | RemoteEntryExports>>;
|
|
329
347
|
}>;
|
|
330
348
|
constructor(host: ModuleFederation);
|
|
@@ -363,12 +381,23 @@ declare class SharedHandler {
|
|
|
363
381
|
shared: Shared;
|
|
364
382
|
origin: ModuleFederation;
|
|
365
383
|
}>;
|
|
384
|
+
afterRegisterShare: SyncHook<[{
|
|
385
|
+
pkgName: string;
|
|
386
|
+
scope: string;
|
|
387
|
+
shared: Shared;
|
|
388
|
+
previousShared?: Shared;
|
|
389
|
+
registeredShared?: Shared;
|
|
390
|
+
shareScopeMap: ShareScopeMap;
|
|
391
|
+
trigger: SharedLoadTrigger;
|
|
392
|
+
origin: ModuleFederation;
|
|
393
|
+
}], void>;
|
|
366
394
|
afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
|
|
367
395
|
beforeLoadShare: AsyncWaterfallHook<{
|
|
368
396
|
pkgName: string;
|
|
369
397
|
shareInfo?: Shared;
|
|
370
398
|
shared: Options["shared"];
|
|
371
399
|
origin: ModuleFederation;
|
|
400
|
+
loadContext?: SharedLoadContext;
|
|
372
401
|
}>;
|
|
373
402
|
loadShare: AsyncHook<[ModuleFederation, string, ShareInfos], false | void | Promise<false | void>>;
|
|
374
403
|
afterLoadShare: SyncHook<[{
|
|
@@ -378,6 +407,7 @@ declare class SharedHandler {
|
|
|
378
407
|
shared: Options["shared"];
|
|
379
408
|
shareScopeMap: ShareScopeMap;
|
|
380
409
|
lifecycle: "loadShare" | "loadShareSync";
|
|
410
|
+
loadContext?: SharedLoadContext;
|
|
381
411
|
origin: ModuleFederation;
|
|
382
412
|
}], void>;
|
|
383
413
|
errorLoadShare: SyncHook<[{
|
|
@@ -389,6 +419,7 @@ declare class SharedHandler {
|
|
|
389
419
|
origin: ModuleFederation;
|
|
390
420
|
error?: unknown;
|
|
391
421
|
recovered?: boolean;
|
|
422
|
+
loadContext?: SharedLoadContext;
|
|
392
423
|
}], void>;
|
|
393
424
|
resolveShare: SyncWaterfallHook<{
|
|
394
425
|
shareScopeMap: ShareScopeMap;
|
|
@@ -401,6 +432,7 @@ declare class SharedHandler {
|
|
|
401
432
|
shared: Shared;
|
|
402
433
|
useTreesShaking: boolean;
|
|
403
434
|
} | undefined;
|
|
435
|
+
loadContext?: SharedLoadContext;
|
|
404
436
|
}>;
|
|
405
437
|
initContainerShareScopeMap: SyncWaterfallHook<{
|
|
406
438
|
shareScope: ShareScopeMap[string];
|
|
@@ -412,6 +444,7 @@ declare class SharedHandler {
|
|
|
412
444
|
}>;
|
|
413
445
|
initTokens: InitTokens;
|
|
414
446
|
constructor(host: ModuleFederation);
|
|
447
|
+
private emitAfterRegisterShare;
|
|
415
448
|
private emitAfterLoadShare;
|
|
416
449
|
private emitErrorLoadShare;
|
|
417
450
|
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
@@ -420,10 +453,7 @@ declare class SharedHandler {
|
|
|
420
453
|
[pkgName: string]: Shared[];
|
|
421
454
|
};
|
|
422
455
|
};
|
|
423
|
-
loadShare<T>(pkgName: string, extraOptions?:
|
|
424
|
-
customShareInfo?: Partial<Shared>;
|
|
425
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
426
|
-
}): Promise<false | (() => T | undefined)>;
|
|
456
|
+
loadShare<T>(pkgName: string, extraOptions?: LoadShareExtraOptions): Promise<false | (() => T | undefined)>;
|
|
427
457
|
/**
|
|
428
458
|
* This function initializes the sharing sequence (executed only once per share scope).
|
|
429
459
|
* It accepts one argument, the name of the share scope.
|
|
@@ -433,12 +463,9 @@ declare class SharedHandler {
|
|
|
433
463
|
initScope?: InitScope;
|
|
434
464
|
from?: CallFrom;
|
|
435
465
|
strategy?: ShareStrategy;
|
|
466
|
+
context?: SharedLoadContext;
|
|
436
467
|
}): Array<Promise<void>>;
|
|
437
|
-
loadShareSync<T>(pkgName: string, extraOptions?:
|
|
438
|
-
from?: 'build' | 'runtime';
|
|
439
|
-
customShareInfo?: Partial<Shared>;
|
|
440
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
441
|
-
}): () => T | never;
|
|
468
|
+
loadShareSync<T>(pkgName: string, extraOptions?: LoadShareExtraOptions): () => T | never;
|
|
442
469
|
initShareScopeMap(scopeName: string, shareScope: ShareScopeMap[string], extraOptions?: {
|
|
443
470
|
hostShareScopeMap?: ShareScopeMap;
|
|
444
471
|
}): void;
|
|
@@ -460,10 +487,11 @@ type SharedLifeCycle = SharedHandler['hooks']['lifecycle'];
|
|
|
460
487
|
type SharedLifeCycleCyclePartial = Partial<{ [k in keyof SharedLifeCycle]: Parameters<SharedLifeCycle[k]['on']>[0] }>;
|
|
461
488
|
type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
|
|
462
489
|
type RemoteLifeCycleCyclePartial = Partial<{ [k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0] }>;
|
|
463
|
-
type
|
|
490
|
+
type RuntimePluginHooks = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial;
|
|
491
|
+
type ModuleFederationRuntimePlugin = RuntimePluginHooks & {
|
|
464
492
|
name: string;
|
|
465
493
|
version?: string;
|
|
466
|
-
apply?: (instance: ModuleFederation) => void;
|
|
494
|
+
apply?: (instance: ModuleFederation) => void | RuntimePluginHooks;
|
|
467
495
|
}; //#endregion
|
|
468
496
|
//#endregion
|
|
469
497
|
//#region ../runtime-core/dist/global.d.ts
|
|
@@ -477,6 +505,7 @@ interface Federation {
|
|
|
477
505
|
__SHARE__: GlobalShareScopeMap;
|
|
478
506
|
__MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
|
|
479
507
|
__PRELOADED_MAP__: Map<string, boolean>;
|
|
508
|
+
__PRELOADED_ASSETS__: Set<string>;
|
|
480
509
|
}
|
|
481
510
|
declare global {
|
|
482
511
|
var __FEDERATION__: Federation, __VMOK__: Federation, __GLOBAL_LOADING_REMOTE_ENTRY__: Record<string, undefined | Promise<RemoteEntryExports | void>>;
|
|
@@ -517,6 +546,29 @@ declare class SnapshotHandler {
|
|
|
517
546
|
moduleInfo: Remote;
|
|
518
547
|
remoteSnapshot: ModuleInfo;
|
|
519
548
|
}>;
|
|
549
|
+
beforeLoadManifest: AsyncHook<[{
|
|
550
|
+
manifestUrl: string;
|
|
551
|
+
moduleInfo: Remote;
|
|
552
|
+
resourceOptions?: {
|
|
553
|
+
initiator: ResourceLoadInitiator;
|
|
554
|
+
id: string;
|
|
555
|
+
};
|
|
556
|
+
origin: ModuleFederation;
|
|
557
|
+
}], void>;
|
|
558
|
+
afterLoadManifest: AsyncHook<[{
|
|
559
|
+
manifestUrl: string;
|
|
560
|
+
moduleInfo: Remote;
|
|
561
|
+
resourceOptions?: {
|
|
562
|
+
initiator: ResourceLoadInitiator;
|
|
563
|
+
id: string;
|
|
564
|
+
};
|
|
565
|
+
manifestJson?: Manifest;
|
|
566
|
+
response?: Response;
|
|
567
|
+
error?: unknown;
|
|
568
|
+
cached?: boolean;
|
|
569
|
+
recovered?: boolean;
|
|
570
|
+
origin: ModuleFederation;
|
|
571
|
+
}], void>;
|
|
520
572
|
}>;
|
|
521
573
|
loaderHook: ModuleFederation['loaderHook'];
|
|
522
574
|
manifestLoading: Record<string, Promise<ModuleInfo>>;
|
|
@@ -550,11 +602,16 @@ declare function getRemoteEntry(params: {
|
|
|
550
602
|
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
551
603
|
getEntryUrl?: (url: string) => string;
|
|
552
604
|
_inErrorHandling?: boolean;
|
|
553
|
-
resourceContext?: ResourceLoadContext;
|
|
605
|
+
resourceContext?: ResourceLoadContext$1;
|
|
554
606
|
}): Promise<RemoteEntryExports | false | void>;
|
|
555
607
|
//#endregion
|
|
556
608
|
//#region ../runtime-core/dist/core.d.ts
|
|
557
609
|
//#region src/core.d.ts
|
|
610
|
+
type BridgeHookContext = object;
|
|
611
|
+
type BridgeHookResult = {
|
|
612
|
+
context: BridgeHookContext;
|
|
613
|
+
result?: unknown;
|
|
614
|
+
};
|
|
558
615
|
declare class ModuleFederation {
|
|
559
616
|
options: Options;
|
|
560
617
|
hooks: PluginSystem<{
|
|
@@ -613,7 +670,7 @@ declare class ModuleFederation {
|
|
|
613
670
|
* (e.g. preloadRemote / loading remoteEntry).
|
|
614
671
|
*/
|
|
615
672
|
remoteInfo?: RemoteInfo;
|
|
616
|
-
resourceContext?: ResourceLoadContext;
|
|
673
|
+
resourceContext?: ResourceLoadContext$1;
|
|
617
674
|
}], CreateScriptHookReturn>;
|
|
618
675
|
createLink: SyncHook<[{
|
|
619
676
|
url: string;
|
|
@@ -624,9 +681,9 @@ declare class ModuleFederation {
|
|
|
624
681
|
* (e.g. preloadRemote / loading remoteEntry).
|
|
625
682
|
*/
|
|
626
683
|
remoteInfo?: RemoteInfo;
|
|
627
|
-
resourceContext?: ResourceLoadContext;
|
|
684
|
+
resourceContext?: ResourceLoadContext$1;
|
|
628
685
|
}], CreateLinkHookReturnDom>;
|
|
629
|
-
fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?, (ResourceLoadContext | undefined)?], false | void | Promise<Response>>;
|
|
686
|
+
fetch: AsyncHook<[string, RequestInit, (RemoteInfo | undefined)?, (ResourceLoadContext$1 | undefined)?], false | void | Promise<Response>>;
|
|
630
687
|
loadEntryError: AsyncHook<[{
|
|
631
688
|
getRemoteEntry: typeof getRemoteEntry;
|
|
632
689
|
origin: ModuleFederation;
|
|
@@ -639,6 +696,8 @@ declare class ModuleFederation {
|
|
|
639
696
|
origin: ModuleFederation;
|
|
640
697
|
remoteInfo: RemoteInfo;
|
|
641
698
|
remoteEntryExports?: false | void | RemoteEntryExports | undefined;
|
|
699
|
+
resourceContext?: ResourceLoadContext$1;
|
|
700
|
+
cached?: boolean;
|
|
642
701
|
error?: unknown;
|
|
643
702
|
recovered?: boolean;
|
|
644
703
|
}], void>;
|
|
@@ -696,27 +755,22 @@ declare class ModuleFederation {
|
|
|
696
755
|
}], RemoteModuleFactory | Promise<RemoteModuleFactory | undefined> | undefined>;
|
|
697
756
|
}>;
|
|
698
757
|
bridgeHook: PluginSystem<{
|
|
699
|
-
beforeBridgeRender: SyncHook<[Record<string, any
|
|
700
|
-
afterBridgeRender: SyncHook<[Record<string, any
|
|
701
|
-
beforeBridgeDestroy: SyncHook<[Record<string, any
|
|
702
|
-
afterBridgeDestroy: SyncHook<[Record<string, any
|
|
758
|
+
beforeBridgeRender: SyncHook<[Record<string, any>, (object | undefined)?], void | Record<string, any>>;
|
|
759
|
+
afterBridgeRender: SyncHook<[Record<string, any>, (BridgeHookResult | undefined)?], void | Record<string, any>>;
|
|
760
|
+
beforeBridgeDestroy: SyncHook<[Record<string, any>, (object | undefined)?], void | Record<string, any>>;
|
|
761
|
+
afterBridgeDestroy: SyncHook<[Record<string, any>, (BridgeHookResult | undefined)?], void | Record<string, any>>;
|
|
762
|
+
afterBridgeRouteSync: SyncHook<[BridgeHookResult], void>;
|
|
703
763
|
}>;
|
|
704
764
|
moduleInfo?: GlobalModuleInfo[string];
|
|
705
765
|
constructor(userOptions: UserOptions);
|
|
706
766
|
initOptions(userOptions: UserOptions): Options;
|
|
707
|
-
loadShare<T>(pkgName: string, extraOptions?:
|
|
708
|
-
|
|
709
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
710
|
-
}): Promise<false | (() => T | undefined)>;
|
|
711
|
-
loadShareSync<T>(pkgName: string, extraOptions?: {
|
|
712
|
-
customShareInfo?: Partial<Shared>;
|
|
713
|
-
from?: 'build' | 'runtime';
|
|
714
|
-
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
715
|
-
}): () => T | never;
|
|
767
|
+
loadShare<T>(pkgName: string, extraOptions?: LoadShareExtraOptions): Promise<false | (() => T | undefined)>;
|
|
768
|
+
loadShareSync<T>(pkgName: string, extraOptions?: LoadShareExtraOptions): () => T | never;
|
|
716
769
|
initializeSharing(shareScopeName?: string, extraOptions?: {
|
|
717
770
|
initScope?: InitScope;
|
|
718
771
|
from?: CallFrom;
|
|
719
772
|
strategy?: Shared['strategy'];
|
|
773
|
+
context?: SharedLoadContext;
|
|
720
774
|
}): Array<Promise<void>>;
|
|
721
775
|
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module$1;
|
|
722
776
|
loadRemote<T>(id: string, options?: {
|
|
@@ -754,8 +808,8 @@ declare class Module$1 {
|
|
|
754
808
|
remoteInfo: RemoteInfo;
|
|
755
809
|
host: ModuleFederation;
|
|
756
810
|
});
|
|
757
|
-
getEntry(expose?: string): Promise<RemoteEntryExports>;
|
|
758
|
-
init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope, expose?: string): Promise<RemoteEntryExports>;
|
|
811
|
+
getEntry(expose?: string, resourceContext?: ResourceLoadContext$1): Promise<RemoteEntryExports>;
|
|
812
|
+
init(id?: string, remoteSnapshot?: ModuleInfo, rawInitScope?: InitScope, expose?: string, resourceContext?: ResourceLoadContext$1): Promise<RemoteEntryExports>;
|
|
759
813
|
get(id: string, expose: string, options?: {
|
|
760
814
|
loadFactory?: boolean;
|
|
761
815
|
}, remoteSnapshot?: ModuleInfo): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/dts-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"author": "hanric <hanric.zhang@gmail.com>",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"isomorphic-ws": "5.0.0",
|
|
70
70
|
"undici": "7.29.0",
|
|
71
71
|
"ws": "8.21.0",
|
|
72
|
-
"@module-federation/error-codes": "2.
|
|
73
|
-
"@module-federation/managers": "2.
|
|
74
|
-
"@module-federation/sdk": "2.
|
|
75
|
-
"@module-federation/third-party-dts-extractor": "2.
|
|
72
|
+
"@module-federation/error-codes": "2.9.0",
|
|
73
|
+
"@module-federation/managers": "2.9.0",
|
|
74
|
+
"@module-federation/sdk": "2.9.0",
|
|
75
|
+
"@module-federation/third-party-dts-extractor": "2.9.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@rstest/core": "^0.10.6",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"vue": "^3.5.13",
|
|
86
86
|
"vue-tsc": "^2.2.10",
|
|
87
87
|
"webpack": "^5.104.1",
|
|
88
|
-
"@module-federation/runtime": "2.
|
|
88
|
+
"@module-federation/runtime": "2.9.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"typescript": "^4.9.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
|