@module-federation/sdk 0.11.3 → 0.12.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/{index.cjs.js → index.cjs.cjs} +12 -8
- package/dist/{index.esm.mjs → index.esm.js} +6 -2
- package/dist/{polyfills.cjs.js → polyfills.cjs.cjs} +1 -1
- package/dist/src/types/plugins/ContainerPlugin.d.ts +1 -1
- package/dist/src/types/plugins/ContainerReferencePlugin.d.ts +2 -2
- package/dist/src/types/plugins/ModuleFederationPlugin.d.ts +7 -5
- package/dist/src/types/plugins/SharePlugin.d.ts +9 -2
- package/dist/src/types/snapshot.d.ts +2 -0
- package/dist/src/types/stats.d.ts +1 -0
- package/package.json +22 -10
- /package/dist/{normalize-webpack-path.cjs.js → normalize-webpack-path.cjs.cjs} +0 -0
- /package/dist/{normalize-webpack-path.esm.mjs → normalize-webpack-path.esm.js} +0 -0
- /package/dist/{polyfills.esm.mjs → polyfills.esm.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var polyfills = require('./polyfills.cjs.
|
|
3
|
+
var polyfills = require('./polyfills.cjs.cjs');
|
|
4
4
|
|
|
5
5
|
const FederationModuleManifest = 'federation-manifest.json';
|
|
6
6
|
const MANIFEST_EXT = '.json';
|
|
@@ -202,6 +202,9 @@ const getResourceUrl = (module, sourceUrl)=>{
|
|
|
202
202
|
}
|
|
203
203
|
return `${publicPath}${sourceUrl}`;
|
|
204
204
|
} else if ('publicPath' in module) {
|
|
205
|
+
if (!isBrowserEnv() && !isReactNativeEnv() && 'ssrPublicPath' in module) {
|
|
206
|
+
return `${module.ssrPublicPath}${sourceUrl}`;
|
|
207
|
+
}
|
|
205
208
|
return `${module.publicPath}${sourceUrl}`;
|
|
206
209
|
} else {
|
|
207
210
|
console.warn('Cannot get resource URL. If in debug mode, please ignore.', module, sourceUrl);
|
|
@@ -336,23 +339,24 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
336
339
|
};
|
|
337
340
|
if ((_manifest_metaData = manifest.metaData) == null ? void 0 : _manifest_metaData.prefetchInterface) {
|
|
338
341
|
const prefetchInterface = manifest.metaData.prefetchInterface;
|
|
339
|
-
basicRemoteSnapshot = polyfills.
|
|
342
|
+
basicRemoteSnapshot = polyfills._({}, basicRemoteSnapshot, {
|
|
340
343
|
prefetchInterface
|
|
341
344
|
});
|
|
342
345
|
}
|
|
343
346
|
if ((_manifest_metaData1 = manifest.metaData) == null ? void 0 : _manifest_metaData1.prefetchEntry) {
|
|
344
347
|
const { path, name, type } = manifest.metaData.prefetchEntry;
|
|
345
|
-
basicRemoteSnapshot = polyfills.
|
|
348
|
+
basicRemoteSnapshot = polyfills._({}, basicRemoteSnapshot, {
|
|
346
349
|
prefetchEntry: simpleJoinRemoteEntry(path, name),
|
|
347
350
|
prefetchEntryType: type
|
|
348
351
|
});
|
|
349
352
|
}
|
|
350
353
|
if ('publicPath' in manifest.metaData) {
|
|
351
|
-
remoteSnapshot = polyfills.
|
|
352
|
-
publicPath: getPublicPath()
|
|
354
|
+
remoteSnapshot = polyfills._({}, basicRemoteSnapshot, {
|
|
355
|
+
publicPath: getPublicPath(),
|
|
356
|
+
ssrPublicPath: manifest.metaData.ssrPublicPath
|
|
353
357
|
});
|
|
354
358
|
} else {
|
|
355
|
-
remoteSnapshot = polyfills.
|
|
359
|
+
remoteSnapshot = polyfills._({}, basicRemoteSnapshot, {
|
|
356
360
|
getPublicPath: getPublicPath()
|
|
357
361
|
});
|
|
358
362
|
}
|
|
@@ -596,7 +600,7 @@ function loadScript(url, info) {
|
|
|
596
600
|
url,
|
|
597
601
|
cb: resolve,
|
|
598
602
|
onErrorCallback: reject,
|
|
599
|
-
attrs: polyfills.
|
|
603
|
+
attrs: polyfills._({
|
|
600
604
|
fetchpriority: 'high'
|
|
601
605
|
}, attrs),
|
|
602
606
|
createScriptHook,
|
|
@@ -753,7 +757,7 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
|
753
757
|
return defaultOptions;
|
|
754
758
|
}
|
|
755
759
|
if (options && typeof options === 'object') {
|
|
756
|
-
return polyfills.
|
|
760
|
+
return polyfills._({}, defaultOptions, options);
|
|
757
761
|
}
|
|
758
762
|
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
759
763
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as _extends } from './polyfills.esm.
|
|
1
|
+
import { _ as _extends } from './polyfills.esm.js';
|
|
2
2
|
|
|
3
3
|
const FederationModuleManifest = 'federation-manifest.json';
|
|
4
4
|
const MANIFEST_EXT = '.json';
|
|
@@ -200,6 +200,9 @@ const getResourceUrl = (module, sourceUrl)=>{
|
|
|
200
200
|
}
|
|
201
201
|
return `${publicPath}${sourceUrl}`;
|
|
202
202
|
} else if ('publicPath' in module) {
|
|
203
|
+
if (!isBrowserEnv() && !isReactNativeEnv() && 'ssrPublicPath' in module) {
|
|
204
|
+
return `${module.ssrPublicPath}${sourceUrl}`;
|
|
205
|
+
}
|
|
203
206
|
return `${module.publicPath}${sourceUrl}`;
|
|
204
207
|
} else {
|
|
205
208
|
console.warn('Cannot get resource URL. If in debug mode, please ignore.', module, sourceUrl);
|
|
@@ -347,7 +350,8 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
347
350
|
}
|
|
348
351
|
if ('publicPath' in manifest.metaData) {
|
|
349
352
|
remoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
350
|
-
publicPath: getPublicPath()
|
|
353
|
+
publicPath: getPublicPath(),
|
|
354
|
+
ssrPublicPath: manifest.metaData.ssrPublicPath
|
|
351
355
|
});
|
|
352
356
|
} else {
|
|
353
357
|
remoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
@@ -66,7 +66,7 @@ export interface ContainerPluginOptions {
|
|
|
66
66
|
/**
|
|
67
67
|
* The name of the share scope which is shared with the host (defaults to 'default').
|
|
68
68
|
*/
|
|
69
|
-
shareScope?: string;
|
|
69
|
+
shareScope?: string | string[];
|
|
70
70
|
/**
|
|
71
71
|
* Runtime plugin file paths or package name.
|
|
72
72
|
*/
|
|
@@ -26,7 +26,7 @@ export interface ContainerReferencePluginOptions {
|
|
|
26
26
|
/**
|
|
27
27
|
* The name of the share scope shared with all remotes (defaults to 'default').
|
|
28
28
|
*/
|
|
29
|
-
shareScope?: string;
|
|
29
|
+
shareScope?: string | string[];
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
|
|
@@ -48,5 +48,5 @@ export interface RemotesConfig {
|
|
|
48
48
|
/**
|
|
49
49
|
* The name of the share scope shared with this remote.
|
|
50
50
|
*/
|
|
51
|
-
shareScope?: string;
|
|
51
|
+
shareScope?: string | string[];
|
|
52
52
|
}
|
|
@@ -114,9 +114,11 @@ export interface DtsRemoteOptions {
|
|
|
114
114
|
deleteTypesFolder?: boolean;
|
|
115
115
|
additionalFilesToCompile?: string[];
|
|
116
116
|
compileInChildProcess?: boolean;
|
|
117
|
-
compilerInstance?: 'tsc' | 'vue-tsc';
|
|
117
|
+
compilerInstance?: 'tsc' | 'vue-tsc' | 'tspc' | string;
|
|
118
118
|
generateAPITypes?: boolean;
|
|
119
|
-
extractThirdParty?: boolean
|
|
119
|
+
extractThirdParty?: boolean | {
|
|
120
|
+
exclude?: Array<string | RegExp>;
|
|
121
|
+
};
|
|
120
122
|
extractRemoteTypes?: boolean;
|
|
121
123
|
abortOnError?: boolean;
|
|
122
124
|
}
|
|
@@ -165,7 +167,7 @@ export interface ModuleFederationPluginOptions {
|
|
|
165
167
|
/**
|
|
166
168
|
* Share scope name used for all shared modules (defaults to 'default').
|
|
167
169
|
*/
|
|
168
|
-
shareScope?: string;
|
|
170
|
+
shareScope?: string | string[];
|
|
169
171
|
/**
|
|
170
172
|
* load shared strategy(defaults to 'version-first').
|
|
171
173
|
*/
|
|
@@ -318,7 +320,7 @@ export interface RemotesConfig {
|
|
|
318
320
|
/**
|
|
319
321
|
* The name of the share scope shared with this remote.
|
|
320
322
|
*/
|
|
321
|
-
shareScope?: string;
|
|
323
|
+
shareScope?: string | string[];
|
|
322
324
|
}
|
|
323
325
|
/**
|
|
324
326
|
* Modules that should be shared in the share scope. Property names are used to match requested modules in this compilation. Relative requests are resolved, module requests are matched unresolved, absolute paths will match resolved requests. A trailing slash will match all requests with this prefix. In this case shareKey must also have a trailing slash.
|
|
@@ -357,7 +359,7 @@ export interface SharedConfig {
|
|
|
357
359
|
/**
|
|
358
360
|
* Share scope name.
|
|
359
361
|
*/
|
|
360
|
-
shareScope?: string;
|
|
362
|
+
shareScope?: string | string[];
|
|
361
363
|
/**
|
|
362
364
|
* load shared strategy(defaults to 'version-first').
|
|
363
365
|
*/
|
|
@@ -13,7 +13,7 @@ export interface SharePluginOptions {
|
|
|
13
13
|
/**
|
|
14
14
|
* Share scope name used for all shared modules (defaults to 'default').
|
|
15
15
|
*/
|
|
16
|
-
shareScope?: string;
|
|
16
|
+
shareScope?: string | string[];
|
|
17
17
|
/**
|
|
18
18
|
* Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
|
|
19
19
|
*/
|
|
@@ -55,7 +55,7 @@ export interface SharedConfig {
|
|
|
55
55
|
/**
|
|
56
56
|
* Share scope name.
|
|
57
57
|
*/
|
|
58
|
-
shareScope?: string;
|
|
58
|
+
shareScope?: string | string[];
|
|
59
59
|
/**
|
|
60
60
|
* Allow only a single version of the shared module in share scope (disabled by default).
|
|
61
61
|
*/
|
|
@@ -69,3 +69,10 @@ export interface SharedConfig {
|
|
|
69
69
|
*/
|
|
70
70
|
version?: false | string;
|
|
71
71
|
}
|
|
72
|
+
export declare class SharePlugin {
|
|
73
|
+
constructor(options: SharePluginOptions);
|
|
74
|
+
/**
|
|
75
|
+
* Apply the plugin
|
|
76
|
+
*/
|
|
77
|
+
apply(compiler: any): void;
|
|
78
|
+
}
|
|
@@ -38,6 +38,7 @@ export interface BasicProviderModuleInfo extends BasicModuleInfo {
|
|
|
38
38
|
}
|
|
39
39
|
interface BasicProviderModuleInfoWithPublicPath extends BasicProviderModuleInfo {
|
|
40
40
|
publicPath: string;
|
|
41
|
+
ssrPublicPath?: string;
|
|
41
42
|
}
|
|
42
43
|
interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleInfo {
|
|
43
44
|
getPublicPath: string;
|
|
@@ -55,6 +56,7 @@ interface BasicConsumerModuleInfo extends BasicModuleInfo {
|
|
|
55
56
|
}
|
|
56
57
|
export interface ConsumerModuleInfoWithPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
|
|
57
58
|
publicPath: string;
|
|
59
|
+
ssrPublicPath?: string;
|
|
58
60
|
}
|
|
59
61
|
interface ConsumerModuleInfoWithGetPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
|
|
60
62
|
getPublicPath: string;
|
|
@@ -32,6 +32,7 @@ type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & {
|
|
|
32
32
|
};
|
|
33
33
|
type StatsMetaDataWithPublicPath<T = BasicStatsMetaData> = T & {
|
|
34
34
|
publicPath: string;
|
|
35
|
+
ssrPublicPath?: string;
|
|
35
36
|
};
|
|
36
37
|
export type StatsMetaData<T = BasicStatsMetaData> = StatsMetaDataWithGetPublicPath<T> | StatsMetaDataWithPublicPath<T>;
|
|
37
38
|
export interface StatsAssets {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"description": "A sdk for support module federation",
|
|
6
7
|
"keywords": [
|
|
@@ -9,7 +10,8 @@
|
|
|
9
10
|
],
|
|
10
11
|
"files": [
|
|
11
12
|
"dist/",
|
|
12
|
-
"README.md"
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
13
15
|
],
|
|
14
16
|
"repository": {
|
|
15
17
|
"type": "git",
|
|
@@ -21,19 +23,29 @@
|
|
|
21
23
|
},
|
|
22
24
|
"author": "zhanghang <hanric.zhang@gmail.com>",
|
|
23
25
|
"sideEffects": false,
|
|
24
|
-
"main": "./dist/index.cjs.
|
|
25
|
-
"module": "./dist/index.esm.
|
|
26
|
+
"main": "./dist/index.cjs.cjs",
|
|
27
|
+
"module": "./dist/index.esm.js",
|
|
26
28
|
"types": "./dist/index.cjs.d.ts",
|
|
27
29
|
"exports": {
|
|
28
30
|
".": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.esm.d.ts",
|
|
33
|
+
"default": "./dist/index.esm.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.cjs.d.ts",
|
|
37
|
+
"default": "./dist/index.cjs.cjs"
|
|
38
|
+
}
|
|
32
39
|
},
|
|
33
40
|
"./normalize-webpack-path": {
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/normalize-webpack-path.esm.d.ts",
|
|
43
|
+
"default": "./dist/normalize-webpack-path.esm.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/normalize-webpack-path.cjs.d.ts",
|
|
47
|
+
"default": "./dist/normalize-webpack-path.cjs.cjs"
|
|
48
|
+
}
|
|
37
49
|
}
|
|
38
50
|
},
|
|
39
51
|
"typesVersions": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|