@module-federation/sdk 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703
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/README.md +9 -3
- package/dist/_virtual/_rolldown/runtime.cjs +19 -0
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/constant.cjs +62 -0
- package/dist/constant.cjs.map +1 -0
- package/dist/constant.d.ts +46 -0
- package/dist/constant.js +48 -0
- package/dist/constant.js.map +1 -0
- package/dist/createModuleFederationConfig.cjs +9 -0
- package/dist/createModuleFederationConfig.cjs.map +1 -0
- package/dist/createModuleFederationConfig.d.ts +6 -0
- package/dist/createModuleFederationConfig.js +8 -0
- package/dist/createModuleFederationConfig.js.map +1 -0
- package/dist/dom.cjs +214 -0
- package/dist/dom.cjs.map +1 -0
- package/dist/dom.d.ts +33 -0
- package/dist/dom.js +210 -0
- package/dist/dom.js.map +1 -0
- package/dist/env.cjs +34 -0
- package/dist/env.cjs.map +1 -0
- package/dist/env.d.ts +12 -0
- package/dist/env.js +30 -0
- package/dist/env.js.map +1 -0
- package/dist/generateSnapshotFromManifest.cjs +123 -0
- package/dist/generateSnapshotFromManifest.cjs.map +1 -0
- package/dist/generateSnapshotFromManifest.d.ts +20 -0
- package/dist/generateSnapshotFromManifest.js +119 -0
- package/dist/generateSnapshotFromManifest.js.map +1 -0
- package/dist/index.cjs +103 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +17 -0
- package/dist/logger.cjs +129 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.ts +34 -0
- package/dist/logger.js +125 -0
- package/dist/logger.js.map +1 -0
- package/dist/node.cjs +180 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +15 -0
- package/dist/node.js +178 -0
- package/dist/node.js.map +1 -0
- package/dist/normalize-webpack-path.cjs +28 -0
- package/dist/normalize-webpack-path.cjs.map +1 -0
- package/dist/normalize-webpack-path.d.ts +10 -1
- package/dist/normalize-webpack-path.js +26 -0
- package/dist/normalize-webpack-path.js.map +1 -0
- package/dist/normalizeOptions.cjs +19 -0
- package/dist/normalizeOptions.cjs.map +1 -0
- package/dist/normalizeOptions.d.ts +5 -0
- package/dist/normalizeOptions.js +18 -0
- package/dist/normalizeOptions.js.map +1 -0
- package/dist/types/common.d.ts +14 -0
- package/dist/types/hooks.d.ts +21 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/manifest.d.ts +34 -0
- package/dist/types/plugins/ConsumeSharedPlugin.cjs +13 -0
- package/dist/types/plugins/ConsumeSharedPlugin.cjs.map +1 -0
- package/dist/types/plugins/ConsumeSharedPlugin.d.ts +109 -0
- package/dist/types/plugins/ConsumeSharedPlugin.js +8 -0
- package/dist/types/plugins/ConsumeSharedPlugin.js.map +1 -0
- package/dist/types/plugins/ContainerPlugin.cjs +13 -0
- package/dist/types/plugins/ContainerPlugin.cjs.map +1 -0
- package/dist/types/plugins/ContainerPlugin.d.ts +38 -0
- package/dist/types/plugins/ContainerPlugin.js +8 -0
- package/dist/types/plugins/ContainerPlugin.js.map +1 -0
- package/dist/types/plugins/ContainerReferencePlugin.cjs +13 -0
- package/dist/types/plugins/ContainerReferencePlugin.cjs.map +1 -0
- package/dist/types/plugins/ContainerReferencePlugin.d.ts +24 -0
- package/dist/types/plugins/ContainerReferencePlugin.js +8 -0
- package/dist/types/plugins/ContainerReferencePlugin.js.map +1 -0
- package/dist/types/plugins/ModuleFederationPlugin.cjs +13 -0
- package/dist/types/plugins/ModuleFederationPlugin.cjs.map +1 -0
- package/dist/types/plugins/ModuleFederationPlugin.d.ts +470 -0
- package/dist/types/plugins/ModuleFederationPlugin.js +8 -0
- package/dist/types/plugins/ModuleFederationPlugin.js.map +1 -0
- package/dist/types/plugins/ProvideSharedPlugin.cjs +13 -0
- package/dist/types/plugins/ProvideSharedPlugin.cjs.map +1 -0
- package/dist/types/plugins/ProvideSharedPlugin.d.ts +97 -0
- package/dist/types/plugins/ProvideSharedPlugin.js +8 -0
- package/dist/types/plugins/ProvideSharedPlugin.js.map +1 -0
- package/dist/types/plugins/SharePlugin.cjs +13 -0
- package/dist/types/plugins/SharePlugin.cjs.map +1 -0
- package/dist/types/plugins/SharePlugin.d.ts +26 -0
- package/dist/types/plugins/SharePlugin.js +8 -0
- package/dist/types/plugins/SharePlugin.js.map +1 -0
- package/dist/types/plugins/index.d.ts +6 -0
- package/dist/types/snapshot.d.ts +78 -0
- package/dist/types/stats.d.ts +101 -0
- package/dist/utils.cjs +127 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/{src/utils.d.ts → utils.d.ts} +15 -4
- package/dist/utils.js +116 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -7
- package/dist/index.cjs.cjs +0 -1048
- package/dist/index.cjs.cjs.map +0 -1
- package/dist/index.cjs.d.ts +0 -1
- package/dist/index.esm.js +0 -994
- package/dist/index.esm.js.map +0 -1
- package/dist/normalize-webpack-path.cjs.cjs +0 -42
- package/dist/normalize-webpack-path.cjs.cjs.map +0 -1
- package/dist/normalize-webpack-path.cjs.d.ts +0 -1
- package/dist/normalize-webpack-path.esm.js +0 -39
- package/dist/normalize-webpack-path.esm.js.map +0 -1
- package/dist/src/constant.d.ts +0 -35
- package/dist/src/createModuleFederationConfig.d.ts +0 -2
- package/dist/src/dom.d.ts +0 -29
- package/dist/src/env.d.ts +0 -8
- package/dist/src/generateSnapshotFromManifest.d.ts +0 -15
- package/dist/src/index.d.ts +0 -11
- package/dist/src/logger.d.ts +0 -32
- package/dist/src/node.d.ts +0 -11
- package/dist/src/normalize-webpack-path.d.ts +0 -5
- package/dist/src/normalizeOptions.d.ts +0 -1
- package/dist/src/types/common.d.ts +0 -10
- package/dist/src/types/hooks.d.ts +0 -12
- package/dist/src/types/index.d.ts +0 -6
- package/dist/src/types/manifest.d.ts +0 -26
- package/dist/src/types/plugins/ContainerPlugin.d.ts +0 -164
- package/dist/src/types/plugins/ContainerReferencePlugin.d.ts +0 -52
- package/dist/src/types/plugins/ModuleFederationPlugin.d.ts +0 -409
- package/dist/src/types/plugins/SharePlugin.d.ts +0 -78
- package/dist/src/types/plugins/index.d.ts +0 -4
- package/dist/src/types/snapshot.d.ts +0 -70
- package/dist/src/types/stats.d.ts +0 -90
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.cjs","names":[],"sources":["../src/node.ts"],"sourcesContent":["import { CreateScriptHookNode, FetchHook } from './types';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\n\nconst sdkImportCache = new Map<string, Promise<any>>();\n\nfunction importNodeModule<T>(name: string): Promise<T> {\n if (!name) {\n throw new Error('import specifier is required');\n }\n\n // Check cache to prevent infinite recursion\n if (sdkImportCache.has(name)) {\n return sdkImportCache.get(name)!;\n }\n\n const importModule = new Function('name', `return import(name)`);\n const promise = importModule(name)\n .then((res: any) => res as T)\n .catch((error: any) => {\n console.error(`Error importing module ${name}:`, error);\n // Remove from cache on error so it can be retried\n sdkImportCache.delete(name);\n throw error;\n });\n\n // Cache the promise to prevent recursive calls\n sdkImportCache.set(name, promise);\n return promise;\n}\n\nconst lazyLoaderHookFetch = async (\n input: RequestInfo | URL,\n init?: RequestInit,\n loaderHook?: any,\n): Promise<Response> => {\n const hook = (url: RequestInfo | URL, init: RequestInit) => {\n return loaderHook.lifecycle.fetch.emit(url, init);\n };\n\n const res = await hook(input, init || {});\n if (!res || !(res instanceof Response)) {\n return fetch(input, init || {});\n }\n\n return res;\n};\n\nexport const createScriptNode =\n typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'\n ? (\n url: string,\n cb: (error?: Error, scriptContext?: any) => void,\n attrs?: Record<string, any>,\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n fetch?: FetchHook;\n },\n ) => {\n if (loaderHook?.createScriptHook) {\n const hookResult = loaderHook.createScriptHook(url);\n if (\n hookResult &&\n typeof hookResult === 'object' &&\n 'url' in hookResult\n ) {\n url = hookResult.url;\n }\n }\n\n let urlObj: URL;\n try {\n urlObj = new URL(url);\n } catch (e) {\n console.error('Error constructing URL:', e);\n cb(new Error(`Invalid URL: ${e}`));\n return;\n }\n\n const getFetch = async (): Promise<typeof fetch> => {\n if (loaderHook?.fetch) {\n return (input: RequestInfo | URL, init?: RequestInit) =>\n lazyLoaderHookFetch(input, init, loaderHook);\n }\n\n return fetch;\n };\n\n const handleScriptFetch = async (f: typeof fetch, urlObj: URL) => {\n try {\n const res = await f(urlObj.href);\n const data = await res.text();\n const [path, vm] = await Promise.all([\n importNodeModule<typeof import('path')>('path'),\n importNodeModule<typeof import('vm')>('vm'),\n ]);\n\n const scriptContext = { exports: {}, module: { exports: {} } };\n const urlDirname = urlObj.pathname\n .split('/')\n .slice(0, -1)\n .join('/');\n const filename = path.basename(urlObj.pathname);\n\n const script = new vm.Script(\n `(function(exports, module, require, __dirname, __filename) {${data}\\n})`,\n {\n filename,\n importModuleDynamically:\n //@ts-ignore\n vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ??\n importNodeModule,\n },\n );\n\n let requireFn: NodeRequire;\n if (process.env.IS_ESM_BUILD === 'true') {\n const nodeModule =\n await importNodeModule<typeof import('node:module')>(\n 'node:module',\n );\n requireFn = nodeModule.createRequire(\n urlObj.protocol === 'file:' || urlObj.protocol === 'node:'\n ? urlObj.href\n : path.join(process.cwd(), '__mf_require_base__.js'),\n );\n } else {\n requireFn = eval('require') as NodeRequire;\n }\n\n script.runInThisContext()(\n scriptContext.exports,\n scriptContext.module,\n requireFn,\n urlDirname,\n filename,\n );\n const exportedInterface: Record<string, any> =\n scriptContext.module.exports || scriptContext.exports;\n\n if (attrs && exportedInterface && attrs['globalName']) {\n const container =\n exportedInterface[attrs['globalName']] || exportedInterface;\n cb(\n undefined,\n container as keyof typeof scriptContext.module.exports,\n );\n return;\n }\n\n cb(\n undefined,\n exportedInterface as keyof typeof scriptContext.module.exports,\n );\n } catch (e) {\n cb(\n e instanceof Error\n ? e\n : new Error(`Script execution error: ${e}`),\n );\n }\n };\n\n getFetch()\n .then(async (f) => {\n if (attrs?.['type'] === 'esm' || attrs?.['type'] === 'module') {\n return loadModule(urlObj.href, {\n fetch: f,\n vm: await importNodeModule<typeof import('vm')>('vm'),\n })\n .then(async (module) => {\n await module.evaluate();\n cb(undefined, module.namespace);\n })\n .catch((e) => {\n cb(\n e instanceof Error\n ? e\n : new Error(`Script execution error: ${e}`),\n );\n });\n }\n handleScriptFetch(f, urlObj);\n })\n .catch((err) => {\n cb(err);\n });\n }\n : (\n url: string,\n cb: (error?: Error, scriptContext?: any) => void,\n attrs?: Record<string, any>,\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n fetch?: FetchHook;\n },\n ) => {\n cb(\n new Error('createScriptNode is disabled in non-Node.js environment'),\n );\n };\n\nexport const loadScriptNode =\n typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'\n ? (\n url: string,\n info: {\n attrs?: Record<string, any>;\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n };\n },\n ) => {\n return new Promise<void>((resolve, reject) => {\n createScriptNode(\n url,\n (error, scriptContext) => {\n if (error) {\n reject(error);\n } else {\n const remoteEntryKey =\n info?.attrs?.['globalName'] ||\n `__FEDERATION_${info?.attrs?.['name']}:custom__`;\n const entryExports = ((globalThis as any)[remoteEntryKey] =\n scriptContext);\n resolve(entryExports);\n }\n },\n info.attrs,\n info.loaderHook,\n );\n });\n }\n : (\n url: string,\n info: {\n attrs?: Record<string, any>;\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n };\n },\n ) => {\n throw new Error(\n 'loadScriptNode is disabled in non-Node.js environment',\n );\n };\n\nconst esmModuleCache = new Map<string, any>();\n\ntype LoadModuleOptions = {\n vm: typeof import('vm') & {\n SourceTextModule: any;\n SyntheticModule: any;\n };\n fetch: typeof fetch;\n};\n\nconst isFetchableRemoteModuleUrl = (url: string): boolean =>\n url.startsWith('http:') || url.startsWith('https:');\n\nconst isBareModuleSpecifier = (specifier: string): boolean =>\n !specifier.startsWith('./') &&\n !specifier.startsWith('../') &&\n !specifier.startsWith('/') &&\n !specifier.includes(':');\n\nfunction encodeRemoteModulePath(url: string): string {\n const remoteUrl = new URL(url);\n const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));\n const encodedHost = encodeURIComponent(remoteUrl.host);\n const encodedPathname = remoteUrl.pathname\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n const encodedSearchHash = encodeURIComponent(\n `${remoteUrl.search}${remoteUrl.hash}`,\n );\n const encodedSuffix = encodedSearchHash ? `/${encodedSearchHash}` : '';\n\n return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSuffix}`;\n}\n\nfunction createImportMetaUrl(url: string, baseFileUrl: string): string {\n const baseUrl = baseFileUrl.endsWith('/') ? baseFileUrl : `${baseFileUrl}/`;\n return new URL(\n `__module_federation_remote__${encodeRemoteModulePath(url)}`,\n baseUrl,\n ).href;\n}\n\nasync function isNodeBuiltinSpecifier(specifier: string): Promise<boolean> {\n if (specifier.startsWith('node:')) {\n return true;\n }\n\n if (!isBareModuleSpecifier(specifier)) {\n return false;\n }\n\n const nodeModule =\n await importNodeModule<typeof import('node:module')>('node:module');\n\n return nodeModule.builtinModules.includes(specifier);\n}\n\nfunction getSyntheticModuleExports(moduleExports: any): Record<string, any> {\n const namespaceObject =\n moduleExports &&\n (typeof moduleExports === 'object' || typeof moduleExports === 'function')\n ? moduleExports\n : { default: moduleExports };\n const effectiveExports = { ...namespaceObject };\n\n if (!Object.prototype.hasOwnProperty.call(effectiveExports, 'default')) {\n effectiveExports.default = namespaceObject;\n }\n\n return effectiveExports;\n}\n\nasync function createSyntheticModuleFromExports(\n identifier: string,\n moduleExports: any,\n vm: LoadModuleOptions['vm'],\n) {\n if (typeof vm.SyntheticModule !== 'function') {\n throw new Error(\n 'vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.',\n );\n }\n\n const effectiveExports = getSyntheticModuleExports(moduleExports);\n const exportNames = Object.keys(effectiveExports);\n const syntheticModule = new vm.SyntheticModule(\n exportNames,\n function setSyntheticModuleExports(this: {\n setExport: (name: string, value: any) => void;\n }) {\n for (const name of exportNames) {\n this.setExport(name, effectiveExports[name]);\n }\n },\n { identifier },\n );\n\n esmModuleCache.set(identifier, syntheticModule);\n await syntheticModule.link(async () => {\n throw new Error(\n `Node.js built-in module \"${identifier}\" should not request child modules.`,\n );\n });\n await syntheticModule.evaluate();\n\n return syntheticModule;\n}\n\nasync function loadNodeBuiltinModule(\n specifier: string,\n vm: LoadModuleOptions['vm'],\n) {\n const cacheKey = `node-builtin:${specifier}`;\n if (esmModuleCache.has(cacheKey)) {\n return esmModuleCache.get(cacheKey)!;\n }\n\n const moduleExports = await importNodeModule(specifier);\n return createSyntheticModuleFromExports(cacheKey, moduleExports, vm);\n}\n\nasync function loadResolvedModule(\n specifier: string,\n parentUrl: string,\n options: LoadModuleOptions,\n) {\n if (await isNodeBuiltinSpecifier(specifier)) {\n return loadNodeBuiltinModule(specifier, options.vm);\n }\n\n if (isBareModuleSpecifier(specifier)) {\n throw new Error(\n `Unsupported ESM module specifier \"${specifier}\". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n const resolvedUrl = new URL(specifier, parentUrl).href;\n if (!isFetchableRemoteModuleUrl(resolvedUrl)) {\n throw new Error(\n `Unsupported ESM module specifier \"${specifier}\" resolved to \"${resolvedUrl}\". Only http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n return loadModule(resolvedUrl, options);\n}\n\nasync function evaluateDynamicModule(module: any) {\n if (module.status === 'linked') {\n await module.evaluate();\n }\n\n if (module.status === 'errored') {\n throw module.error;\n }\n\n return module;\n}\n\nasync function loadModule(url: string, options: LoadModuleOptions) {\n // Check cache to prevent infinite recursion in ESM loading\n if (esmModuleCache.has(url)) {\n return esmModuleCache.get(url)!;\n }\n\n const { fetch, vm } = options;\n if (!isFetchableRemoteModuleUrl(url)) {\n throw new Error(\n `Unsupported ESM module URL \"${url}\". Only http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n const response = await fetch(url);\n const code = await response.text();\n const nodeUrl = await importNodeModule<typeof import('node:url')>('node:url');\n const cwdFileUrl = nodeUrl.pathToFileURL(process.cwd()).href;\n\n const sourceTextModule: any = new vm.SourceTextModule(code, {\n identifier: url,\n initializeImportMeta: (meta: { url: string }) => {\n meta.url = createImportMetaUrl(url, cwdFileUrl);\n },\n importModuleDynamically: async (specifier: string) => {\n return evaluateDynamicModule(\n await loadResolvedModule(specifier, url, options),\n );\n },\n });\n\n // Cache the module before linking to prevent cycles\n esmModuleCache.set(url, sourceTextModule);\n\n await sourceTextModule.link(async (specifier: string) => {\n return loadResolvedModule(specifier, url, options);\n });\n\n return sourceTextModule;\n}\n"],"mappings":";;AAKA,MAAM,iCAAiB,IAAI,KAA2B;AAEtD,SAAS,iBAAoB,MAA0B;AACrD,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,+BAA+B;AAIjD,KAAI,eAAe,IAAI,KAAK,CAC1B,QAAO,eAAe,IAAI,KAAK;CAIjC,MAAM,UADe,IAAI,SAAS,QAAQ,sBAAsB,CACnC,KAAK,CAC/B,MAAM,QAAa,IAAS,CAC5B,OAAO,UAAe;AACrB,UAAQ,MAAM,0BAA0B,KAAK,IAAI,MAAM;AAEvD,iBAAe,OAAO,KAAK;AAC3B,QAAM;GACN;AAGJ,gBAAe,IAAI,MAAM,QAAQ;AACjC,QAAO;;AAGT,MAAM,sBAAsB,OAC1B,OACA,MACA,eACsB;CACtB,MAAM,QAAQ,KAAwB,SAAsB;AAC1D,SAAO,WAAW,UAAU,MAAM,KAAK,KAAK,KAAK;;CAGnD,MAAM,MAAM,MAAM,KAAK,OAAO,QAAQ,EAAE,CAAC;AACzC,KAAI,CAAC,OAAO,EAAE,eAAe,UAC3B,QAAO,MAAM,OAAO,QAAQ,EAAE,CAAC;AAGjC,QAAO;;AAGT,MAAa,mB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,MAAM,oBAAoB,KAAK,WAAW;;EAEjD,yBAAyB,OAAO,cAAsB;AACpD,UAAO,sBACL,MAAM,mBAAmB,WAAW,KAAK,QAAQ,CAClD;;EAEJ,CAAC;AAGF,gBAAe,IAAI,KAAK,iBAAiB;AAEzC,OAAM,iBAAiB,KAAK,OAAO,cAAsB;AACvD,SAAO,mBAAmB,WAAW,KAAK,QAAQ;GAClD;AAEF,QAAO"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CreateScriptHookNode, FetchHook } from "./types/hooks.js";
|
|
2
|
+
//#region src/node.d.ts
|
|
3
|
+
declare const createScriptNode: (url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, loaderHook?: {
|
|
4
|
+
createScriptHook?: CreateScriptHookNode;
|
|
5
|
+
fetch?: FetchHook;
|
|
6
|
+
}) => void;
|
|
7
|
+
declare const loadScriptNode: (url: string, info: {
|
|
8
|
+
attrs?: Record<string, any>;
|
|
9
|
+
loaderHook?: {
|
|
10
|
+
createScriptHook?: CreateScriptHookNode;
|
|
11
|
+
};
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createScriptNode, loadScriptNode };
|
|
15
|
+
//# sourceMappingURL=node.d.ts.map
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
//#region src/node.ts
|
|
2
|
+
const sdkImportCache = /* @__PURE__ */ new Map();
|
|
3
|
+
function importNodeModule(name) {
|
|
4
|
+
if (!name) throw new Error("import specifier is required");
|
|
5
|
+
if (sdkImportCache.has(name)) return sdkImportCache.get(name);
|
|
6
|
+
const promise = new Function("name", `return import(name)`)(name).then((res) => res).catch((error) => {
|
|
7
|
+
console.error(`Error importing module ${name}:`, error);
|
|
8
|
+
sdkImportCache.delete(name);
|
|
9
|
+
throw error;
|
|
10
|
+
});
|
|
11
|
+
sdkImportCache.set(name, promise);
|
|
12
|
+
return promise;
|
|
13
|
+
}
|
|
14
|
+
const lazyLoaderHookFetch = async (input, init, loaderHook) => {
|
|
15
|
+
const hook = (url, init) => {
|
|
16
|
+
return loaderHook.lifecycle.fetch.emit(url, init);
|
|
17
|
+
};
|
|
18
|
+
const res = await hook(input, init || {});
|
|
19
|
+
if (!res || !(res instanceof Response)) return fetch(input, init || {});
|
|
20
|
+
return res;
|
|
21
|
+
};
|
|
22
|
+
const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
23
|
+
if (loaderHook?.createScriptHook) {
|
|
24
|
+
const hookResult = loaderHook.createScriptHook(url);
|
|
25
|
+
if (hookResult && typeof hookResult === "object" && "url" in hookResult) url = hookResult.url;
|
|
26
|
+
}
|
|
27
|
+
let urlObj;
|
|
28
|
+
try {
|
|
29
|
+
urlObj = new URL(url);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
console.error("Error constructing URL:", e);
|
|
32
|
+
cb(/* @__PURE__ */ new Error(`Invalid URL: ${e}`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const getFetch = async () => {
|
|
36
|
+
if (loaderHook?.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
|
|
37
|
+
return fetch;
|
|
38
|
+
};
|
|
39
|
+
const handleScriptFetch = async (f, urlObj) => {
|
|
40
|
+
try {
|
|
41
|
+
const res = await f(urlObj.href);
|
|
42
|
+
const data = await res.text();
|
|
43
|
+
const [path, vm] = await Promise.all([importNodeModule("path"), importNodeModule("vm")]);
|
|
44
|
+
const scriptContext = {
|
|
45
|
+
exports: {},
|
|
46
|
+
module: { exports: {} }
|
|
47
|
+
};
|
|
48
|
+
const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
|
|
49
|
+
const filename = path.basename(urlObj.pathname);
|
|
50
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
|
|
51
|
+
filename,
|
|
52
|
+
importModuleDynamically: vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule
|
|
53
|
+
});
|
|
54
|
+
let requireFn;
|
|
55
|
+
requireFn = (await importNodeModule("node:module")).createRequire(urlObj.protocol === "file:" || urlObj.protocol === "node:" ? urlObj.href : path.join(process.cwd(), "__mf_require_base__.js"));
|
|
56
|
+
script.runInThisContext()(scriptContext.exports, scriptContext.module, requireFn, urlDirname, filename);
|
|
57
|
+
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
58
|
+
if (attrs && exportedInterface && attrs["globalName"]) {
|
|
59
|
+
cb(void 0, exportedInterface[attrs["globalName"]] || exportedInterface);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
cb(void 0, exportedInterface);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
getFetch().then(async (f) => {
|
|
68
|
+
if (attrs?.["type"] === "esm" || attrs?.["type"] === "module") return loadModule(urlObj.href, {
|
|
69
|
+
fetch: f,
|
|
70
|
+
vm: await importNodeModule("vm")
|
|
71
|
+
}).then(async (module) => {
|
|
72
|
+
await module.evaluate();
|
|
73
|
+
cb(void 0, module.namespace);
|
|
74
|
+
}).catch((e) => {
|
|
75
|
+
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
|
|
76
|
+
});
|
|
77
|
+
handleScriptFetch(f, urlObj);
|
|
78
|
+
}).catch((err) => {
|
|
79
|
+
cb(err);
|
|
80
|
+
});
|
|
81
|
+
} : (url, cb, attrs, loaderHook) => {
|
|
82
|
+
cb(/* @__PURE__ */ new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
83
|
+
};
|
|
84
|
+
const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, info) => {
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
createScriptNode(url, (error, scriptContext) => {
|
|
87
|
+
if (error) reject(error);
|
|
88
|
+
else {
|
|
89
|
+
const remoteEntryKey = info?.attrs?.["globalName"] || `__FEDERATION_${info?.attrs?.["name"]}:custom__`;
|
|
90
|
+
resolve(globalThis[remoteEntryKey] = scriptContext);
|
|
91
|
+
}
|
|
92
|
+
}, info.attrs, info.loaderHook);
|
|
93
|
+
});
|
|
94
|
+
} : (url, info) => {
|
|
95
|
+
throw new Error("loadScriptNode is disabled in non-Node.js environment");
|
|
96
|
+
};
|
|
97
|
+
const esmModuleCache = /* @__PURE__ */ new Map();
|
|
98
|
+
const isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");
|
|
99
|
+
const isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");
|
|
100
|
+
function encodeRemoteModulePath(url) {
|
|
101
|
+
const remoteUrl = new URL(url);
|
|
102
|
+
const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));
|
|
103
|
+
const encodedHost = encodeURIComponent(remoteUrl.host);
|
|
104
|
+
const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
105
|
+
const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);
|
|
106
|
+
return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;
|
|
107
|
+
}
|
|
108
|
+
function createImportMetaUrl(url, baseFileUrl) {
|
|
109
|
+
const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;
|
|
110
|
+
return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;
|
|
111
|
+
}
|
|
112
|
+
async function isNodeBuiltinSpecifier(specifier) {
|
|
113
|
+
if (specifier.startsWith("node:")) return true;
|
|
114
|
+
if (!isBareModuleSpecifier(specifier)) return false;
|
|
115
|
+
return (await importNodeModule("node:module")).builtinModules.includes(specifier);
|
|
116
|
+
}
|
|
117
|
+
function getSyntheticModuleExports(moduleExports) {
|
|
118
|
+
const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };
|
|
119
|
+
const effectiveExports = { ...namespaceObject };
|
|
120
|
+
if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;
|
|
121
|
+
return effectiveExports;
|
|
122
|
+
}
|
|
123
|
+
async function createSyntheticModuleFromExports(identifier, moduleExports, vm) {
|
|
124
|
+
if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");
|
|
125
|
+
const effectiveExports = getSyntheticModuleExports(moduleExports);
|
|
126
|
+
const exportNames = Object.keys(effectiveExports);
|
|
127
|
+
const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {
|
|
128
|
+
for (const name of exportNames) this.setExport(name, effectiveExports[name]);
|
|
129
|
+
}, { identifier });
|
|
130
|
+
esmModuleCache.set(identifier, syntheticModule);
|
|
131
|
+
await syntheticModule.link(async () => {
|
|
132
|
+
throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);
|
|
133
|
+
});
|
|
134
|
+
await syntheticModule.evaluate();
|
|
135
|
+
return syntheticModule;
|
|
136
|
+
}
|
|
137
|
+
async function loadNodeBuiltinModule(specifier, vm) {
|
|
138
|
+
const cacheKey = `node-builtin:${specifier}`;
|
|
139
|
+
if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);
|
|
140
|
+
return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);
|
|
141
|
+
}
|
|
142
|
+
async function loadResolvedModule(specifier, parentUrl, options) {
|
|
143
|
+
if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);
|
|
144
|
+
if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);
|
|
145
|
+
const resolvedUrl = new URL(specifier, parentUrl).href;
|
|
146
|
+
if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);
|
|
147
|
+
return loadModule(resolvedUrl, options);
|
|
148
|
+
}
|
|
149
|
+
async function evaluateDynamicModule(module) {
|
|
150
|
+
if (module.status === "linked") await module.evaluate();
|
|
151
|
+
if (module.status === "errored") throw module.error;
|
|
152
|
+
return module;
|
|
153
|
+
}
|
|
154
|
+
async function loadModule(url, options) {
|
|
155
|
+
if (esmModuleCache.has(url)) return esmModuleCache.get(url);
|
|
156
|
+
const { fetch, vm } = options;
|
|
157
|
+
if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);
|
|
158
|
+
const code = await (await fetch(url)).text();
|
|
159
|
+
const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;
|
|
160
|
+
const sourceTextModule = new vm.SourceTextModule(code, {
|
|
161
|
+
identifier: url,
|
|
162
|
+
initializeImportMeta: (meta) => {
|
|
163
|
+
meta.url = createImportMetaUrl(url, cwdFileUrl);
|
|
164
|
+
},
|
|
165
|
+
importModuleDynamically: async (specifier) => {
|
|
166
|
+
return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
esmModuleCache.set(url, sourceTextModule);
|
|
170
|
+
await sourceTextModule.link(async (specifier) => {
|
|
171
|
+
return loadResolvedModule(specifier, url, options);
|
|
172
|
+
});
|
|
173
|
+
return sourceTextModule;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { createScriptNode, loadScriptNode };
|
|
178
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","names":[],"sources":["../src/node.ts"],"sourcesContent":["import { CreateScriptHookNode, FetchHook } from './types';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\n\nconst sdkImportCache = new Map<string, Promise<any>>();\n\nfunction importNodeModule<T>(name: string): Promise<T> {\n if (!name) {\n throw new Error('import specifier is required');\n }\n\n // Check cache to prevent infinite recursion\n if (sdkImportCache.has(name)) {\n return sdkImportCache.get(name)!;\n }\n\n const importModule = new Function('name', `return import(name)`);\n const promise = importModule(name)\n .then((res: any) => res as T)\n .catch((error: any) => {\n console.error(`Error importing module ${name}:`, error);\n // Remove from cache on error so it can be retried\n sdkImportCache.delete(name);\n throw error;\n });\n\n // Cache the promise to prevent recursive calls\n sdkImportCache.set(name, promise);\n return promise;\n}\n\nconst lazyLoaderHookFetch = async (\n input: RequestInfo | URL,\n init?: RequestInit,\n loaderHook?: any,\n): Promise<Response> => {\n const hook = (url: RequestInfo | URL, init: RequestInit) => {\n return loaderHook.lifecycle.fetch.emit(url, init);\n };\n\n const res = await hook(input, init || {});\n if (!res || !(res instanceof Response)) {\n return fetch(input, init || {});\n }\n\n return res;\n};\n\nexport const createScriptNode =\n typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'\n ? (\n url: string,\n cb: (error?: Error, scriptContext?: any) => void,\n attrs?: Record<string, any>,\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n fetch?: FetchHook;\n },\n ) => {\n if (loaderHook?.createScriptHook) {\n const hookResult = loaderHook.createScriptHook(url);\n if (\n hookResult &&\n typeof hookResult === 'object' &&\n 'url' in hookResult\n ) {\n url = hookResult.url;\n }\n }\n\n let urlObj: URL;\n try {\n urlObj = new URL(url);\n } catch (e) {\n console.error('Error constructing URL:', e);\n cb(new Error(`Invalid URL: ${e}`));\n return;\n }\n\n const getFetch = async (): Promise<typeof fetch> => {\n if (loaderHook?.fetch) {\n return (input: RequestInfo | URL, init?: RequestInit) =>\n lazyLoaderHookFetch(input, init, loaderHook);\n }\n\n return fetch;\n };\n\n const handleScriptFetch = async (f: typeof fetch, urlObj: URL) => {\n try {\n const res = await f(urlObj.href);\n const data = await res.text();\n const [path, vm] = await Promise.all([\n importNodeModule<typeof import('path')>('path'),\n importNodeModule<typeof import('vm')>('vm'),\n ]);\n\n const scriptContext = { exports: {}, module: { exports: {} } };\n const urlDirname = urlObj.pathname\n .split('/')\n .slice(0, -1)\n .join('/');\n const filename = path.basename(urlObj.pathname);\n\n const script = new vm.Script(\n `(function(exports, module, require, __dirname, __filename) {${data}\\n})`,\n {\n filename,\n importModuleDynamically:\n //@ts-ignore\n vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ??\n importNodeModule,\n },\n );\n\n let requireFn: NodeRequire;\n if (process.env.IS_ESM_BUILD === 'true') {\n const nodeModule =\n await importNodeModule<typeof import('node:module')>(\n 'node:module',\n );\n requireFn = nodeModule.createRequire(\n urlObj.protocol === 'file:' || urlObj.protocol === 'node:'\n ? urlObj.href\n : path.join(process.cwd(), '__mf_require_base__.js'),\n );\n } else {\n requireFn = eval('require') as NodeRequire;\n }\n\n script.runInThisContext()(\n scriptContext.exports,\n scriptContext.module,\n requireFn,\n urlDirname,\n filename,\n );\n const exportedInterface: Record<string, any> =\n scriptContext.module.exports || scriptContext.exports;\n\n if (attrs && exportedInterface && attrs['globalName']) {\n const container =\n exportedInterface[attrs['globalName']] || exportedInterface;\n cb(\n undefined,\n container as keyof typeof scriptContext.module.exports,\n );\n return;\n }\n\n cb(\n undefined,\n exportedInterface as keyof typeof scriptContext.module.exports,\n );\n } catch (e) {\n cb(\n e instanceof Error\n ? e\n : new Error(`Script execution error: ${e}`),\n );\n }\n };\n\n getFetch()\n .then(async (f) => {\n if (attrs?.['type'] === 'esm' || attrs?.['type'] === 'module') {\n return loadModule(urlObj.href, {\n fetch: f,\n vm: await importNodeModule<typeof import('vm')>('vm'),\n })\n .then(async (module) => {\n await module.evaluate();\n cb(undefined, module.namespace);\n })\n .catch((e) => {\n cb(\n e instanceof Error\n ? e\n : new Error(`Script execution error: ${e}`),\n );\n });\n }\n handleScriptFetch(f, urlObj);\n })\n .catch((err) => {\n cb(err);\n });\n }\n : (\n url: string,\n cb: (error?: Error, scriptContext?: any) => void,\n attrs?: Record<string, any>,\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n fetch?: FetchHook;\n },\n ) => {\n cb(\n new Error('createScriptNode is disabled in non-Node.js environment'),\n );\n };\n\nexport const loadScriptNode =\n typeof ENV_TARGET === 'undefined' || ENV_TARGET !== 'web'\n ? (\n url: string,\n info: {\n attrs?: Record<string, any>;\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n };\n },\n ) => {\n return new Promise<void>((resolve, reject) => {\n createScriptNode(\n url,\n (error, scriptContext) => {\n if (error) {\n reject(error);\n } else {\n const remoteEntryKey =\n info?.attrs?.['globalName'] ||\n `__FEDERATION_${info?.attrs?.['name']}:custom__`;\n const entryExports = ((globalThis as any)[remoteEntryKey] =\n scriptContext);\n resolve(entryExports);\n }\n },\n info.attrs,\n info.loaderHook,\n );\n });\n }\n : (\n url: string,\n info: {\n attrs?: Record<string, any>;\n loaderHook?: {\n createScriptHook?: CreateScriptHookNode;\n };\n },\n ) => {\n throw new Error(\n 'loadScriptNode is disabled in non-Node.js environment',\n );\n };\n\nconst esmModuleCache = new Map<string, any>();\n\ntype LoadModuleOptions = {\n vm: typeof import('vm') & {\n SourceTextModule: any;\n SyntheticModule: any;\n };\n fetch: typeof fetch;\n};\n\nconst isFetchableRemoteModuleUrl = (url: string): boolean =>\n url.startsWith('http:') || url.startsWith('https:');\n\nconst isBareModuleSpecifier = (specifier: string): boolean =>\n !specifier.startsWith('./') &&\n !specifier.startsWith('../') &&\n !specifier.startsWith('/') &&\n !specifier.includes(':');\n\nfunction encodeRemoteModulePath(url: string): string {\n const remoteUrl = new URL(url);\n const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));\n const encodedHost = encodeURIComponent(remoteUrl.host);\n const encodedPathname = remoteUrl.pathname\n .split('/')\n .map((segment) => encodeURIComponent(segment))\n .join('/');\n const encodedSearchHash = encodeURIComponent(\n `${remoteUrl.search}${remoteUrl.hash}`,\n );\n const encodedSuffix = encodedSearchHash ? `/${encodedSearchHash}` : '';\n\n return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSuffix}`;\n}\n\nfunction createImportMetaUrl(url: string, baseFileUrl: string): string {\n const baseUrl = baseFileUrl.endsWith('/') ? baseFileUrl : `${baseFileUrl}/`;\n return new URL(\n `__module_federation_remote__${encodeRemoteModulePath(url)}`,\n baseUrl,\n ).href;\n}\n\nasync function isNodeBuiltinSpecifier(specifier: string): Promise<boolean> {\n if (specifier.startsWith('node:')) {\n return true;\n }\n\n if (!isBareModuleSpecifier(specifier)) {\n return false;\n }\n\n const nodeModule =\n await importNodeModule<typeof import('node:module')>('node:module');\n\n return nodeModule.builtinModules.includes(specifier);\n}\n\nfunction getSyntheticModuleExports(moduleExports: any): Record<string, any> {\n const namespaceObject =\n moduleExports &&\n (typeof moduleExports === 'object' || typeof moduleExports === 'function')\n ? moduleExports\n : { default: moduleExports };\n const effectiveExports = { ...namespaceObject };\n\n if (!Object.prototype.hasOwnProperty.call(effectiveExports, 'default')) {\n effectiveExports.default = namespaceObject;\n }\n\n return effectiveExports;\n}\n\nasync function createSyntheticModuleFromExports(\n identifier: string,\n moduleExports: any,\n vm: LoadModuleOptions['vm'],\n) {\n if (typeof vm.SyntheticModule !== 'function') {\n throw new Error(\n 'vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.',\n );\n }\n\n const effectiveExports = getSyntheticModuleExports(moduleExports);\n const exportNames = Object.keys(effectiveExports);\n const syntheticModule = new vm.SyntheticModule(\n exportNames,\n function setSyntheticModuleExports(this: {\n setExport: (name: string, value: any) => void;\n }) {\n for (const name of exportNames) {\n this.setExport(name, effectiveExports[name]);\n }\n },\n { identifier },\n );\n\n esmModuleCache.set(identifier, syntheticModule);\n await syntheticModule.link(async () => {\n throw new Error(\n `Node.js built-in module \"${identifier}\" should not request child modules.`,\n );\n });\n await syntheticModule.evaluate();\n\n return syntheticModule;\n}\n\nasync function loadNodeBuiltinModule(\n specifier: string,\n vm: LoadModuleOptions['vm'],\n) {\n const cacheKey = `node-builtin:${specifier}`;\n if (esmModuleCache.has(cacheKey)) {\n return esmModuleCache.get(cacheKey)!;\n }\n\n const moduleExports = await importNodeModule(specifier);\n return createSyntheticModuleFromExports(cacheKey, moduleExports, vm);\n}\n\nasync function loadResolvedModule(\n specifier: string,\n parentUrl: string,\n options: LoadModuleOptions,\n) {\n if (await isNodeBuiltinSpecifier(specifier)) {\n return loadNodeBuiltinModule(specifier, options.vm);\n }\n\n if (isBareModuleSpecifier(specifier)) {\n throw new Error(\n `Unsupported ESM module specifier \"${specifier}\". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n const resolvedUrl = new URL(specifier, parentUrl).href;\n if (!isFetchableRemoteModuleUrl(resolvedUrl)) {\n throw new Error(\n `Unsupported ESM module specifier \"${specifier}\" resolved to \"${resolvedUrl}\". Only http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n return loadModule(resolvedUrl, options);\n}\n\nasync function evaluateDynamicModule(module: any) {\n if (module.status === 'linked') {\n await module.evaluate();\n }\n\n if (module.status === 'errored') {\n throw module.error;\n }\n\n return module;\n}\n\nasync function loadModule(url: string, options: LoadModuleOptions) {\n // Check cache to prevent infinite recursion in ESM loading\n if (esmModuleCache.has(url)) {\n return esmModuleCache.get(url)!;\n }\n\n const { fetch, vm } = options;\n if (!isFetchableRemoteModuleUrl(url)) {\n throw new Error(\n `Unsupported ESM module URL \"${url}\". Only http(s) remote modules and Node.js built-in modules are supported.`,\n );\n }\n\n const response = await fetch(url);\n const code = await response.text();\n const nodeUrl = await importNodeModule<typeof import('node:url')>('node:url');\n const cwdFileUrl = nodeUrl.pathToFileURL(process.cwd()).href;\n\n const sourceTextModule: any = new vm.SourceTextModule(code, {\n identifier: url,\n initializeImportMeta: (meta: { url: string }) => {\n meta.url = createImportMetaUrl(url, cwdFileUrl);\n },\n importModuleDynamically: async (specifier: string) => {\n return evaluateDynamicModule(\n await loadResolvedModule(specifier, url, options),\n );\n },\n });\n\n // Cache the module before linking to prevent cycles\n esmModuleCache.set(url, sourceTextModule);\n\n await sourceTextModule.link(async (specifier: string) => {\n return loadResolvedModule(specifier, url, options);\n });\n\n return sourceTextModule;\n}\n"],"mappings":";AAKA,MAAM,iCAAiB,IAAI,KAA2B;AAEtD,SAAS,iBAAoB,MAA0B;AACrD,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,+BAA+B;AAIjD,KAAI,eAAe,IAAI,KAAK,CAC1B,QAAO,eAAe,IAAI,KAAK;CAIjC,MAAM,UADe,IAAI,SAAS,QAAQ,sBAAsB,CACnC,KAAK,CAC/B,MAAM,QAAa,IAAS,CAC5B,OAAO,UAAe;AACrB,UAAQ,MAAM,0BAA0B,KAAK,IAAI,MAAM;AAEvD,iBAAe,OAAO,KAAK;AAC3B,QAAM;GACN;AAGJ,gBAAe,IAAI,MAAM,QAAQ;AACjC,QAAO;;AAGT,MAAM,sBAAsB,OAC1B,OACA,MACA,eACsB;CACtB,MAAM,QAAQ,KAAwB,SAAsB;AAC1D,SAAO,WAAW,UAAU,MAAM,KAAK,KAAK,KAAK;;CAGnD,MAAM,MAAM,MAAM,KAAK,OAAO,QAAQ,EAAE,CAAC;AACzC,KAAI,CAAC,OAAO,EAAE,eAAe,UAC3B,QAAO,MAAM,OAAO,QAAQ,EAAE,CAAC;AAGjC,QAAO;;AAGT,MAAa,mBACX,OAAO,eAAe,eAAe,eAAe,SAE9C,KACA,IACA,OACA,eAIG;AACH,KAAI,YAAY,kBAAkB;EAChC,MAAM,aAAa,WAAW,iBAAiB,IAAI;AACnD,MACE,cACA,OAAO,eAAe,YACtB,SAAS,WAET,OAAM,WAAW;;CAIrB,IA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,MAAM,mBAAmB,WAAW,KAAK,QAAQ,CAClD;;EAEJ,CAAC;AAGF,gBAAe,IAAI,KAAK,iBAAiB;AAEzC,OAAM,iBAAiB,KAAK,OAAO,cAAsB;AACvD,SAAO,mBAAmB,WAAW,KAAK,QAAQ;GAClD;AAEF,QAAO"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
|
|
4
|
+
//#region src/normalize-webpack-path.ts
|
|
5
|
+
function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
6
|
+
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
|
|
7
|
+
try {
|
|
8
|
+
compiler.webpack();
|
|
9
|
+
return "";
|
|
10
|
+
} catch (err) {
|
|
11
|
+
const webpackPath = ((err.stack?.split("\n") || []).find((item) => item.includes("at webpack")) || "").replace(/[^\(\)]+/, "").slice(1, -1).split(":").slice(0, -2).join(":");
|
|
12
|
+
if (options?.framework === "nextjs") {
|
|
13
|
+
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
return resolveWithContext("webpack", { paths: [webpackPath] });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const normalizeWebpackPath = (fullPath) => {
|
|
20
|
+
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
|
|
21
|
+
if (process.env["FEDERATION_WEBPACK_PATH"]) return (0, node_path.resolve)(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
|
|
22
|
+
return fullPath;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.getWebpackPath = getWebpackPath;
|
|
27
|
+
exports.normalizeWebpackPath = normalizeWebpackPath;
|
|
28
|
+
//# sourceMappingURL=normalize-webpack-path.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-webpack-path.cjs","names":[],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { resolve } from 'node:path';\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\n const resolveWithContext = new Function(\n 'id',\n 'options',\n 'return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)',\n ) as (id: string, options?: { paths?: string[] }) => string;\n\n try {\n // @ts-ignore just throw err\n compiler.webpack();\n return '';\n } catch (err) {\n const trace = (err as Error).stack?.split('\\n') || [];\n const webpackErrLocation =\n trace.find((item) => item.includes('at webpack')) || '';\n const webpackLocationWithDetail = webpackErrLocation\n .replace(/[^\\(\\)]+/, '')\n .slice(1, -1);\n const webpackPath = webpackLocationWithDetail\n .split(':')\n .slice(0, -2)\n .join(':');\n if (options?.framework === 'nextjs') {\n if (webpackPath.endsWith('webpack.js')) {\n return webpackPath.replace('webpack.js', 'index.js');\n }\n return '';\n }\n return resolveWithContext('webpack', { paths: [webpackPath] });\n }\n}\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n return resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n fullPath.replace('webpack', '../../'),\n );\n }\n\n return fullPath;\n};\n"],"mappings":";;;;AAGA,SAAgB,eACd,UACA,UAA6C,EAAE,WAAW,SAAS,EAC3D;CACR,MAAM,qBAAqB,IAAI,SAC7B,MACA,WACA,gFACD;AAED,KAAI;AAEF,WAAS,SAAS;AAClB,SAAO;UACA,KAAK;EAOZ,MAAM,gBANS,IAAc,OAAO,MAAM,KAAK,IAAI,EAAE,EAE7C,MAAM,SAAS,KAAK,SAAS,aAAa,CAAC,IAAI,IAEpD,QAAQ,YAAY,GAAG,CACvB,MAAM,GAAG,GAAG,CAEZ,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;AACZ,MAAI,SAAS,cAAc,UAAU;AACnC,OAAI,YAAY,SAAS,aAAa,CACpC,QAAO,YAAY,QAAQ,cAAc,WAAW;AAEtD,UAAO;;AAET,SAAO,mBAAmB,WAAW,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;;;AAIlE,MAAa,wBAAwB,aAA6B;AAChE,KAAI,aAAa,UACf,QAAO,QAAQ,IAAI,8BAA8B;AAGnD,KAAI,QAAQ,IAAI,2BACd,+BACE,QAAQ,IAAI,4BACZ,SAAS,QAAQ,WAAW,SAAS,CACtC;AAGH,QAAO"}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import webpack from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/normalize-webpack-path.d.ts
|
|
4
|
+
declare function getWebpackPath(compiler: webpack.Compiler, options?: {
|
|
5
|
+
framework: 'nextjs' | 'other';
|
|
6
|
+
}): string;
|
|
7
|
+
declare const normalizeWebpackPath: (fullPath: string) => string;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getWebpackPath, normalizeWebpackPath };
|
|
10
|
+
//# sourceMappingURL=normalize-webpack-path.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
|
|
3
|
+
//#region src/normalize-webpack-path.ts
|
|
4
|
+
function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
5
|
+
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
|
|
6
|
+
try {
|
|
7
|
+
compiler.webpack();
|
|
8
|
+
return "";
|
|
9
|
+
} catch (err) {
|
|
10
|
+
const webpackPath = ((err.stack?.split("\n") || []).find((item) => item.includes("at webpack")) || "").replace(/[^\(\)]+/, "").slice(1, -1).split(":").slice(0, -2).join(":");
|
|
11
|
+
if (options?.framework === "nextjs") {
|
|
12
|
+
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return resolveWithContext("webpack", { paths: [webpackPath] });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const normalizeWebpackPath = (fullPath) => {
|
|
19
|
+
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
|
|
20
|
+
if (process.env["FEDERATION_WEBPACK_PATH"]) return resolve(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
|
|
21
|
+
return fullPath;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getWebpackPath, normalizeWebpackPath };
|
|
26
|
+
//# sourceMappingURL=normalize-webpack-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-webpack-path.js","names":[],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { resolve } from 'node:path';\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\n const resolveWithContext = new Function(\n 'id',\n 'options',\n 'return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)',\n ) as (id: string, options?: { paths?: string[] }) => string;\n\n try {\n // @ts-ignore just throw err\n compiler.webpack();\n return '';\n } catch (err) {\n const trace = (err as Error).stack?.split('\\n') || [];\n const webpackErrLocation =\n trace.find((item) => item.includes('at webpack')) || '';\n const webpackLocationWithDetail = webpackErrLocation\n .replace(/[^\\(\\)]+/, '')\n .slice(1, -1);\n const webpackPath = webpackLocationWithDetail\n .split(':')\n .slice(0, -2)\n .join(':');\n if (options?.framework === 'nextjs') {\n if (webpackPath.endsWith('webpack.js')) {\n return webpackPath.replace('webpack.js', 'index.js');\n }\n return '';\n }\n return resolveWithContext('webpack', { paths: [webpackPath] });\n }\n}\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n return resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n fullPath.replace('webpack', '../../'),\n );\n }\n\n return fullPath;\n};\n"],"mappings":";;;AAGA,SAAgB,eACd,UACA,UAA6C,EAAE,WAAW,SAAS,EAC3D;CACR,MAAM,qBAAqB,IAAI,SAC7B,MACA,WACA,gFACD;AAED,KAAI;AAEF,WAAS,SAAS;AAClB,SAAO;UACA,KAAK;EAOZ,MAAM,gBANS,IAAc,OAAO,MAAM,KAAK,IAAI,EAAE,EAE7C,MAAM,SAAS,KAAK,SAAS,aAAa,CAAC,IAAI,IAEpD,QAAQ,YAAY,GAAG,CACvB,MAAM,GAAG,GAAG,CAEZ,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;AACZ,MAAI,SAAS,cAAc,UAAU;AACnC,OAAI,YAAY,SAAS,aAAa,CACpC,QAAO,YAAY,QAAQ,cAAc,WAAW;AAEtD,UAAO;;AAET,SAAO,mBAAmB,WAAW,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;;;AAIlE,MAAa,wBAAwB,aAA6B;AAChE,KAAI,aAAa,UACf,QAAO,QAAQ,IAAI,8BAA8B;AAGnD,KAAI,QAAQ,IAAI,2BACd,QAAO,QACL,QAAQ,IAAI,4BACZ,SAAS,QAAQ,WAAW,SAAS,CACtC;AAGH,QAAO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/normalizeOptions.ts
|
|
3
|
+
function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
4
|
+
return function(options) {
|
|
5
|
+
if (options === false) return false;
|
|
6
|
+
if (typeof options === "undefined") if (enableDefault) return defaultOptions;
|
|
7
|
+
else return false;
|
|
8
|
+
if (options === true) return defaultOptions;
|
|
9
|
+
if (options && typeof options === "object") return {
|
|
10
|
+
...defaultOptions,
|
|
11
|
+
...options
|
|
12
|
+
};
|
|
13
|
+
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.normalizeOptions = normalizeOptions;
|
|
19
|
+
//# sourceMappingURL=normalizeOptions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeOptions.cjs","names":[],"sources":["../src/normalizeOptions.ts"],"sourcesContent":["export function normalizeOptions<T>(\n enableDefault: boolean,\n defaultOptions: T,\n key: string,\n) {\n return function <U extends boolean | undefined | T>(options: U): T | false {\n if (options === false) {\n return false;\n }\n\n if (typeof options === 'undefined') {\n if (enableDefault) {\n return defaultOptions;\n } else {\n return false;\n }\n }\n\n if (options === true) {\n return defaultOptions;\n }\n\n if (options && typeof options === 'object') {\n return {\n ...(defaultOptions as T),\n ...options,\n };\n }\n\n throw new Error(\n `Unexpected type for \\`${key}\\`, expect boolean/undefined/object, got: ${typeof options}`,\n );\n };\n}\n"],"mappings":";;AAAA,SAAgB,iBACd,eACA,gBACA,KACA;AACA,QAAO,SAA6C,SAAuB;AACzE,MAAI,YAAY,MACd,QAAO;AAGT,MAAI,OAAO,YAAY,YACrB,KAAI,cACF,QAAO;MAEP,QAAO;AAIX,MAAI,YAAY,KACd,QAAO;AAGT,MAAI,WAAW,OAAO,YAAY,SAChC,QAAO;GACL,GAAI;GACJ,GAAG;GACJ;AAGH,QAAM,IAAI,MACR,yBAAyB,IAAI,4CAA4C,OAAO,UACjF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/normalizeOptions.d.ts
|
|
2
|
+
declare function normalizeOptions<T>(enableDefault: boolean, defaultOptions: T, key: string): <U extends boolean | undefined | T>(options: U) => T | false;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { normalizeOptions };
|
|
5
|
+
//# sourceMappingURL=normalizeOptions.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/normalizeOptions.ts
|
|
2
|
+
function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
3
|
+
return function(options) {
|
|
4
|
+
if (options === false) return false;
|
|
5
|
+
if (typeof options === "undefined") if (enableDefault) return defaultOptions;
|
|
6
|
+
else return false;
|
|
7
|
+
if (options === true) return defaultOptions;
|
|
8
|
+
if (options && typeof options === "object") return {
|
|
9
|
+
...defaultOptions,
|
|
10
|
+
...options
|
|
11
|
+
};
|
|
12
|
+
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { normalizeOptions };
|
|
18
|
+
//# sourceMappingURL=normalizeOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeOptions.js","names":[],"sources":["../src/normalizeOptions.ts"],"sourcesContent":["export function normalizeOptions<T>(\n enableDefault: boolean,\n defaultOptions: T,\n key: string,\n) {\n return function <U extends boolean | undefined | T>(options: U): T | false {\n if (options === false) {\n return false;\n }\n\n if (typeof options === 'undefined') {\n if (enableDefault) {\n return defaultOptions;\n } else {\n return false;\n }\n }\n\n if (options === true) {\n return defaultOptions;\n }\n\n if (options && typeof options === 'object') {\n return {\n ...(defaultOptions as T),\n ...options,\n };\n }\n\n throw new Error(\n `Unexpected type for \\`${key}\\`, expect boolean/undefined/object, got: ${typeof options}`,\n );\n };\n}\n"],"mappings":";AAAA,SAAgB,iBACd,eACA,gBACA,KACA;AACA,QAAO,SAA6C,SAAuB;AACzE,MAAI,YAAY,MACd,QAAO;AAGT,MAAI,OAAO,YAAY,YACrB,KAAI,cACF,QAAO;MAEP,QAAO;AAIX,MAAI,YAAY,KACd,QAAO;AAGT,MAAI,WAAW,OAAO,YAAY,SAChC,QAAO;GACL,GAAI;GACJ,GAAG;GACJ;AAGH,QAAM,IAAI,MACR,yBAAyB,IAAI,4CAA4C,OAAO,UACjF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/types/common.d.ts
|
|
2
|
+
interface RemoteWithEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
entry: string;
|
|
5
|
+
}
|
|
6
|
+
interface RemoteWithVersion {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
type RemoteEntryInfo = RemoteWithEntry | RemoteWithVersion;
|
|
11
|
+
type Module = any;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion };
|
|
14
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/types/hooks.d.ts
|
|
2
|
+
type CreateScriptHookReturnNode = {
|
|
3
|
+
url: string;
|
|
4
|
+
} | void;
|
|
5
|
+
type CreateScriptHookReturnDom = HTMLScriptElement | {
|
|
6
|
+
script?: HTMLScriptElement;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
} | void;
|
|
9
|
+
type CreateLinkHookReturnDom = HTMLLinkElement | {
|
|
10
|
+
link?: HTMLLinkElement;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
} | void;
|
|
13
|
+
type CreateScriptHookReturn = CreateScriptHookReturnNode | CreateScriptHookReturnDom;
|
|
14
|
+
type CreateScriptHookNode = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnNode;
|
|
15
|
+
type CreateScriptHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnDom;
|
|
16
|
+
type CreateLinkHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateLinkHookReturnDom;
|
|
17
|
+
type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
18
|
+
type FetchHook = (args: [string, RequestInit]) => Promise<Response> | void | false;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook };
|
|
21
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion } from "./common.js";
|
|
2
|
+
import { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared } from "./stats.js";
|
|
3
|
+
import { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared } from "./manifest.js";
|
|
4
|
+
import { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider } from "./snapshot.js";
|
|
5
|
+
import { ModuleFederationPlugin_d_exports } from "./plugins/ModuleFederationPlugin.js";
|
|
6
|
+
import { ContainerPlugin_d_exports } from "./plugins/ContainerPlugin.js";
|
|
7
|
+
import { ContainerReferencePlugin_d_exports } from "./plugins/ContainerReferencePlugin.js";
|
|
8
|
+
import { SharePlugin_d_exports } from "./plugins/SharePlugin.js";
|
|
9
|
+
import { ConsumeSharedPlugin_d_exports } from "./plugins/ConsumeSharedPlugin.js";
|
|
10
|
+
import { ProvideSharedPlugin_d_exports } from "./plugins/ProvideSharedPlugin.js";
|
|
11
|
+
import { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook } from "./hooks.js";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RemoteWithEntry, RemoteWithVersion } from "./common.js";
|
|
2
|
+
import { BasicStatsMetaData, RemoteEntryType, StatsAssets, StatsExpose, StatsMetaData } from "./stats.js";
|
|
3
|
+
|
|
4
|
+
//#region src/types/manifest.d.ts
|
|
5
|
+
interface ManifestShared {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
singleton: boolean;
|
|
10
|
+
requiredVersion: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
assets: StatsAssets;
|
|
13
|
+
fallback?: string;
|
|
14
|
+
fallbackName?: string;
|
|
15
|
+
fallbackType?: RemoteEntryType;
|
|
16
|
+
}
|
|
17
|
+
interface ManifestRemoteCommonInfo {
|
|
18
|
+
federationContainerName: string;
|
|
19
|
+
moduleName: string;
|
|
20
|
+
alias: string;
|
|
21
|
+
}
|
|
22
|
+
type ManifestRemote<T = ManifestRemoteCommonInfo> = (Omit<RemoteWithEntry, 'name'> & T) | (Omit<RemoteWithVersion, 'name'> & T);
|
|
23
|
+
type ManifestExpose = Pick<StatsExpose, 'assets' | 'id' | 'name' | 'path'>;
|
|
24
|
+
interface Manifest<T = BasicStatsMetaData, K = ManifestRemoteCommonInfo> {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
metaData: StatsMetaData<T>;
|
|
28
|
+
shared: ManifestShared[];
|
|
29
|
+
remotes: ManifestRemote<K>[];
|
|
30
|
+
exposes: ManifestExpose[];
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared };
|
|
34
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/types/plugins/ConsumeSharedPlugin.ts
|
|
4
|
+
var ConsumeSharedPlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
Object.defineProperty(exports, 'ConsumeSharedPlugin_exports', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return ConsumeSharedPlugin_exports;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=ConsumeSharedPlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsumeSharedPlugin.cjs","names":[],"sources":["../../../src/types/plugins/ConsumeSharedPlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\n/**\n * A module that should be consumed from share scope.\n */\nexport type ConsumesItem = string;\n\n/**\n * Advanced configuration for modules that should be consumed from share scope.\n */\nexport interface ConsumesConfig {\n /**\n * Include the fallback module directly instead behind an async request. This allows to use fallback module in initial load too. All possible shared modules need to be eager too.\n */\n eager?: boolean;\n /**\n * Fallback module if no shared module is found in share scope. Defaults to the property name.\n */\n import?: false | ConsumesItem;\n /**\n * Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.\n */\n packageName?: string;\n /**\n * Version requirement from module in share scope.\n */\n requiredVersion?: false | string;\n /**\n * Module is looked up under this key from the share scope.\n */\n shareKey?: string;\n /**\n * Share scope name.\n */\n shareScope?: string | string[];\n /**\n * Layer in which the shared module should be placed.\n */\n layer?: string;\n /**\n * Layer of the issuer.\n */\n issuerLayer?: string;\n /**\n * Import request to match on\n */\n request?: string;\n /**\n * Allow only a single version of the shared module in share scope (disabled by default).\n */\n singleton?: boolean;\n /**\n * 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).\n */\n strictVersion?: boolean;\n /**\n * Filter consumed modules based on the request path.\n */\n exclude?: IncludeExcludeOptions;\n /**\n * Filter consumed modules based on the request path (only include matches).\n */\n include?: IncludeExcludeOptions;\n /**\n * Enable reconstructed lookup for node_modules paths for this share item\n */\n allowNodeModulesSuffixMatch?: boolean;\n /**\n * Tree shaking mode for the shared module.\n */\n treeShakingMode?: 'server-calc' | 'runtime-infer';\n}\n\n/**\n * Modules that should be consumed from 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.\n */\nexport interface ConsumesObject {\n [k: string]: ConsumesConfig | ConsumesItem;\n}\n\n/**\n * Modules that should be consumed from share scope. When provided, property names are used to match requested modules in this compilation.\n */\nexport type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;\n\nexport interface IncludeExcludeOptions {\n request?: string | RegExp;\n /**\n * Semantic versioning range to match against the module's version.\n */\n version?: string;\n /**\n * Optional specific version string to check against the version range instead of reading package.json.\n */\n fallbackVersion?: string;\n}\n\nexport interface ConsumeSharedPluginOptions {\n consumes: Consumes;\n /**\n * Share scope name used for all consumed modules (defaults to 'default').\n */\n shareScope?: string | string[];\n /**\n * Experimental features configuration\n */\n experiments?: {\n /** Enable reconstructed lookup for node_modules paths */\n allowNodeModulesSuffixMatch?: boolean;\n };\n}\n"],"mappings":""}
|