@module-federation/sdk 0.0.0-next-20240707075106 → 0.0.0-next-20240708090519
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 +14 -7
- package/dist/index.esm.js +15 -7
- package/dist/package.json +1 -1
- package/dist/src/constant.d.ts +0 -1
- package/dist/src/types/plugins/ModuleFederationPlugin.d.ts +6 -0
- package/dist/src/types/snapshot.d.ts +3 -0
- package/dist/src/types/stats.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -30,7 +30,6 @@ const MFModuleType = {
|
|
|
30
30
|
};
|
|
31
31
|
const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
|
|
32
32
|
const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
33
|
-
const TEMP_DIR = '.federation';
|
|
34
33
|
|
|
35
34
|
var ContainerPlugin = /*#__PURE__*/Object.freeze({
|
|
36
35
|
__proto__: null
|
|
@@ -337,7 +336,7 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
337
336
|
// overrides will override dependencies
|
|
338
337
|
matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
|
|
339
338
|
});
|
|
340
|
-
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName } = manifest.metaData;
|
|
339
|
+
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
|
|
341
340
|
const { exposes } = manifest;
|
|
342
341
|
let basicRemoteSnapshot = {
|
|
343
342
|
version: version ? version : '',
|
|
@@ -382,6 +381,11 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
382
381
|
getPublicPath: getPublicPath()
|
|
383
382
|
});
|
|
384
383
|
}
|
|
384
|
+
if (ssrRemoteEntry) {
|
|
385
|
+
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
|
|
386
|
+
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
|
|
387
|
+
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
|
|
388
|
+
}
|
|
385
389
|
return remoteSnapshot;
|
|
386
390
|
}
|
|
387
391
|
function isManifestProvider(moduleInfo) {
|
|
@@ -556,7 +560,6 @@ function loadScript(url, info) {
|
|
|
556
560
|
url,
|
|
557
561
|
cb: resolve,
|
|
558
562
|
attrs: _extends({
|
|
559
|
-
crossorigin: 'anonymous',
|
|
560
563
|
fetchpriority: 'high'
|
|
561
564
|
}, attrs),
|
|
562
565
|
createScriptHook,
|
|
@@ -571,7 +574,7 @@ function importNodeModule(name) {
|
|
|
571
574
|
throw new Error('import specifier is required');
|
|
572
575
|
}
|
|
573
576
|
const importModule = new Function('name', `return import(name)`);
|
|
574
|
-
return importModule(name).then((res)=>res
|
|
577
|
+
return importModule(name).then((res)=>res).catch((error)=>{
|
|
575
578
|
console.error(`Error importing module ${name}:`, error);
|
|
576
579
|
throw error;
|
|
577
580
|
});
|
|
@@ -625,6 +628,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
625
628
|
};
|
|
626
629
|
const handleScriptFetch = async (f, urlObj)=>{
|
|
627
630
|
try {
|
|
631
|
+
var _vm_constants;
|
|
628
632
|
const res = await f(urlObj.href);
|
|
629
633
|
const data = await res.text();
|
|
630
634
|
const [path, vm] = await Promise.all([
|
|
@@ -639,7 +643,11 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
639
643
|
};
|
|
640
644
|
const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
|
|
641
645
|
const filename = path.basename(urlObj.pathname);
|
|
642
|
-
|
|
646
|
+
var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
|
|
647
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
|
|
648
|
+
filename,
|
|
649
|
+
importModuleDynamically: (_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER = (_vm_constants = vm.constants) == null ? void 0 : _vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER) != null ? _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER : importNodeModule
|
|
650
|
+
});
|
|
643
651
|
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
|
|
644
652
|
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
645
653
|
if (attrs && exportedInterface && attrs['globalName']) {
|
|
@@ -649,7 +657,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
649
657
|
}
|
|
650
658
|
cb(undefined, exportedInterface);
|
|
651
659
|
} catch (e) {
|
|
652
|
-
cb(new Error(`Script execution error: ${e}`));
|
|
660
|
+
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
|
|
653
661
|
}
|
|
654
662
|
};
|
|
655
663
|
getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
|
|
@@ -707,7 +715,6 @@ exports.NameTransformMap = NameTransformMap;
|
|
|
707
715
|
exports.NameTransformSymbol = NameTransformSymbol;
|
|
708
716
|
exports.SEPARATOR = SEPARATOR;
|
|
709
717
|
exports.StatsFileName = StatsFileName;
|
|
710
|
-
exports.TEMP_DIR = TEMP_DIR;
|
|
711
718
|
exports.assert = assert;
|
|
712
719
|
exports.composeKeyWithSeparator = composeKeyWithSeparator;
|
|
713
720
|
exports.containerPlugin = ContainerPlugin;
|
package/dist/index.esm.js
CHANGED
|
@@ -26,7 +26,6 @@ const MFModuleType = {
|
|
|
26
26
|
};
|
|
27
27
|
const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
|
|
28
28
|
const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
29
|
-
const TEMP_DIR = '.federation';
|
|
30
29
|
|
|
31
30
|
var ContainerPlugin = /*#__PURE__*/Object.freeze({
|
|
32
31
|
__proto__: null
|
|
@@ -333,7 +332,7 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
333
332
|
// overrides will override dependencies
|
|
334
333
|
matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
|
|
335
334
|
});
|
|
336
|
-
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName } = manifest.metaData;
|
|
335
|
+
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
|
|
337
336
|
const { exposes } = manifest;
|
|
338
337
|
let basicRemoteSnapshot = {
|
|
339
338
|
version: version ? version : '',
|
|
@@ -378,6 +377,11 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
378
377
|
getPublicPath: getPublicPath()
|
|
379
378
|
});
|
|
380
379
|
}
|
|
380
|
+
if (ssrRemoteEntry) {
|
|
381
|
+
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
|
|
382
|
+
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
|
|
383
|
+
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
|
|
384
|
+
}
|
|
381
385
|
return remoteSnapshot;
|
|
382
386
|
}
|
|
383
387
|
function isManifestProvider(moduleInfo) {
|
|
@@ -552,7 +556,6 @@ function loadScript(url, info) {
|
|
|
552
556
|
url,
|
|
553
557
|
cb: resolve,
|
|
554
558
|
attrs: _extends({
|
|
555
|
-
crossorigin: 'anonymous',
|
|
556
559
|
fetchpriority: 'high'
|
|
557
560
|
}, attrs),
|
|
558
561
|
createScriptHook,
|
|
@@ -567,7 +570,7 @@ function importNodeModule(name) {
|
|
|
567
570
|
throw new Error('import specifier is required');
|
|
568
571
|
}
|
|
569
572
|
const importModule = new Function('name', `return import(name)`);
|
|
570
|
-
return importModule(name).then((res)=>res
|
|
573
|
+
return importModule(name).then((res)=>res).catch((error)=>{
|
|
571
574
|
console.error(`Error importing module ${name}:`, error);
|
|
572
575
|
throw error;
|
|
573
576
|
});
|
|
@@ -621,6 +624,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
621
624
|
};
|
|
622
625
|
const handleScriptFetch = async (f, urlObj)=>{
|
|
623
626
|
try {
|
|
627
|
+
var _vm_constants;
|
|
624
628
|
const res = await f(urlObj.href);
|
|
625
629
|
const data = await res.text();
|
|
626
630
|
const [path, vm] = await Promise.all([
|
|
@@ -635,7 +639,11 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
635
639
|
};
|
|
636
640
|
const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
|
|
637
641
|
const filename = path.basename(urlObj.pathname);
|
|
638
|
-
|
|
642
|
+
var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
|
|
643
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
|
|
644
|
+
filename,
|
|
645
|
+
importModuleDynamically: (_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER = (_vm_constants = vm.constants) == null ? void 0 : _vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER) != null ? _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER : importNodeModule
|
|
646
|
+
});
|
|
639
647
|
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
|
|
640
648
|
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
641
649
|
if (attrs && exportedInterface && attrs['globalName']) {
|
|
@@ -645,7 +653,7 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
645
653
|
}
|
|
646
654
|
cb(undefined, exportedInterface);
|
|
647
655
|
} catch (e) {
|
|
648
|
-
cb(new Error(`Script execution error: ${e}`));
|
|
656
|
+
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
|
|
649
657
|
}
|
|
650
658
|
};
|
|
651
659
|
getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
|
|
@@ -689,4 +697,4 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
|
689
697
|
};
|
|
690
698
|
}
|
|
691
699
|
|
|
692
|
-
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName,
|
|
700
|
+
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, assert, composeKeyWithSeparator, ContainerPlugin as containerPlugin, ContainerReferencePlugin as containerReferencePlugin, createLink, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, inferAutoPublicPath, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin as moduleFederationPlugin, normalizeOptions, parseEntry, safeWrapper, SharePlugin as sharePlugin, simpleJoinRemoteEntry, warn };
|
package/dist/package.json
CHANGED
package/dist/src/constant.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export interface DtsHostOptions {
|
|
|
91
91
|
deleteTypesFolder?: boolean;
|
|
92
92
|
maxRetries?: number;
|
|
93
93
|
consumeAPITypes?: boolean;
|
|
94
|
+
runtimePkgs?: string[];
|
|
94
95
|
}
|
|
95
96
|
export interface DtsRemoteOptions {
|
|
96
97
|
tsConfigPath?: string;
|
|
@@ -112,6 +113,10 @@ export interface PluginDtsOptions {
|
|
|
112
113
|
extraOptions?: Record<string, any>;
|
|
113
114
|
implementation?: string;
|
|
114
115
|
}
|
|
116
|
+
export type AsyncBoundaryOptions = {
|
|
117
|
+
eager?: RegExp | ((module: any) => boolean);
|
|
118
|
+
excludeChunk?: (chunk: any) => boolean;
|
|
119
|
+
};
|
|
115
120
|
export interface ModuleFederationPluginOptions {
|
|
116
121
|
/**
|
|
117
122
|
* Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
|
|
@@ -164,6 +169,7 @@ export interface ModuleFederationPluginOptions {
|
|
|
164
169
|
manifest?: boolean | PluginManifestOptions;
|
|
165
170
|
dev?: boolean | PluginDevOptions;
|
|
166
171
|
dts?: boolean | PluginDtsOptions;
|
|
172
|
+
async?: boolean | AsyncBoundaryOptions;
|
|
167
173
|
}
|
|
168
174
|
/**
|
|
169
175
|
* Modules that should be exposed by this container. Property names are used as public paths.
|
|
@@ -23,6 +23,8 @@ interface BasicModuleInfo {
|
|
|
23
23
|
export interface BasicProviderModuleInfo extends BasicModuleInfo {
|
|
24
24
|
remoteEntry: string;
|
|
25
25
|
remoteEntryType: RemoteEntryType;
|
|
26
|
+
ssrRemoteEntry?: string;
|
|
27
|
+
ssrRemoteEntryType?: RemoteEntryType;
|
|
26
28
|
remoteManifest?: string;
|
|
27
29
|
globalName: string;
|
|
28
30
|
modules: Array<{
|
|
@@ -42,6 +44,7 @@ interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleIn
|
|
|
42
44
|
}
|
|
43
45
|
export interface ManifestProvider {
|
|
44
46
|
remoteEntry: string;
|
|
47
|
+
ssrRemoteEntry?: string;
|
|
45
48
|
version?: string;
|
|
46
49
|
}
|
|
47
50
|
export interface PureEntryProvider extends ManifestProvider {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RemoteWithEntry, RemoteWithVersion } from './common';
|
|
2
2
|
export 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;
|
|
3
|
-
interface ResourceInfo {
|
|
3
|
+
export interface ResourceInfo {
|
|
4
4
|
path: string;
|
|
5
5
|
name: string;
|
|
6
6
|
type: RemoteEntryType;
|
|
@@ -20,6 +20,7 @@ export interface BasicStatsMetaData {
|
|
|
20
20
|
globalName: string;
|
|
21
21
|
buildInfo: StatsBuildInfo;
|
|
22
22
|
remoteEntry: ResourceInfo;
|
|
23
|
+
ssrRemoteEntry?: ResourceInfo;
|
|
23
24
|
prefetchInterface?: boolean;
|
|
24
25
|
prefetchEntry?: ResourceInfo;
|
|
25
26
|
types: MetaDataTypes;
|