@module-federation/sdk 0.17.1 → 0.18.1
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.cjs
CHANGED
|
@@ -609,15 +609,25 @@ function loadScript(url, info) {
|
|
|
609
609
|
});
|
|
610
610
|
}
|
|
611
611
|
|
|
612
|
+
const sdkImportCache = new Map();
|
|
612
613
|
function importNodeModule(name) {
|
|
613
614
|
if (!name) {
|
|
614
615
|
throw new Error('import specifier is required');
|
|
615
616
|
}
|
|
617
|
+
// Check cache to prevent infinite recursion
|
|
618
|
+
if (sdkImportCache.has(name)) {
|
|
619
|
+
return sdkImportCache.get(name);
|
|
620
|
+
}
|
|
616
621
|
const importModule = new Function('name', `return import(name)`);
|
|
617
|
-
|
|
622
|
+
const promise = importModule(name).then((res)=>res).catch((error)=>{
|
|
618
623
|
console.error(`Error importing module ${name}:`, error);
|
|
624
|
+
// Remove from cache on error so it can be retried
|
|
625
|
+
sdkImportCache.delete(name);
|
|
619
626
|
throw error;
|
|
620
627
|
});
|
|
628
|
+
// Cache the promise to prevent recursive calls
|
|
629
|
+
sdkImportCache.set(name, promise);
|
|
630
|
+
return promise;
|
|
621
631
|
}
|
|
622
632
|
const loadNodeFetch = async ()=>{
|
|
623
633
|
const fetchModule = await importNodeModule('node-fetch');
|
|
@@ -725,7 +735,12 @@ const loadScriptNode = typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'
|
|
|
725
735
|
} : (url, info)=>{
|
|
726
736
|
throw new Error('loadScriptNode is disabled in non-Node.js environment');
|
|
727
737
|
};
|
|
738
|
+
const esmModuleCache = new Map();
|
|
728
739
|
async function loadModule(url, options) {
|
|
740
|
+
// Check cache to prevent infinite recursion in ESM loading
|
|
741
|
+
if (esmModuleCache.has(url)) {
|
|
742
|
+
return esmModuleCache.get(url);
|
|
743
|
+
}
|
|
729
744
|
const { fetch: fetch1, vm } = options;
|
|
730
745
|
const response = await fetch1(url);
|
|
731
746
|
const code = await response.text();
|
|
@@ -736,6 +751,8 @@ async function loadModule(url, options) {
|
|
|
736
751
|
return loadModule(resolvedUrl, options);
|
|
737
752
|
}
|
|
738
753
|
});
|
|
754
|
+
// Cache the module before linking to prevent cycles
|
|
755
|
+
esmModuleCache.set(url, module);
|
|
739
756
|
await module.link(async (specifier)=>{
|
|
740
757
|
const resolvedUrl = new URL(specifier, url).href;
|
|
741
758
|
const module = await loadModule(resolvedUrl, options);
|
package/dist/index.esm.js
CHANGED
|
@@ -607,15 +607,25 @@ function loadScript(url, info) {
|
|
|
607
607
|
});
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
+
const sdkImportCache = new Map();
|
|
610
611
|
function importNodeModule(name) {
|
|
611
612
|
if (!name) {
|
|
612
613
|
throw new Error('import specifier is required');
|
|
613
614
|
}
|
|
615
|
+
// Check cache to prevent infinite recursion
|
|
616
|
+
if (sdkImportCache.has(name)) {
|
|
617
|
+
return sdkImportCache.get(name);
|
|
618
|
+
}
|
|
614
619
|
const importModule = new Function('name', `return import(name)`);
|
|
615
|
-
|
|
620
|
+
const promise = importModule(name).then((res)=>res).catch((error)=>{
|
|
616
621
|
console.error(`Error importing module ${name}:`, error);
|
|
622
|
+
// Remove from cache on error so it can be retried
|
|
623
|
+
sdkImportCache.delete(name);
|
|
617
624
|
throw error;
|
|
618
625
|
});
|
|
626
|
+
// Cache the promise to prevent recursive calls
|
|
627
|
+
sdkImportCache.set(name, promise);
|
|
628
|
+
return promise;
|
|
619
629
|
}
|
|
620
630
|
const loadNodeFetch = async ()=>{
|
|
621
631
|
const fetchModule = await importNodeModule('node-fetch');
|
|
@@ -723,7 +733,12 @@ const loadScriptNode = typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'
|
|
|
723
733
|
} : (url, info)=>{
|
|
724
734
|
throw new Error('loadScriptNode is disabled in non-Node.js environment');
|
|
725
735
|
};
|
|
736
|
+
const esmModuleCache = new Map();
|
|
726
737
|
async function loadModule(url, options) {
|
|
738
|
+
// Check cache to prevent infinite recursion in ESM loading
|
|
739
|
+
if (esmModuleCache.has(url)) {
|
|
740
|
+
return esmModuleCache.get(url);
|
|
741
|
+
}
|
|
727
742
|
const { fetch: fetch1, vm } = options;
|
|
728
743
|
const response = await fetch1(url);
|
|
729
744
|
const code = await response.text();
|
|
@@ -734,6 +749,8 @@ async function loadModule(url, options) {
|
|
|
734
749
|
return loadModule(resolvedUrl, options);
|
|
735
750
|
}
|
|
736
751
|
});
|
|
752
|
+
// Cache the module before linking to prevent cycles
|
|
753
|
+
esmModuleCache.set(url, module);
|
|
737
754
|
await module.link(async (specifier)=>{
|
|
738
755
|
const resolvedUrl = new URL(specifier, url).href;
|
|
739
756
|
const module = await loadModule(resolvedUrl, options);
|
|
@@ -106,6 +106,8 @@ export interface DtsHostOptions {
|
|
|
106
106
|
runtimePkgs?: string[];
|
|
107
107
|
remoteTypeUrls?: (() => Promise<RemoteTypeUrls>) | RemoteTypeUrls;
|
|
108
108
|
timeout?: number;
|
|
109
|
+
/** The family of IP, used for network requests */
|
|
110
|
+
family?: 4 | 6;
|
|
109
111
|
typesOnBuild?: boolean;
|
|
110
112
|
}
|
|
111
113
|
export interface DtsRemoteOptions {
|