@module-federation/sdk 2.9.2 → 2.9.4
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/constant.d.cts +46 -0
- package/dist/createModuleFederationConfig.d.cts +6 -0
- package/dist/dom.d.cts +33 -0
- package/dist/env.d.cts +12 -0
- package/dist/generateSnapshotFromManifest.d.cts +20 -0
- package/dist/index.d.cts +21 -0
- package/dist/logger.d.cts +34 -0
- package/dist/node.d.cts +15 -0
- package/dist/normalize-webpack-path.cjs +103 -4
- package/dist/normalize-webpack-path.cjs.map +1 -1
- package/dist/normalize-webpack-path.d.cts +10 -0
- package/dist/normalize-webpack-path.js +104 -5
- package/dist/normalize-webpack-path.js.map +1 -1
- package/dist/normalizeOptions.d.cts +5 -0
- package/dist/types/common.d.cts +14 -0
- package/dist/types/hooks.d.cts +21 -0
- package/dist/types/index.d.cts +11 -0
- package/dist/types/manifest.d.cts +34 -0
- package/dist/types/plugins/ConsumeSharedPlugin.d.cts +109 -0
- package/dist/types/plugins/ContainerPlugin.d.cts +38 -0
- package/dist/types/plugins/ContainerReferencePlugin.d.cts +24 -0
- package/dist/types/plugins/ModuleFederationPlugin.d.cts +470 -0
- package/dist/types/plugins/ProvideSharedPlugin.d.cts +97 -0
- package/dist/types/plugins/SharePlugin.d.cts +26 -0
- package/dist/types/plugins/index.d.cts +6 -0
- package/dist/types/snapshot.d.cts +78 -0
- package/dist/types/stats.d.cts +101 -0
- package/dist/utils.d.cts +28 -0
- package/package.json +4 -4
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { IncludeExcludeOptions } from "./ConsumeSharedPlugin.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/plugins/ProvideSharedPlugin.d.ts
|
|
4
|
+
declare namespace ProvideSharedPlugin_d_exports {
|
|
5
|
+
export { ProvideSharedPluginOptions, Provides, ProvidesConfig, ProvidesItem, ProvidesObject };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Request to a module that should be provided as shared module to the share scope (will be resolved when relative).
|
|
9
|
+
*/
|
|
10
|
+
type ProvidesItem = string;
|
|
11
|
+
/**
|
|
12
|
+
* Advanced configuration for modules that should be provided as shared modules to the share scope.
|
|
13
|
+
*/
|
|
14
|
+
interface ProvidesConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Include the provided module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
|
|
17
|
+
*/
|
|
18
|
+
eager?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Key in the share scope under which the shared modules should be stored.
|
|
21
|
+
*/
|
|
22
|
+
shareKey?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Import request to match on
|
|
25
|
+
*/
|
|
26
|
+
request?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Share scope name.
|
|
29
|
+
*/
|
|
30
|
+
shareScope?: string | string[];
|
|
31
|
+
/**
|
|
32
|
+
* Version requirement from module in share scope.
|
|
33
|
+
*/
|
|
34
|
+
requiredVersion?: false | string;
|
|
35
|
+
/**
|
|
36
|
+
* Do not accept shared module if version is not valid (defaults to yes, if local fallback module is available and shared module is not a singleton, otherwise no, has no effect if there is no required version specified).
|
|
37
|
+
*/
|
|
38
|
+
strictVersion?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Allow only a single version of the shared module in share scope (disabled by default).
|
|
41
|
+
*/
|
|
42
|
+
singleton?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Layer in which the shared module should be placed.
|
|
45
|
+
*/
|
|
46
|
+
layer?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Layer of the issuer.
|
|
49
|
+
*/
|
|
50
|
+
issuerLayer?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Version of the provided module. Will replace lower matching versions, but not higher.
|
|
53
|
+
*/
|
|
54
|
+
version?: false | string;
|
|
55
|
+
/**
|
|
56
|
+
* Filter for the shared module.
|
|
57
|
+
*/
|
|
58
|
+
exclude?: IncludeExcludeOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Options for including only certain versions or requests of the provided module. Cannot be used with 'exclude'.
|
|
61
|
+
*/
|
|
62
|
+
include?: IncludeExcludeOptions;
|
|
63
|
+
/**
|
|
64
|
+
* Enable reconstructed lookup for node_modules paths for this share item
|
|
65
|
+
*/
|
|
66
|
+
allowNodeModulesSuffixMatch?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Tree shaking mode for the shared module.
|
|
69
|
+
*/
|
|
70
|
+
treeShakingMode?: 'server-calc' | 'runtime-infer';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Modules that should be provided as shared modules to the share scope. Property names are used as share keys.
|
|
74
|
+
*/
|
|
75
|
+
interface ProvidesObject {
|
|
76
|
+
[k: string]: ProvidesConfig | ProvidesItem;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Modules that should be provided as shared modules to the share scope. When provided, property name is used to match modules, otherwise this is automatically inferred from share key.
|
|
80
|
+
*/
|
|
81
|
+
type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject;
|
|
82
|
+
interface ProvideSharedPluginOptions {
|
|
83
|
+
provides: Provides;
|
|
84
|
+
/**
|
|
85
|
+
* Share scope name used for all provided modules (defaults to 'default').
|
|
86
|
+
*/
|
|
87
|
+
shareScope?: string | string[];
|
|
88
|
+
/**
|
|
89
|
+
* Experimental features configuration
|
|
90
|
+
*/
|
|
91
|
+
experiments?: {
|
|
92
|
+
/** Enable reconstructed lookup for node_modules paths */allowNodeModulesSuffixMatch?: boolean;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { ProvideSharedPlugin_d_exports };
|
|
97
|
+
//# sourceMappingURL=ProvideSharedPlugin.d.cts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Shared } from "./ModuleFederationPlugin.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/plugins/SharePlugin.d.ts
|
|
4
|
+
declare namespace SharePlugin_d_exports {
|
|
5
|
+
export { SharePluginOptions };
|
|
6
|
+
}
|
|
7
|
+
interface SharePluginOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.
|
|
10
|
+
*/
|
|
11
|
+
async?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Share scope name used for all shared modules (defaults to 'default').
|
|
14
|
+
*/
|
|
15
|
+
shareScope?: string | string[];
|
|
16
|
+
shared: Shared;
|
|
17
|
+
/**
|
|
18
|
+
* Experimental features configuration
|
|
19
|
+
*/
|
|
20
|
+
experiments?: {
|
|
21
|
+
/** Enable reconstructed lookup for node_modules paths */allowNodeModulesSuffixMatch?: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { SharePlugin_d_exports };
|
|
26
|
+
//# sourceMappingURL=SharePlugin.d.cts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModuleFederationPlugin_d_exports } from "./ModuleFederationPlugin.cjs";
|
|
2
|
+
import { ContainerPlugin_d_exports } from "./ContainerPlugin.cjs";
|
|
3
|
+
import { ContainerReferencePlugin_d_exports } from "./ContainerReferencePlugin.cjs";
|
|
4
|
+
import { SharePlugin_d_exports } from "./SharePlugin.cjs";
|
|
5
|
+
import { ConsumeSharedPlugin_d_exports } from "./ConsumeSharedPlugin.cjs";
|
|
6
|
+
import { ProvideSharedPlugin_d_exports } from "./ProvideSharedPlugin.cjs";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TreeShakingStatus } from "../constant.cjs";
|
|
2
|
+
import { RemoteEntryType, StatsAssets } from "./stats.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/types/snapshot.d.ts
|
|
5
|
+
interface BasicModuleInfo {
|
|
6
|
+
dev?: {
|
|
7
|
+
version?: string;
|
|
8
|
+
remotes?: {
|
|
9
|
+
[nameWithType: string]: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
version: string;
|
|
13
|
+
buildVersion: string;
|
|
14
|
+
remoteTypes: string;
|
|
15
|
+
remoteTypesZip: string;
|
|
16
|
+
remoteTypesAPI?: string;
|
|
17
|
+
remotesInfo: Record<string, {
|
|
18
|
+
matchedVersion: string;
|
|
19
|
+
}>;
|
|
20
|
+
shared: Array<{
|
|
21
|
+
sharedName: string;
|
|
22
|
+
fallback?: string;
|
|
23
|
+
fallbackName?: string;
|
|
24
|
+
fallbackType?: RemoteEntryType;
|
|
25
|
+
version?: string;
|
|
26
|
+
assets: StatsAssets;
|
|
27
|
+
treeShakingStatus?: TreeShakingStatus;
|
|
28
|
+
secondarySharedTreeShakingEntry?: string;
|
|
29
|
+
secondarySharedTreeShakingName?: string;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
interface BasicProviderModuleInfo extends BasicModuleInfo {
|
|
33
|
+
remoteEntry: string;
|
|
34
|
+
remoteEntryType: RemoteEntryType;
|
|
35
|
+
ssrRemoteEntry?: string;
|
|
36
|
+
ssrRemoteEntryType?: RemoteEntryType;
|
|
37
|
+
globalName: string;
|
|
38
|
+
modules: Array<{
|
|
39
|
+
moduleName: string;
|
|
40
|
+
modulePath?: string;
|
|
41
|
+
assets: StatsAssets;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
interface BasicProviderModuleInfoWithPublicPath extends BasicProviderModuleInfo {
|
|
45
|
+
publicPath: string;
|
|
46
|
+
ssrPublicPath?: string;
|
|
47
|
+
}
|
|
48
|
+
interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleInfo {
|
|
49
|
+
getPublicPath: string;
|
|
50
|
+
}
|
|
51
|
+
interface ManifestProvider {
|
|
52
|
+
remoteEntry: string;
|
|
53
|
+
ssrRemoteEntry?: string;
|
|
54
|
+
version?: string;
|
|
55
|
+
}
|
|
56
|
+
interface PureEntryProvider extends ManifestProvider {
|
|
57
|
+
globalName: string;
|
|
58
|
+
}
|
|
59
|
+
interface BasicConsumerModuleInfo extends BasicModuleInfo {
|
|
60
|
+
consumerList: Array<string>;
|
|
61
|
+
}
|
|
62
|
+
interface ConsumerModuleInfoWithPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
|
|
63
|
+
publicPath: string;
|
|
64
|
+
ssrPublicPath?: string;
|
|
65
|
+
}
|
|
66
|
+
interface ConsumerModuleInfoWithGetPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
|
|
67
|
+
getPublicPath: string;
|
|
68
|
+
}
|
|
69
|
+
type PureConsumerModuleInfo = Omit<BasicConsumerModuleInfo, 'remoteTypes'>;
|
|
70
|
+
type ConsumerModuleInfo = ConsumerModuleInfoWithPublicPath | ConsumerModuleInfoWithGetPublicPath;
|
|
71
|
+
type ProviderModuleInfo = BasicProviderModuleInfoWithPublicPath | BasicProviderModuleInfoWithGetPublicPath;
|
|
72
|
+
type ModuleInfo = ConsumerModuleInfo | PureConsumerModuleInfo | ProviderModuleInfo;
|
|
73
|
+
type GlobalModuleInfo = {
|
|
74
|
+
[key: string]: ModuleInfo | ManifestProvider | PureEntryProvider | undefined;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider };
|
|
78
|
+
//# sourceMappingURL=snapshot.d.cts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { RemoteWithEntry, RemoteWithVersion } from "./common.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types/stats.d.ts
|
|
4
|
+
type RemoteEntryType = 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | string;
|
|
5
|
+
interface ResourceInfo {
|
|
6
|
+
path: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: RemoteEntryType;
|
|
9
|
+
}
|
|
10
|
+
interface StatsBuildInfo {
|
|
11
|
+
buildVersion: string;
|
|
12
|
+
buildName: string;
|
|
13
|
+
hash?: string;
|
|
14
|
+
target?: string[];
|
|
15
|
+
plugins?: string[];
|
|
16
|
+
excludePlugins?: string[];
|
|
17
|
+
}
|
|
18
|
+
interface MetaDataTypes {
|
|
19
|
+
path: string;
|
|
20
|
+
name: string;
|
|
21
|
+
api: string;
|
|
22
|
+
zip: string;
|
|
23
|
+
}
|
|
24
|
+
interface BasicStatsMetaData {
|
|
25
|
+
name: string;
|
|
26
|
+
globalName: string;
|
|
27
|
+
buildInfo: StatsBuildInfo;
|
|
28
|
+
remoteEntry: ResourceInfo;
|
|
29
|
+
ssrRemoteEntry?: ResourceInfo;
|
|
30
|
+
types?: MetaDataTypes;
|
|
31
|
+
type: string;
|
|
32
|
+
pluginVersion?: string;
|
|
33
|
+
}
|
|
34
|
+
type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & {
|
|
35
|
+
getPublicPath: string;
|
|
36
|
+
};
|
|
37
|
+
type StatsMetaDataWithPublicPath<T = BasicStatsMetaData> = T & {
|
|
38
|
+
publicPath: string;
|
|
39
|
+
ssrPublicPath?: string;
|
|
40
|
+
};
|
|
41
|
+
type StatsMetaData<T = BasicStatsMetaData> = StatsMetaDataWithGetPublicPath<T> | StatsMetaDataWithPublicPath<T>;
|
|
42
|
+
interface StatsAssets {
|
|
43
|
+
js: StatsAssetsInfo;
|
|
44
|
+
css: StatsAssetsInfo;
|
|
45
|
+
}
|
|
46
|
+
interface StatsAssetsInfo {
|
|
47
|
+
sync: string[];
|
|
48
|
+
async: string[];
|
|
49
|
+
}
|
|
50
|
+
interface StatsShared {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
version: string;
|
|
54
|
+
singleton: boolean;
|
|
55
|
+
requiredVersion: string;
|
|
56
|
+
hash: string;
|
|
57
|
+
assets: StatsAssets;
|
|
58
|
+
deps: string[];
|
|
59
|
+
usedIn: string[];
|
|
60
|
+
usedExports: string[];
|
|
61
|
+
fallback: string;
|
|
62
|
+
fallbackName: string;
|
|
63
|
+
fallbackType: RemoteEntryType;
|
|
64
|
+
}
|
|
65
|
+
interface StatsRemoteVal {
|
|
66
|
+
moduleName: string;
|
|
67
|
+
federationContainerName: string;
|
|
68
|
+
consumingFederationContainerName: string;
|
|
69
|
+
alias: string;
|
|
70
|
+
usedIn: string[];
|
|
71
|
+
}
|
|
72
|
+
type StatsRemoteWithEntry<T = StatsRemoteVal> = T & Omit<RemoteWithEntry, 'name'>;
|
|
73
|
+
type StatsRemoteWithVersion<T = StatsRemoteVal> = T & Omit<RemoteWithVersion, 'name'>;
|
|
74
|
+
type StatsRemote<T = StatsRemoteVal> = StatsRemoteWithEntry<T> | StatsRemoteWithVersion<T>;
|
|
75
|
+
interface StatsModuleInfo {
|
|
76
|
+
name: string;
|
|
77
|
+
file: string[];
|
|
78
|
+
}
|
|
79
|
+
interface ManifestModuleInfos {
|
|
80
|
+
[exposeModuleName: string]: StatsModuleInfo;
|
|
81
|
+
}
|
|
82
|
+
interface StatsExpose {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
path?: string;
|
|
86
|
+
file: string;
|
|
87
|
+
requires: string[];
|
|
88
|
+
assets: StatsAssets;
|
|
89
|
+
hash?: string;
|
|
90
|
+
}
|
|
91
|
+
interface Stats<T = BasicStatsMetaData, K = StatsRemoteVal> {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
metaData: StatsMetaData<T>;
|
|
95
|
+
shared: StatsShared[];
|
|
96
|
+
remotes: StatsRemote<K>[];
|
|
97
|
+
exposes: StatsExpose[];
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared };
|
|
101
|
+
//# sourceMappingURL=stats.d.cts.map
|
package/dist/utils.d.cts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RemoteEntryInfo } from "./types/common.cjs";
|
|
2
|
+
import { ModuleInfo } from "./types/snapshot.cjs";
|
|
3
|
+
//#region src/utils.d.ts
|
|
4
|
+
declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo;
|
|
5
|
+
declare global {
|
|
6
|
+
var FEDERATION_DEBUG: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
declare const composeKeyWithSeparator: (...args: (string | undefined)[]) => string;
|
|
9
|
+
declare const encodeName: (name: string, prefix?: string, withExt?: boolean) => string;
|
|
10
|
+
declare const decodeName: (name: string, prefix?: string, withExt?: boolean) => string;
|
|
11
|
+
declare const generateExposeFilename: (exposeName: string, withExt: boolean) => string;
|
|
12
|
+
declare const generateShareFilename: (pkgName: string, withExt: boolean) => string;
|
|
13
|
+
type ResourceUrlInfo = {
|
|
14
|
+
getPublicPath: string;
|
|
15
|
+
} | {
|
|
16
|
+
publicPath: string;
|
|
17
|
+
ssrPublicPath?: string;
|
|
18
|
+
};
|
|
19
|
+
declare function getResourceUrl(module: ModuleInfo, sourceUrl: string): string;
|
|
20
|
+
declare function getResourceUrl(module: ResourceUrlInfo, sourceUrl: string): string;
|
|
21
|
+
declare const assert: (condition: any, msg: string) => asserts condition;
|
|
22
|
+
declare const error: (msg: string | Error | unknown) => never;
|
|
23
|
+
declare const warn: (msg: Parameters<typeof console.warn>[0]) => void;
|
|
24
|
+
declare function safeToString(info: any): string;
|
|
25
|
+
declare function isRequiredVersion(str: string): boolean;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn };
|
|
28
|
+
//# sourceMappingURL=utils.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/sdk",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A sdk for support module federation",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"default": "./dist/index.js"
|
|
37
37
|
},
|
|
38
38
|
"require": {
|
|
39
|
-
"types": "./dist/index.d.
|
|
39
|
+
"types": "./dist/index.d.cts",
|
|
40
40
|
"default": "./dist/index.cjs"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"default": "./dist/normalize-webpack-path.js"
|
|
47
47
|
},
|
|
48
48
|
"require": {
|
|
49
|
-
"types": "./dist/normalize-webpack-path.d.
|
|
49
|
+
"types": "./dist/normalize-webpack-path.d.cts",
|
|
50
50
|
"default": "./dist/normalize-webpack-path.cjs"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@jest/globals": "29.7.0",
|
|
66
|
-
"webpack": "
|
|
66
|
+
"webpack": "5.112.2"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsdown --config tsdown.config.ts",
|