@module-federation/sdk
Advanced tools
Comparing version 0.0.0-next-20241105211652 to 0.0.0-next-20241106024856
@@ -603,7 +603,5 @@ 'use strict'; | ||
}; | ||
const lazyLoaderHookFetch = async (input, init)=>{ | ||
// @ts-ignore | ||
const loaderHooks = __webpack_require__.federation.instance.loaderHook; | ||
const lazyLoaderHookFetch = async (input, init, loaderHook)=>{ | ||
const hook = (url, init)=>{ | ||
return loaderHooks.lifecycle.fetch.emit(url, init); | ||
return loaderHook.lifecycle.fetch.emit(url, init); | ||
}; | ||
@@ -617,5 +615,5 @@ const res = await hook(input, init || {}); | ||
}; | ||
function createScriptNode(url, cb, attrs, createScriptHook) { | ||
if (createScriptHook) { | ||
const hookResult = createScriptHook(url); | ||
function createScriptNode(url, cb, attrs, loaderHook) { | ||
if (loaderHook == null ? void 0 : loaderHook.createScriptHook) { | ||
const hookResult = loaderHook.createScriptHook(url); | ||
if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) { | ||
@@ -634,13 +632,4 @@ url = hookResult.url; | ||
const getFetch = async ()=>{ | ||
//@ts-ignore | ||
if (typeof __webpack_require__ !== 'undefined') { | ||
try { | ||
//@ts-ignore | ||
const loaderHooks = __webpack_require__.federation.instance.loaderHook; | ||
if (loaderHooks.lifecycle.fetch) { | ||
return lazyLoaderHookFetch; | ||
} | ||
} catch (e) { | ||
console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e); | ||
} | ||
if (loaderHook == null ? void 0 : loaderHook.fetch) { | ||
return (input, init)=>lazyLoaderHookFetch(input, init, loaderHook); | ||
} | ||
@@ -712,3 +701,3 @@ return typeof fetch === 'undefined' ? loadNodeFetch() : fetch; | ||
} | ||
}, info.attrs, info.createScriptHook); | ||
}, info.attrs, info.loaderHook); | ||
}); | ||
@@ -715,0 +704,0 @@ } |
@@ -25,3 +25,3 @@ { | ||
"types": "./dist/index.cjs.d.ts", | ||
"import": "./dist/index.esm.js", | ||
"import": "./dist/index.esm.mjs", | ||
"require": "./dist/index.cjs.js" | ||
@@ -31,3 +31,3 @@ }, | ||
"types": "./dist/normalize-webpack-path.cjs.d.ts", | ||
"import": "./dist/normalize-webpack-path.esm.js", | ||
"import": "./dist/normalize-webpack-path.esm.mjs", | ||
"require": "./dist/normalize-webpack-path.cjs.js" | ||
@@ -34,0 +34,0 @@ } |
@@ -1,6 +0,11 @@ | ||
import { CreateScriptHookNode } from './types'; | ||
export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: CreateScriptHookNode): void; | ||
import { CreateScriptHookNode, FetchHook } from './types'; | ||
export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, loaderHook?: { | ||
createScriptHook?: CreateScriptHookNode; | ||
fetch?: FetchHook; | ||
}): void; | ||
export declare function loadScriptNode(url: string, info: { | ||
attrs?: Record<string, any>; | ||
createScriptHook?: CreateScriptHookNode; | ||
loaderHook?: { | ||
createScriptHook?: CreateScriptHookNode; | ||
}; | ||
}): Promise<void>; |
@@ -12,1 +12,2 @@ export type CreateScriptHookReturnNode = { | ||
export type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn; | ||
export type FetchHook = (args: [string, RequestInit]) => Promise<Response> | void | false; |
@@ -186,2 +186,10 @@ import type webpack from 'webpack'; | ||
}; | ||
bridge?: { | ||
/** | ||
* Disables the default alias setting in the bridge. | ||
* When true, users must manually handle basename through root component props. | ||
* @default false | ||
*/ | ||
disableAlias?: boolean; | ||
}; | ||
} | ||
@@ -188,0 +196,0 @@ /** |
{ | ||
"name": "@module-federation/sdk", | ||
"version": "0.0.0-next-20241105211652", | ||
"version": "0.0.0-next-20241106024856", | ||
"license": "MIT", | ||
@@ -20,3 +20,3 @@ "description": "A sdk for support module federation", | ||
"main": "./dist/index.cjs.js", | ||
"module": "./dist/index.esm.js", | ||
"module": "./dist/index.esm.mjs", | ||
"types": "./dist/index.cjs.d.ts", | ||
@@ -26,3 +26,3 @@ "exports": { | ||
"types": "./dist/index.cjs.d.ts", | ||
"import": "./dist/index.esm.js", | ||
"import": "./dist/index.esm.mjs", | ||
"require": "./dist/index.cjs.js" | ||
@@ -32,3 +32,3 @@ }, | ||
"types": "./dist/normalize-webpack-path.cjs.d.ts", | ||
"import": "./dist/normalize-webpack-path.esm.js", | ||
"import": "./dist/normalize-webpack-path.esm.mjs", | ||
"require": "./dist/normalize-webpack-path.cjs.js" | ||
@@ -35,0 +35,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104242
2610