Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

21
node_modules/@module-federation/sdk/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023-present zhanghang(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

105
node_modules/@module-federation/sdk/README.md generated vendored Normal file
View File

@@ -0,0 +1,105 @@
# `@module-federation/sdk` Documentation
- This SDK provides utilities and tools to support the implementation of Module Federation in your projects.
- It contains utility functions for parsing, encoding, and decoding module names, as well as generating filenames for exposed modules and shared packages.
- It also includes a logger for debugging and environment detection utilities.
- Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.
## Usage
```javascript
// The SDK can be used to parse entry strings, encode and decode module names, and generate filenames for exposed modules and shared packages.
// It also includes a logger for debugging and environment detection utilities.
// Additionally, it provides a function to generate a snapshot from a manifest and environment detection utilities.
import { parseEntry, encodeName, decodeName, generateExposeFilename, generateShareFilename, createLogger, isBrowserEnv, isBrowserEnvValue, isDebugMode, getProcessEnv, generateSnapshotFromManifest } from '@module-federation/sdk';
// Parse an entry string into a RemoteEntryInfo object
parseEntry('entryString');
// Encode a module name with a prefix and optional extension
encodeName('moduleName', 'prefix');
// Decode a module name with a prefix and optional extension
decodeName('encodedModuleName', 'prefix');
// Generate a filename for an exposed module
generateExposeFilename('exposeName', true);
// Generate a filename for a shared package
generateShareFilename('packageName', true);
// Create a logger
const logger = createLogger('identifier');
// Check if the current environment is a browser
const inBrowser = isBrowserEnv();
const inBrowserStatic = isBrowserEnvValue;
// Check if the current environment is in debug mode
isDebugMode();
// Get the process environment
getProcessEnv();
// Generate a snapshot from a manifest
generateSnapshotFromManifest(manifest, options);
```
### parseEntry
- Type: `parseEntry(str: string, devVerOrUrl?: string, separator?: string) `
- Parses a string into a RemoteEntryInfo object.
### encodeName
- Type: `encodeName(name: string, prefix?: string, withExt?: boolean)`
- Encodes a name with a prefix and optional extension.
### decodeName
- Type: `decodeName(name: string, prefix?: string, withExt?: boolean)`
- Decodes a name with a prefix and optional extension.
### generateExposeFilename
- Type: `generateExposeFilename(exposeName: string, withExt: boolean)`
- Generates a filename for an expose.
### generateShareFilename
- Type: `generateShareFilename(pkgName: string, withExt: boolean)`
- Generates a filename for a shared package.
### createLogger
- Type: `createLogger(prefix: string)`
- Creates a logger for debugging.
### isBrowserEnv
- Type: `isBrowserEnv(): boolean`
- Checks if the current environment is a browser.
### isBrowserEnvValue
- Type: `isBrowserEnvValue: boolean`
- Static browser environment flag (tree-shakable when ENV_TARGET is defined).
### isDebugMode
- Type: `isDebugMode()`
- Checks if the current environment is in debug mode.
### getProcessEnv
- Type: `getProcessEnv()`
- Gets the process environment.
### generateSnapshotFromManifest
- Type: `generateSnapshotFromManifest(manifest: Manifest, options?: IOptions)`
- Generates a snapshot from a manifest.
## Testing
The SDK uses Jest for testing. The configuration can be found in `jest.config.js`. The tests are located in the **tests** directory.

21
node_modules/@module-federation/sdk/dist/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023-present zhanghang(2heal1)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,19 @@
//#region \0rolldown/runtime.js
var __defProp = Object.defineProperty;
var __exportAll = (all, no_symbols) => {
let target = {};
for (var name in all) {
__defProp(target, name, {
get: all[name],
enumerable: true
});
}
if (!no_symbols) {
__defProp(target, Symbol.toStringTag, { value: "Module" });
}
return target;
};
//#endregion
exports.__exportAll = __exportAll;

View File

@@ -0,0 +1,18 @@
//#region \0rolldown/runtime.js
var __defProp = Object.defineProperty;
var __exportAll = (all, no_symbols) => {
let target = {};
for (var name in all) {
__defProp(target, name, {
get: all[name],
enumerable: true
});
}
if (!no_symbols) {
__defProp(target, Symbol.toStringTag, { value: "Module" });
}
return target;
};
//#endregion
export { __exportAll };

62
node_modules/@module-federation/sdk/dist/constant.cjs generated vendored Normal file
View File

@@ -0,0 +1,62 @@
//#region src/constant.ts
const FederationModuleManifest = "federation-manifest.json";
const MANIFEST_EXT = ".json";
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
const NameTransformSymbol = {
AT: "@",
HYPHEN: "-",
SLASH: "/"
};
const NameTransformMap = {
[NameTransformSymbol.AT]: "scope_",
[NameTransformSymbol.HYPHEN]: "_",
[NameTransformSymbol.SLASH]: "__"
};
const EncodedNameTransformMap = {
[NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
[NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
[NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
};
const SEPARATOR = ":";
const ManifestFileName = "mf-manifest.json";
const StatsFileName = "mf-stats.json";
const MFModuleType = {
NPM: "npm",
APP: "app"
};
const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
const TEMP_DIR = ".federation";
let TreeShakingStatus = /* @__PURE__ */ function(TreeShakingStatus) {
/**
* Not handled by deploy server, needs to infer by the real runtime period.
*/
TreeShakingStatus[TreeShakingStatus["UNKNOWN"] = 1] = "UNKNOWN";
/**
* It means the shared has been calculated , runtime should take this shared as first choice.
*/
TreeShakingStatus[TreeShakingStatus["CALCULATED"] = 2] = "CALCULATED";
/**
* It means the shared has been calculated, and marked as no used
*/
TreeShakingStatus[TreeShakingStatus["NO_USE"] = 0] = "NO_USE";
return TreeShakingStatus;
}({});
//#endregion
exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY;
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
exports.EncodedNameTransformMap = EncodedNameTransformMap;
exports.FederationModuleManifest = FederationModuleManifest;
exports.MANIFEST_EXT = MANIFEST_EXT;
exports.MFModuleType = MFModuleType;
exports.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER;
exports.ManifestFileName = ManifestFileName;
exports.NameTransformMap = NameTransformMap;
exports.NameTransformSymbol = NameTransformSymbol;
exports.SEPARATOR = SEPARATOR;
exports.StatsFileName = StatsFileName;
exports.TEMP_DIR = TEMP_DIR;
exports.TreeShakingStatus = TreeShakingStatus;
//# sourceMappingURL=constant.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constant.cjs","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const FederationModuleManifest = 'federation-manifest.json';\nexport const MANIFEST_EXT = '.json';\n\nexport const BROWSER_LOG_KEY = 'FEDERATION_DEBUG';\n\nexport const NameTransformSymbol = {\n AT: '@',\n HYPHEN: '-',\n SLASH: '/',\n} as const;\nexport const NameTransformMap = {\n [NameTransformSymbol.AT]: 'scope_',\n [NameTransformSymbol.HYPHEN]: '_',\n [NameTransformSymbol.SLASH]: '__',\n} as const;\n\nexport const EncodedNameTransformMap = {\n [NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,\n [NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,\n [NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH,\n};\n\nexport const SEPARATOR = ':';\n\nexport const ManifestFileName = 'mf-manifest.json';\nexport const StatsFileName = 'mf-stats.json';\n\nexport const MFModuleType = {\n NPM: 'npm',\n APP: 'app',\n};\n\nexport const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';\nexport const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';\nexport const TEMP_DIR = '.federation';\n\nexport const enum TreeShakingStatus {\n /**\n * Not handled by deploy server, needs to infer by the real runtime period.\n */\n UNKNOWN = 1,\n /**\n * It means the shared has been calculated , runtime should take this shared as first choice.\n */\n CALCULATED = 2,\n /**\n * It means the shared has been calculated, and marked as no used\n */\n NO_USE = 0,\n}\n"],"mappings":";;AAAA,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAE5B,MAAa,kBAAkB;AAE/B,MAAa,sBAAsB;CACjC,IAAI;CACJ,QAAQ;CACR,OAAO;CACR;AACD,MAAa,mBAAmB;EAC7B,oBAAoB,KAAK;EACzB,oBAAoB,SAAS;EAC7B,oBAAoB,QAAQ;CAC9B;AAED,MAAa,0BAA0B;EACpC,iBAAiB,oBAAoB,MAAM,oBAAoB;EAC/D,iBAAiB,oBAAoB,UAAU,oBAAoB;EACnE,iBAAiB,oBAAoB,SAAS,oBAAoB;CACpE;AAED,MAAa,YAAY;AAEzB,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAE7B,MAAa,eAAe;CAC1B,KAAK;CACL,KAAK;CACN;AAED,MAAa,4BAA4B;AACzC,MAAa,qBAAqB;AAClC,MAAa,WAAW;AAExB,IAAkB,gEAAX;;;;AAIL;;;;AAIA;;;;AAIA"}

46
node_modules/@module-federation/sdk/dist/constant.d.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
//#region src/constant.d.ts
declare const FederationModuleManifest = "federation-manifest.json";
declare const MANIFEST_EXT = ".json";
declare const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
declare const NameTransformSymbol: {
readonly AT: "@";
readonly HYPHEN: "-";
readonly SLASH: "/";
};
declare const NameTransformMap: {
readonly "@": "scope_";
readonly "-": "_";
readonly "/": "__";
};
declare const EncodedNameTransformMap: {
scope_: "@";
_: "-";
__: "/";
};
declare const SEPARATOR = ":";
declare const ManifestFileName = "mf-manifest.json";
declare const StatsFileName = "mf-stats.json";
declare const MFModuleType: {
NPM: string;
APP: string;
};
declare const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
declare const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
declare const TEMP_DIR = ".federation";
declare const enum TreeShakingStatus {
/**
* Not handled by deploy server, needs to infer by the real runtime period.
*/
UNKNOWN = 1,
/**
* It means the shared has been calculated , runtime should take this shared as first choice.
*/
CALCULATED = 2,
/**
* It means the shared has been calculated, and marked as no used
*/
NO_USE = 0
}
//#endregion
export { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus };
//# sourceMappingURL=constant.d.ts.map

48
node_modules/@module-federation/sdk/dist/constant.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
//#region src/constant.ts
const FederationModuleManifest = "federation-manifest.json";
const MANIFEST_EXT = ".json";
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
const NameTransformSymbol = {
AT: "@",
HYPHEN: "-",
SLASH: "/"
};
const NameTransformMap = {
[NameTransformSymbol.AT]: "scope_",
[NameTransformSymbol.HYPHEN]: "_",
[NameTransformSymbol.SLASH]: "__"
};
const EncodedNameTransformMap = {
[NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
[NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
[NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
};
const SEPARATOR = ":";
const ManifestFileName = "mf-manifest.json";
const StatsFileName = "mf-stats.json";
const MFModuleType = {
NPM: "npm",
APP: "app"
};
const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
const TEMP_DIR = ".federation";
let TreeShakingStatus = /* @__PURE__ */ function(TreeShakingStatus) {
/**
* Not handled by deploy server, needs to infer by the real runtime period.
*/
TreeShakingStatus[TreeShakingStatus["UNKNOWN"] = 1] = "UNKNOWN";
/**
* It means the shared has been calculated , runtime should take this shared as first choice.
*/
TreeShakingStatus[TreeShakingStatus["CALCULATED"] = 2] = "CALCULATED";
/**
* It means the shared has been calculated, and marked as no used
*/
TreeShakingStatus[TreeShakingStatus["NO_USE"] = 0] = "NO_USE";
return TreeShakingStatus;
}({});
//#endregion
export { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus };
//# sourceMappingURL=constant.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"constant.js","names":[],"sources":["../src/constant.ts"],"sourcesContent":["export const FederationModuleManifest = 'federation-manifest.json';\nexport const MANIFEST_EXT = '.json';\n\nexport const BROWSER_LOG_KEY = 'FEDERATION_DEBUG';\n\nexport const NameTransformSymbol = {\n AT: '@',\n HYPHEN: '-',\n SLASH: '/',\n} as const;\nexport const NameTransformMap = {\n [NameTransformSymbol.AT]: 'scope_',\n [NameTransformSymbol.HYPHEN]: '_',\n [NameTransformSymbol.SLASH]: '__',\n} as const;\n\nexport const EncodedNameTransformMap = {\n [NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,\n [NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,\n [NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH,\n};\n\nexport const SEPARATOR = ':';\n\nexport const ManifestFileName = 'mf-manifest.json';\nexport const StatsFileName = 'mf-stats.json';\n\nexport const MFModuleType = {\n NPM: 'npm',\n APP: 'app',\n};\n\nexport const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';\nexport const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';\nexport const TEMP_DIR = '.federation';\n\nexport const enum TreeShakingStatus {\n /**\n * Not handled by deploy server, needs to infer by the real runtime period.\n */\n UNKNOWN = 1,\n /**\n * It means the shared has been calculated , runtime should take this shared as first choice.\n */\n CALCULATED = 2,\n /**\n * It means the shared has been calculated, and marked as no used\n */\n NO_USE = 0,\n}\n"],"mappings":";AAAA,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAE5B,MAAa,kBAAkB;AAE/B,MAAa,sBAAsB;CACjC,IAAI;CACJ,QAAQ;CACR,OAAO;CACR;AACD,MAAa,mBAAmB;EAC7B,oBAAoB,KAAK;EACzB,oBAAoB,SAAS;EAC7B,oBAAoB,QAAQ;CAC9B;AAED,MAAa,0BAA0B;EACpC,iBAAiB,oBAAoB,MAAM,oBAAoB;EAC/D,iBAAiB,oBAAoB,UAAU,oBAAoB;EACnE,iBAAiB,oBAAoB,SAAS,oBAAoB;CACpE;AAED,MAAa,YAAY;AAEzB,MAAa,mBAAmB;AAChC,MAAa,gBAAgB;AAE7B,MAAa,eAAe;CAC1B,KAAK;CACL,KAAK;CACN;AAED,MAAa,4BAA4B;AACzC,MAAa,qBAAqB;AAClC,MAAa,WAAW;AAExB,IAAkB,gEAAX;;;;AAIL;;;;AAIA;;;;AAIA"}

View File

@@ -0,0 +1,9 @@
//#region src/createModuleFederationConfig.ts
const createModuleFederationConfig = (options) => {
return options;
};
//#endregion
exports.createModuleFederationConfig = createModuleFederationConfig;
//# sourceMappingURL=createModuleFederationConfig.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createModuleFederationConfig.cjs","names":[],"sources":["../src/createModuleFederationConfig.ts"],"sourcesContent":["import type { moduleFederationPlugin } from './types/plugins';\n\nexport const createModuleFederationConfig = (\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): moduleFederationPlugin.ModuleFederationPluginOptions => {\n return options;\n};\n"],"mappings":";;AAEA,MAAa,gCACX,YACyD;AACzD,QAAO"}

View File

@@ -0,0 +1,6 @@
import { ModuleFederationPluginOptions } from "./types/plugins/ModuleFederationPlugin.js";
//#region src/createModuleFederationConfig.d.ts
declare const createModuleFederationConfig: (options: ModuleFederationPluginOptions) => ModuleFederationPluginOptions;
//#endregion
export { createModuleFederationConfig };
//# sourceMappingURL=createModuleFederationConfig.d.ts.map

View File

@@ -0,0 +1,8 @@
//#region src/createModuleFederationConfig.ts
const createModuleFederationConfig = (options) => {
return options;
};
//#endregion
export { createModuleFederationConfig };
//# sourceMappingURL=createModuleFederationConfig.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"createModuleFederationConfig.js","names":[],"sources":["../src/createModuleFederationConfig.ts"],"sourcesContent":["import type { moduleFederationPlugin } from './types/plugins';\n\nexport const createModuleFederationConfig = (\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): moduleFederationPlugin.ModuleFederationPluginOptions => {\n return options;\n};\n"],"mappings":";AAEA,MAAa,gCACX,YACyD;AACzD,QAAO"}

214
node_modules/@module-federation/sdk/dist/dom.cjs generated vendored Normal file
View File

@@ -0,0 +1,214 @@
const require_utils = require('./utils.cjs');
//#region src/dom.ts
async function safeWrapper(callback, disableWarn) {
try {
return await callback();
} catch (e) {
!disableWarn && require_utils.warn(e);
return;
}
}
function isStaticResourcesEqual(url1, url2) {
const REG_EXP = /^(https?:)?\/\//i;
return url1.replace(REG_EXP, "").replace(/\/$/, "") === url2.replace(REG_EXP, "").replace(/\/$/, "");
}
function createScript(info) {
let script = null;
let needAttach = true;
let timeout = 2e4;
let timeoutId;
const scripts = document.getElementsByTagName("script");
for (let i = 0; i < scripts.length; i++) {
const s = scripts[i];
const scriptSrc = s.getAttribute("src");
if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
script = s;
needAttach = false;
break;
}
}
if (!script) {
const attrs = info.attrs;
script = document.createElement("script");
script.type = attrs?.["type"] === "module" ? "module" : "text/javascript";
let createScriptRes = void 0;
if (info.createScriptHook) {
createScriptRes = info.createScriptHook(info.url, info.attrs);
if (createScriptRes instanceof HTMLScriptElement) script = createScriptRes;
else if (typeof createScriptRes === "object") {
if ("script" in createScriptRes && createScriptRes.script) script = createScriptRes.script;
if ("timeout" in createScriptRes && createScriptRes.timeout) timeout = createScriptRes.timeout;
}
}
if (!script.src) script.src = info.url;
if (attrs && !createScriptRes) Object.keys(attrs).forEach((name) => {
if (script) {
if (name === "async" || name === "defer") script[name] = attrs[name];
else if (!script.getAttribute(name)) script.setAttribute(name, attrs[name]);
}
});
}
let executionError = null;
const executionErrorHandler = typeof window !== "undefined" ? (evt) => {
if (evt.filename && isStaticResourcesEqual(evt.filename, info.url)) {
const err = /* @__PURE__ */ new Error(`ScriptExecutionError: Script "${info.url}" loaded but threw a runtime error during execution: ${evt.message} (${evt.filename}:${evt.lineno}:${evt.colno})`);
err.name = "ScriptExecutionError";
executionError = err;
}
} : null;
if (executionErrorHandler) window.addEventListener("error", executionErrorHandler);
const onScriptComplete = async (prev, event) => {
clearTimeout(timeoutId);
if (executionErrorHandler) window.removeEventListener("error", executionErrorHandler);
const onScriptCompleteCallback = () => {
if (event?.type === "error") {
const networkError = /* @__PURE__ */ new Error(event?.isTimeout ? `ScriptNetworkError: Script "${info.url}" timed out.` : `ScriptNetworkError: Failed to load script "${info.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);
networkError.name = "ScriptNetworkError";
info?.onErrorCallback && info?.onErrorCallback(networkError);
} else if (executionError) info?.onErrorCallback && info?.onErrorCallback(executionError);
else info?.cb && info?.cb();
};
if (script) {
script.onerror = null;
script.onload = null;
safeWrapper(() => {
const { needDeleteScript = true } = info;
if (needDeleteScript) script?.parentNode && script.parentNode.removeChild(script);
});
if (prev && typeof prev === "function") {
const result = prev(event);
if (result instanceof Promise) {
const res = await result;
onScriptCompleteCallback();
return res;
}
onScriptCompleteCallback();
return result;
}
}
onScriptCompleteCallback();
};
script.onerror = onScriptComplete.bind(null, script.onerror);
script.onload = onScriptComplete.bind(null, script.onload);
timeoutId = setTimeout(() => {
onScriptComplete(null, {
type: "error",
isTimeout: true
});
}, timeout);
return {
script,
needAttach
};
}
function createLink(info) {
let link = null;
let needAttach = true;
let timeout = 2e4;
let timeoutId;
const links = document.getElementsByTagName("link");
for (let i = 0; i < links.length; i++) {
const l = links[i];
const linkHref = l.getAttribute("href");
const linkRel = l.getAttribute("rel");
if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) {
link = l;
needAttach = false;
break;
}
}
if (!link) {
link = document.createElement("link");
link.setAttribute("href", info.url);
let createLinkRes = void 0;
let shouldApplyAttrs = true;
const attrs = info.attrs;
if (info.createLinkHook) {
createLinkRes = info.createLinkHook(info.url, attrs);
if (createLinkRes instanceof HTMLLinkElement) {
link = createLinkRes;
shouldApplyAttrs = false;
} else if (typeof createLinkRes === "object") {
if ("link" in createLinkRes && createLinkRes.link) {
link = createLinkRes.link;
shouldApplyAttrs = false;
}
if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
}
}
if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
});
}
if (!needAttach) {
Promise.resolve().then(() => {
info?.cb && info?.cb();
});
return {
link,
needAttach
};
}
const onLinkComplete = (prev, event) => {
if (timeoutId) clearTimeout(timeoutId);
const onLinkCompleteCallback = () => {
if (event?.type === "error") {
const linkError = /* @__PURE__ */ new Error(event?.isTimeout ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);
linkError.name = "LinkNetworkError";
info?.onErrorCallback && info?.onErrorCallback(linkError);
} else info?.cb && info?.cb();
};
if (link) {
link.onerror = null;
link.onload = null;
safeWrapper(() => {
const { needDeleteLink = true } = info;
if (needDeleteLink) link?.parentNode && link.parentNode.removeChild(link);
});
if (prev) {
const res = prev(event);
onLinkCompleteCallback();
return res;
}
}
onLinkCompleteCallback();
};
link.onerror = onLinkComplete.bind(null, link.onerror);
link.onload = onLinkComplete.bind(null, link.onload);
timeoutId = setTimeout(() => {
onLinkComplete(null, {
type: "error",
isTimeout: true
});
}, timeout);
return {
link,
needAttach
};
}
function loadScript(url, info) {
const { attrs = {}, createScriptHook } = info;
return new Promise((resolve, reject) => {
const { script, needAttach } = createScript({
url,
cb: resolve,
onErrorCallback: reject,
attrs: {
fetchpriority: "high",
...attrs
},
createScriptHook,
needDeleteScript: true
});
needAttach && document.head.appendChild(script);
});
}
//#endregion
exports.createLink = createLink;
exports.createScript = createScript;
exports.isStaticResourcesEqual = isStaticResourcesEqual;
exports.loadScript = loadScript;
exports.safeWrapper = safeWrapper;
//# sourceMappingURL=dom.cjs.map

1
node_modules/@module-federation/sdk/dist/dom.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

33
node_modules/@module-federation/sdk/dist/dom.d.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import { CreateLinkHookDom, CreateScriptHookDom } from "./types/hooks.js";
//#region src/dom.d.ts
declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
declare function createScript(info: {
url: string;
cb?: (value: void | PromiseLike<void>) => void;
onErrorCallback?: (error: Error) => void;
attrs?: Record<string, any>;
needDeleteScript?: boolean;
createScriptHook?: CreateScriptHookDom;
}): {
script: HTMLScriptElement;
needAttach: boolean;
};
declare function createLink(info: {
url: string;
cb?: (value: void | PromiseLike<void>) => void;
onErrorCallback?: (error: Error) => void;
attrs: Record<string, string>;
needDeleteLink?: boolean;
createLinkHook?: CreateLinkHookDom;
}): {
link: HTMLLinkElement;
needAttach: boolean;
};
declare function loadScript(url: string, info: {
attrs?: Record<string, any>;
createScriptHook?: CreateScriptHookDom;
}): Promise<void>;
//#endregion
export { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper };
//# sourceMappingURL=dom.d.ts.map

210
node_modules/@module-federation/sdk/dist/dom.js generated vendored Normal file
View File

@@ -0,0 +1,210 @@
import { warn } from "./utils.js";
//#region src/dom.ts
async function safeWrapper(callback, disableWarn) {
try {
return await callback();
} catch (e) {
!disableWarn && warn(e);
return;
}
}
function isStaticResourcesEqual(url1, url2) {
const REG_EXP = /^(https?:)?\/\//i;
return url1.replace(REG_EXP, "").replace(/\/$/, "") === url2.replace(REG_EXP, "").replace(/\/$/, "");
}
function createScript(info) {
let script = null;
let needAttach = true;
let timeout = 2e4;
let timeoutId;
const scripts = document.getElementsByTagName("script");
for (let i = 0; i < scripts.length; i++) {
const s = scripts[i];
const scriptSrc = s.getAttribute("src");
if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
script = s;
needAttach = false;
break;
}
}
if (!script) {
const attrs = info.attrs;
script = document.createElement("script");
script.type = attrs?.["type"] === "module" ? "module" : "text/javascript";
let createScriptRes = void 0;
if (info.createScriptHook) {
createScriptRes = info.createScriptHook(info.url, info.attrs);
if (createScriptRes instanceof HTMLScriptElement) script = createScriptRes;
else if (typeof createScriptRes === "object") {
if ("script" in createScriptRes && createScriptRes.script) script = createScriptRes.script;
if ("timeout" in createScriptRes && createScriptRes.timeout) timeout = createScriptRes.timeout;
}
}
if (!script.src) script.src = info.url;
if (attrs && !createScriptRes) Object.keys(attrs).forEach((name) => {
if (script) {
if (name === "async" || name === "defer") script[name] = attrs[name];
else if (!script.getAttribute(name)) script.setAttribute(name, attrs[name]);
}
});
}
let executionError = null;
const executionErrorHandler = typeof window !== "undefined" ? (evt) => {
if (evt.filename && isStaticResourcesEqual(evt.filename, info.url)) {
const err = /* @__PURE__ */ new Error(`ScriptExecutionError: Script "${info.url}" loaded but threw a runtime error during execution: ${evt.message} (${evt.filename}:${evt.lineno}:${evt.colno})`);
err.name = "ScriptExecutionError";
executionError = err;
}
} : null;
if (executionErrorHandler) window.addEventListener("error", executionErrorHandler);
const onScriptComplete = async (prev, event) => {
clearTimeout(timeoutId);
if (executionErrorHandler) window.removeEventListener("error", executionErrorHandler);
const onScriptCompleteCallback = () => {
if (event?.type === "error") {
const networkError = /* @__PURE__ */ new Error(event?.isTimeout ? `ScriptNetworkError: Script "${info.url}" timed out.` : `ScriptNetworkError: Failed to load script "${info.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);
networkError.name = "ScriptNetworkError";
info?.onErrorCallback && info?.onErrorCallback(networkError);
} else if (executionError) info?.onErrorCallback && info?.onErrorCallback(executionError);
else info?.cb && info?.cb();
};
if (script) {
script.onerror = null;
script.onload = null;
safeWrapper(() => {
const { needDeleteScript = true } = info;
if (needDeleteScript) script?.parentNode && script.parentNode.removeChild(script);
});
if (prev && typeof prev === "function") {
const result = prev(event);
if (result instanceof Promise) {
const res = await result;
onScriptCompleteCallback();
return res;
}
onScriptCompleteCallback();
return result;
}
}
onScriptCompleteCallback();
};
script.onerror = onScriptComplete.bind(null, script.onerror);
script.onload = onScriptComplete.bind(null, script.onload);
timeoutId = setTimeout(() => {
onScriptComplete(null, {
type: "error",
isTimeout: true
});
}, timeout);
return {
script,
needAttach
};
}
function createLink(info) {
let link = null;
let needAttach = true;
let timeout = 2e4;
let timeoutId;
const links = document.getElementsByTagName("link");
for (let i = 0; i < links.length; i++) {
const l = links[i];
const linkHref = l.getAttribute("href");
const linkRel = l.getAttribute("rel");
if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) {
link = l;
needAttach = false;
break;
}
}
if (!link) {
link = document.createElement("link");
link.setAttribute("href", info.url);
let createLinkRes = void 0;
let shouldApplyAttrs = true;
const attrs = info.attrs;
if (info.createLinkHook) {
createLinkRes = info.createLinkHook(info.url, attrs);
if (createLinkRes instanceof HTMLLinkElement) {
link = createLinkRes;
shouldApplyAttrs = false;
} else if (typeof createLinkRes === "object") {
if ("link" in createLinkRes && createLinkRes.link) {
link = createLinkRes.link;
shouldApplyAttrs = false;
}
if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
}
}
if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
});
}
if (!needAttach) {
Promise.resolve().then(() => {
info?.cb && info?.cb();
});
return {
link,
needAttach
};
}
const onLinkComplete = (prev, event) => {
if (timeoutId) clearTimeout(timeoutId);
const onLinkCompleteCallback = () => {
if (event?.type === "error") {
const linkError = /* @__PURE__ */ new Error(event?.isTimeout ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);
linkError.name = "LinkNetworkError";
info?.onErrorCallback && info?.onErrorCallback(linkError);
} else info?.cb && info?.cb();
};
if (link) {
link.onerror = null;
link.onload = null;
safeWrapper(() => {
const { needDeleteLink = true } = info;
if (needDeleteLink) link?.parentNode && link.parentNode.removeChild(link);
});
if (prev) {
const res = prev(event);
onLinkCompleteCallback();
return res;
}
}
onLinkCompleteCallback();
};
link.onerror = onLinkComplete.bind(null, link.onerror);
link.onload = onLinkComplete.bind(null, link.onload);
timeoutId = setTimeout(() => {
onLinkComplete(null, {
type: "error",
isTimeout: true
});
}, timeout);
return {
link,
needAttach
};
}
function loadScript(url, info) {
const { attrs = {}, createScriptHook } = info;
return new Promise((resolve, reject) => {
const { script, needAttach } = createScript({
url,
cb: resolve,
onErrorCallback: reject,
attrs: {
fetchpriority: "high",
...attrs
},
createScriptHook,
needDeleteScript: true
});
needAttach && document.head.appendChild(script);
});
}
//#endregion
export { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper };
//# sourceMappingURL=dom.js.map

1
node_modules/@module-federation/sdk/dist/dom.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

34
node_modules/@module-federation/sdk/dist/env.cjs generated vendored Normal file
View File

@@ -0,0 +1,34 @@
const require_constant = require('./constant.cjs');
//#region src/env.ts
const isBrowserEnvValue = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : typeof window !== "undefined" && typeof window.document !== "undefined";
function isBrowserEnv() {
return isBrowserEnvValue;
}
function isReactNativeEnv() {
return typeof navigator !== "undefined" && navigator?.product === "ReactNative";
}
function isBrowserDebug() {
try {
if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(require_constant.BROWSER_LOG_KEY));
} catch (error) {
return false;
}
return false;
}
function isDebugMode() {
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
return isBrowserDebug();
}
const getProcessEnv = function() {
return typeof process !== "undefined" && process.env ? process.env : {};
};
//#endregion
exports.getProcessEnv = getProcessEnv;
exports.isBrowserEnv = isBrowserEnv;
exports.isBrowserEnvValue = isBrowserEnvValue;
exports.isDebugMode = isDebugMode;
exports.isReactNativeEnv = isReactNativeEnv;
//# sourceMappingURL=env.cjs.map

1
node_modules/@module-federation/sdk/dist/env.cjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"env.cjs","names":["BROWSER_LOG_KEY"],"sources":["../src/env.ts"],"sourcesContent":["import { BROWSER_LOG_KEY } from './constant';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var FEDERATION_DEBUG: string | undefined;\n}\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\n\nconst isBrowserEnvValue =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nfunction isBrowserEnv(): boolean {\n return isBrowserEnvValue;\n}\n\nfunction isReactNativeEnv(): boolean {\n return (\n typeof navigator !== 'undefined' && navigator?.product === 'ReactNative'\n );\n}\n\nfunction isBrowserDebug() {\n try {\n if (isBrowserEnv() && window.localStorage) {\n return Boolean(localStorage.getItem(BROWSER_LOG_KEY));\n }\n } catch (error) {\n return false;\n }\n return false;\n}\n\nfunction isDebugMode(): boolean {\n if (\n typeof process !== 'undefined' &&\n process.env &&\n process.env['FEDERATION_DEBUG']\n ) {\n return Boolean(process.env['FEDERATION_DEBUG']);\n }\n\n if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) {\n return true;\n }\n\n return isBrowserDebug();\n}\n\nconst getProcessEnv = function (): Record<string, string | undefined> {\n return typeof process !== 'undefined' && process.env ? process.env : {};\n};\n\nexport {\n isBrowserEnv,\n isBrowserEnvValue,\n isReactNativeEnv,\n isDebugMode,\n getProcessEnv,\n};\n"],"mappings":";;;AAUA,MAAM,oBACJ,OAAO,eAAe,cAClB,eAAe,QACf,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AAElE,SAAS,eAAwB;AAC/B,QAAO;;AAGT,SAAS,mBAA4B;AACnC,QACE,OAAO,cAAc,eAAe,WAAW,YAAY;;AAI/D,SAAS,iBAAiB;AACxB,KAAI;AACF,MAAI,cAAc,IAAI,OAAO,aAC3B,QAAO,QAAQ,aAAa,QAAQA,iCAAgB,CAAC;UAEhD,OAAO;AACd,SAAO;;AAET,QAAO;;AAGT,SAAS,cAAuB;AAC9B,KACE,OAAO,YAAY,eACnB,QAAQ,OACR,QAAQ,IAAI,oBAEZ,QAAO,QAAQ,QAAQ,IAAI,oBAAoB;AAGjD,KAAI,OAAO,qBAAqB,eAAe,QAAQ,iBAAiB,CACtE,QAAO;AAGT,QAAO,gBAAgB;;AAGzB,MAAM,gBAAgB,WAAgD;AACpE,QAAO,OAAO,YAAY,eAAe,QAAQ,MAAM,QAAQ,MAAM,EAAE"}

12
node_modules/@module-federation/sdk/dist/env.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
//#region src/env.d.ts
declare global {
var FEDERATION_DEBUG: string | undefined;
}
declare const isBrowserEnvValue: boolean;
declare function isBrowserEnv(): boolean;
declare function isReactNativeEnv(): boolean;
declare function isDebugMode(): boolean;
declare const getProcessEnv: () => Record<string, string | undefined>;
//#endregion
export { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv };
//# sourceMappingURL=env.d.ts.map

30
node_modules/@module-federation/sdk/dist/env.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import { BROWSER_LOG_KEY } from "./constant.js";
//#region src/env.ts
const isBrowserEnvValue = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : typeof window !== "undefined" && typeof window.document !== "undefined";
function isBrowserEnv() {
return isBrowserEnvValue;
}
function isReactNativeEnv() {
return typeof navigator !== "undefined" && navigator?.product === "ReactNative";
}
function isBrowserDebug() {
try {
if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
} catch (error) {
return false;
}
return false;
}
function isDebugMode() {
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
return isBrowserDebug();
}
const getProcessEnv = function() {
return typeof process !== "undefined" && process.env ? process.env : {};
};
//#endregion
export { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv };
//# sourceMappingURL=env.js.map

1
node_modules/@module-federation/sdk/dist/env.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"env.js","names":[],"sources":["../src/env.ts"],"sourcesContent":["import { BROWSER_LOG_KEY } from './constant';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var FEDERATION_DEBUG: string | undefined;\n}\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\n\nconst isBrowserEnvValue =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nfunction isBrowserEnv(): boolean {\n return isBrowserEnvValue;\n}\n\nfunction isReactNativeEnv(): boolean {\n return (\n typeof navigator !== 'undefined' && navigator?.product === 'ReactNative'\n );\n}\n\nfunction isBrowserDebug() {\n try {\n if (isBrowserEnv() && window.localStorage) {\n return Boolean(localStorage.getItem(BROWSER_LOG_KEY));\n }\n } catch (error) {\n return false;\n }\n return false;\n}\n\nfunction isDebugMode(): boolean {\n if (\n typeof process !== 'undefined' &&\n process.env &&\n process.env['FEDERATION_DEBUG']\n ) {\n return Boolean(process.env['FEDERATION_DEBUG']);\n }\n\n if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) {\n return true;\n }\n\n return isBrowserDebug();\n}\n\nconst getProcessEnv = function (): Record<string, string | undefined> {\n return typeof process !== 'undefined' && process.env ? process.env : {};\n};\n\nexport {\n isBrowserEnv,\n isBrowserEnvValue,\n isReactNativeEnv,\n isDebugMode,\n getProcessEnv,\n};\n"],"mappings":";;;AAUA,MAAM,oBACJ,OAAO,eAAe,cAClB,eAAe,QACf,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AAElE,SAAS,eAAwB;AAC/B,QAAO;;AAGT,SAAS,mBAA4B;AACnC,QACE,OAAO,cAAc,eAAe,WAAW,YAAY;;AAI/D,SAAS,iBAAiB;AACxB,KAAI;AACF,MAAI,cAAc,IAAI,OAAO,aAC3B,QAAO,QAAQ,aAAa,QAAQ,gBAAgB,CAAC;UAEhD,OAAO;AACd,SAAO;;AAET,QAAO;;AAGT,SAAS,cAAuB;AAC9B,KACE,OAAO,YAAY,eACnB,QAAQ,OACR,QAAQ,IAAI,oBAEZ,QAAO,QAAQ,QAAQ,IAAI,oBAAoB;AAGjD,KAAI,OAAO,qBAAqB,eAAe,QAAQ,iBAAiB,CACtE,QAAO;AAGT,QAAO,gBAAgB;;AAGzB,MAAM,gBAAgB,WAAgD;AACpE,QAAO,OAAO,YAAY,eAAe,QAAQ,MAAM,QAAQ,MAAM,EAAE"}

View File

@@ -0,0 +1,123 @@
const require_constant = require('./constant.cjs');
//#region src/generateSnapshotFromManifest.ts
const simpleJoinRemoteEntry = (rPath, rName) => {
if (!rPath) return rName;
const transformPath = (str) => {
if (str === ".") return "";
if (str.startsWith("./")) return str.replace("./", "");
if (str.startsWith("/")) {
const strWithoutSlash = str.slice(1);
if (strWithoutSlash.endsWith("/")) return strWithoutSlash.slice(0, -1);
return strWithoutSlash;
}
return str;
};
const transformedPath = transformPath(rPath);
if (!transformedPath) return rName;
if (transformedPath.endsWith("/")) return `${transformedPath}${rName}`;
return `${transformedPath}/${rName}`;
};
function inferAutoPublicPath(url) {
return url.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
}
function generateSnapshotFromManifest(manifest, options = {}) {
const { remotes = {}, overrides = {}, version } = options;
let remoteSnapshot;
const getPublicPath = () => {
if ("publicPath" in manifest.metaData) {
if ((manifest.metaData.publicPath === "auto" || manifest.metaData.publicPath === "") && version) return inferAutoPublicPath(version);
return manifest.metaData.publicPath;
} else return manifest.metaData.getPublicPath;
};
const overridesKeys = Object.keys(overrides);
let remotesInfo = {};
if (!Object.keys(remotes).length) remotesInfo = manifest.remotes?.reduce((res, next) => {
let matchedVersion;
const name = next.federationContainerName;
if (overridesKeys.includes(name)) matchedVersion = overrides[name];
else if ("version" in next) matchedVersion = next.version;
else matchedVersion = next.entry;
res[name] = { matchedVersion };
return res;
}, {}) || {};
Object.keys(remotes).forEach((key) => remotesInfo[key] = { matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key] });
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes = {
path: "",
name: "",
zip: "",
api: ""
}, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
const { exposes } = manifest;
let basicRemoteSnapshot = {
version: version ? version : "",
buildVersion,
globalName,
remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
remoteEntryType,
remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
remoteTypesZip: remoteTypes.zip || "",
remoteTypesAPI: remoteTypes.api || "",
remotesInfo,
shared: manifest?.shared.map((item) => ({
assets: item.assets,
sharedName: item.name,
version: item.version,
usedExports: item.referenceExports || []
})),
modules: exposes?.map((expose) => ({
moduleName: expose.name,
modulePath: expose.path,
assets: expose.assets
}))
};
if ("publicPath" in manifest.metaData) {
remoteSnapshot = {
...basicRemoteSnapshot,
publicPath: getPublicPath()
};
if (typeof manifest.metaData.ssrPublicPath === "string") remoteSnapshot.ssrPublicPath = manifest.metaData.ssrPublicPath;
} else remoteSnapshot = {
...basicRemoteSnapshot,
getPublicPath: getPublicPath()
};
if (ssrRemoteEntry) {
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || "commonjs-module";
}
return remoteSnapshot;
}
function isManifestProvider(moduleInfo) {
if ("remoteEntry" in moduleInfo && moduleInfo.remoteEntry.includes(require_constant.MANIFEST_EXT)) return true;
else return false;
}
function getManifestFileName(manifestOptions) {
if (!manifestOptions) return {
statsFileName: require_constant.StatsFileName,
manifestFileName: require_constant.ManifestFileName
};
let filePath = typeof manifestOptions === "boolean" ? "" : manifestOptions.filePath || "";
let fileName = typeof manifestOptions === "boolean" ? "" : manifestOptions.fileName || "";
const JSON_EXT = ".json";
const addExt = (name) => {
if (name.endsWith(JSON_EXT)) return name;
return `${name}${JSON_EXT}`;
};
const insertSuffix = (name, suffix) => {
return name.replace(JSON_EXT, `${suffix}${JSON_EXT}`);
};
const manifestFileName = fileName ? addExt(fileName) : require_constant.ManifestFileName;
return {
statsFileName: simpleJoinRemoteEntry(filePath, fileName ? insertSuffix(manifestFileName, "-stats") : require_constant.StatsFileName),
manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName)
};
}
//#endregion
exports.generateSnapshotFromManifest = generateSnapshotFromManifest;
exports.getManifestFileName = getManifestFileName;
exports.inferAutoPublicPath = inferAutoPublicPath;
exports.isManifestProvider = isManifestProvider;
exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
//# sourceMappingURL=generateSnapshotFromManifest.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,20 @@
import { Manifest } from "./types/manifest.js";
import { ManifestProvider, ModuleInfo, ProviderModuleInfo } from "./types/snapshot.js";
import { ModuleFederationPluginOptions } from "./types/plugins/ModuleFederationPlugin.js";
//#region src/generateSnapshotFromManifest.d.ts
interface IOptions {
remotes?: Record<string, string>;
overrides?: Record<string, string>;
version?: string;
}
declare const simpleJoinRemoteEntry: (rPath: string, rName: string) => string;
declare function inferAutoPublicPath(url: string): string;
declare function generateSnapshotFromManifest(manifest: Manifest, options?: IOptions): ProviderModuleInfo;
declare function isManifestProvider(moduleInfo: ModuleInfo | ManifestProvider): moduleInfo is ManifestProvider;
declare function getManifestFileName(manifestOptions?: ModuleFederationPluginOptions['manifest']): {
statsFileName: string;
manifestFileName: string;
};
//#endregion
export { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry };
//# sourceMappingURL=generateSnapshotFromManifest.d.ts.map

View File

@@ -0,0 +1,119 @@
import { MANIFEST_EXT, ManifestFileName, StatsFileName } from "./constant.js";
//#region src/generateSnapshotFromManifest.ts
const simpleJoinRemoteEntry = (rPath, rName) => {
if (!rPath) return rName;
const transformPath = (str) => {
if (str === ".") return "";
if (str.startsWith("./")) return str.replace("./", "");
if (str.startsWith("/")) {
const strWithoutSlash = str.slice(1);
if (strWithoutSlash.endsWith("/")) return strWithoutSlash.slice(0, -1);
return strWithoutSlash;
}
return str;
};
const transformedPath = transformPath(rPath);
if (!transformedPath) return rName;
if (transformedPath.endsWith("/")) return `${transformedPath}${rName}`;
return `${transformedPath}/${rName}`;
};
function inferAutoPublicPath(url) {
return url.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
}
function generateSnapshotFromManifest(manifest, options = {}) {
const { remotes = {}, overrides = {}, version } = options;
let remoteSnapshot;
const getPublicPath = () => {
if ("publicPath" in manifest.metaData) {
if ((manifest.metaData.publicPath === "auto" || manifest.metaData.publicPath === "") && version) return inferAutoPublicPath(version);
return manifest.metaData.publicPath;
} else return manifest.metaData.getPublicPath;
};
const overridesKeys = Object.keys(overrides);
let remotesInfo = {};
if (!Object.keys(remotes).length) remotesInfo = manifest.remotes?.reduce((res, next) => {
let matchedVersion;
const name = next.federationContainerName;
if (overridesKeys.includes(name)) matchedVersion = overrides[name];
else if ("version" in next) matchedVersion = next.version;
else matchedVersion = next.entry;
res[name] = { matchedVersion };
return res;
}, {}) || {};
Object.keys(remotes).forEach((key) => remotesInfo[key] = { matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key] });
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes = {
path: "",
name: "",
zip: "",
api: ""
}, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
const { exposes } = manifest;
let basicRemoteSnapshot = {
version: version ? version : "",
buildVersion,
globalName,
remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
remoteEntryType,
remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
remoteTypesZip: remoteTypes.zip || "",
remoteTypesAPI: remoteTypes.api || "",
remotesInfo,
shared: manifest?.shared.map((item) => ({
assets: item.assets,
sharedName: item.name,
version: item.version,
usedExports: item.referenceExports || []
})),
modules: exposes?.map((expose) => ({
moduleName: expose.name,
modulePath: expose.path,
assets: expose.assets
}))
};
if ("publicPath" in manifest.metaData) {
remoteSnapshot = {
...basicRemoteSnapshot,
publicPath: getPublicPath()
};
if (typeof manifest.metaData.ssrPublicPath === "string") remoteSnapshot.ssrPublicPath = manifest.metaData.ssrPublicPath;
} else remoteSnapshot = {
...basicRemoteSnapshot,
getPublicPath: getPublicPath()
};
if (ssrRemoteEntry) {
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || "commonjs-module";
}
return remoteSnapshot;
}
function isManifestProvider(moduleInfo) {
if ("remoteEntry" in moduleInfo && moduleInfo.remoteEntry.includes(MANIFEST_EXT)) return true;
else return false;
}
function getManifestFileName(manifestOptions) {
if (!manifestOptions) return {
statsFileName: StatsFileName,
manifestFileName: ManifestFileName
};
let filePath = typeof manifestOptions === "boolean" ? "" : manifestOptions.filePath || "";
let fileName = typeof manifestOptions === "boolean" ? "" : manifestOptions.fileName || "";
const JSON_EXT = ".json";
const addExt = (name) => {
if (name.endsWith(JSON_EXT)) return name;
return `${name}${JSON_EXT}`;
};
const insertSuffix = (name, suffix) => {
return name.replace(JSON_EXT, `${suffix}${JSON_EXT}`);
};
const manifestFileName = fileName ? addExt(fileName) : ManifestFileName;
return {
statsFileName: simpleJoinRemoteEntry(filePath, fileName ? insertSuffix(manifestFileName, "-stats") : StatsFileName),
manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName)
};
}
//#endregion
export { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry };
//# sourceMappingURL=generateSnapshotFromManifest.js.map

File diff suppressed because one or more lines are too long

103
node_modules/@module-federation/sdk/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,103 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_constant = require('./constant.cjs');
const require_ContainerPlugin = require('./types/plugins/ContainerPlugin.cjs');
const require_ContainerReferencePlugin = require('./types/plugins/ContainerReferencePlugin.cjs');
const require_ModuleFederationPlugin = require('./types/plugins/ModuleFederationPlugin.cjs');
const require_SharePlugin = require('./types/plugins/SharePlugin.cjs');
const require_ConsumeSharedPlugin = require('./types/plugins/ConsumeSharedPlugin.cjs');
const require_ProvideSharedPlugin = require('./types/plugins/ProvideSharedPlugin.cjs');
const require_env = require('./env.cjs');
const require_utils = require('./utils.cjs');
const require_generateSnapshotFromManifest = require('./generateSnapshotFromManifest.cjs');
const require_logger = require('./logger.cjs');
const require_dom = require('./dom.cjs');
const require_node = require('./node.cjs');
const require_normalizeOptions = require('./normalizeOptions.cjs');
const require_createModuleFederationConfig = require('./createModuleFederationConfig.cjs');
exports.BROWSER_LOG_KEY = require_constant.BROWSER_LOG_KEY;
exports.ENCODE_NAME_PREFIX = require_constant.ENCODE_NAME_PREFIX;
exports.EncodedNameTransformMap = require_constant.EncodedNameTransformMap;
exports.FederationModuleManifest = require_constant.FederationModuleManifest;
exports.MANIFEST_EXT = require_constant.MANIFEST_EXT;
exports.MFModuleType = require_constant.MFModuleType;
exports.MODULE_DEVTOOL_IDENTIFIER = require_constant.MODULE_DEVTOOL_IDENTIFIER;
exports.ManifestFileName = require_constant.ManifestFileName;
exports.NameTransformMap = require_constant.NameTransformMap;
exports.NameTransformSymbol = require_constant.NameTransformSymbol;
exports.SEPARATOR = require_constant.SEPARATOR;
exports.StatsFileName = require_constant.StatsFileName;
exports.TEMP_DIR = require_constant.TEMP_DIR;
exports.TreeShakingStatus = require_constant.TreeShakingStatus;
exports.assert = require_utils.assert;
exports.bindLoggerToCompiler = require_logger.bindLoggerToCompiler;
exports.composeKeyWithSeparator = require_utils.composeKeyWithSeparator;
Object.defineProperty(exports, 'consumeSharedPlugin', {
enumerable: true,
get: function () {
return require_ConsumeSharedPlugin.ConsumeSharedPlugin_exports;
}
});
Object.defineProperty(exports, 'containerPlugin', {
enumerable: true,
get: function () {
return require_ContainerPlugin.ContainerPlugin_exports;
}
});
Object.defineProperty(exports, 'containerReferencePlugin', {
enumerable: true,
get: function () {
return require_ContainerReferencePlugin.ContainerReferencePlugin_exports;
}
});
exports.createInfrastructureLogger = require_logger.createInfrastructureLogger;
exports.createLink = require_dom.createLink;
exports.createLogger = require_logger.createLogger;
exports.createModuleFederationConfig = require_createModuleFederationConfig.createModuleFederationConfig;
exports.createScript = require_dom.createScript;
exports.createScriptNode = require_node.createScriptNode;
exports.decodeName = require_utils.decodeName;
exports.encodeName = require_utils.encodeName;
exports.error = require_utils.error;
exports.generateExposeFilename = require_utils.generateExposeFilename;
exports.generateShareFilename = require_utils.generateShareFilename;
exports.generateSnapshotFromManifest = require_generateSnapshotFromManifest.generateSnapshotFromManifest;
exports.getManifestFileName = require_generateSnapshotFromManifest.getManifestFileName;
exports.getProcessEnv = require_env.getProcessEnv;
exports.getResourceUrl = require_utils.getResourceUrl;
exports.inferAutoPublicPath = require_generateSnapshotFromManifest.inferAutoPublicPath;
exports.infrastructureLogger = require_logger.infrastructureLogger;
exports.isBrowserEnv = require_env.isBrowserEnv;
exports.isBrowserEnvValue = require_env.isBrowserEnvValue;
exports.isDebugMode = require_env.isDebugMode;
exports.isManifestProvider = require_generateSnapshotFromManifest.isManifestProvider;
exports.isReactNativeEnv = require_env.isReactNativeEnv;
exports.isRequiredVersion = require_utils.isRequiredVersion;
exports.isStaticResourcesEqual = require_dom.isStaticResourcesEqual;
exports.loadScript = require_dom.loadScript;
exports.loadScriptNode = require_node.loadScriptNode;
exports.logger = require_logger.logger;
Object.defineProperty(exports, 'moduleFederationPlugin', {
enumerable: true,
get: function () {
return require_ModuleFederationPlugin.ModuleFederationPlugin_exports;
}
});
exports.normalizeOptions = require_normalizeOptions.normalizeOptions;
exports.parseEntry = require_utils.parseEntry;
Object.defineProperty(exports, 'provideSharedPlugin', {
enumerable: true,
get: function () {
return require_ProvideSharedPlugin.ProvideSharedPlugin_exports;
}
});
exports.safeToString = require_utils.safeToString;
exports.safeWrapper = require_dom.safeWrapper;
Object.defineProperty(exports, 'sharePlugin', {
enumerable: true,
get: function () {
return require_SharePlugin.SharePlugin_exports;
}
});
exports.simpleJoinRemoteEntry = require_generateSnapshotFromManifest.simpleJoinRemoteEntry;
exports.warn = require_utils.warn;

21
node_modules/@module-federation/sdk/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus } from "./constant.js";
import { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion } from "./types/common.js";
import { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared } from "./types/stats.js";
import { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared } from "./types/manifest.js";
import { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider } from "./types/snapshot.js";
import { ModuleFederationPlugin_d_exports } from "./types/plugins/ModuleFederationPlugin.js";
import { ContainerPlugin_d_exports } from "./types/plugins/ContainerPlugin.js";
import { ContainerReferencePlugin_d_exports } from "./types/plugins/ContainerReferencePlugin.js";
import { SharePlugin_d_exports } from "./types/plugins/SharePlugin.js";
import { ConsumeSharedPlugin_d_exports } from "./types/plugins/ConsumeSharedPlugin.js";
import { ProvideSharedPlugin_d_exports } from "./types/plugins/ProvideSharedPlugin.js";
import { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook } from "./types/hooks.js";
import { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn } from "./utils.js";
import { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry } from "./generateSnapshotFromManifest.js";
import { InfrastructureLogger, Logger, bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger } from "./logger.js";
import { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv } from "./env.js";
import { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper } from "./dom.js";
import { createScriptNode, loadScriptNode } from "./node.js";
import { normalizeOptions } from "./normalizeOptions.js";
import { createModuleFederationConfig } from "./createModuleFederationConfig.js";
export { BROWSER_LOG_KEY, BasicProviderModuleInfo, BasicStatsMetaData, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, FetchHook, GlobalModuleInfo, type InfrastructureLogger, type Logger, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, Manifest, ManifestExpose, ManifestFileName, ManifestModuleInfos, ManifestProvider, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared, MetaDataTypes, Module, ModuleInfo, NameTransformMap, NameTransformSymbol, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider, RemoteEntryInfo, RemoteEntryType, RemoteWithEntry, RemoteWithVersion, ResourceInfo, SEPARATOR, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsFileName, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared, TEMP_DIR, TreeShakingStatus, assert, bindLoggerToCompiler, composeKeyWithSeparator, ConsumeSharedPlugin_d_exports as consumeSharedPlugin, ContainerPlugin_d_exports as containerPlugin, ContainerReferencePlugin_d_exports as containerReferencePlugin, createInfrastructureLogger, createLink, createLogger, createModuleFederationConfig, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getManifestFileName, getProcessEnv, getResourceUrl, inferAutoPublicPath, infrastructureLogger, isBrowserEnv, isBrowserEnvValue, isDebugMode, isManifestProvider, isReactNativeEnv, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin_d_exports as moduleFederationPlugin, normalizeOptions, parseEntry, ProvideSharedPlugin_d_exports as provideSharedPlugin, safeToString, safeWrapper, SharePlugin_d_exports as sharePlugin, simpleJoinRemoteEntry, warn };

17
node_modules/@module-federation/sdk/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus } from "./constant.js";
import { ContainerPlugin_exports } from "./types/plugins/ContainerPlugin.js";
import { ContainerReferencePlugin_exports } from "./types/plugins/ContainerReferencePlugin.js";
import { ModuleFederationPlugin_exports } from "./types/plugins/ModuleFederationPlugin.js";
import { SharePlugin_exports } from "./types/plugins/SharePlugin.js";
import { ConsumeSharedPlugin_exports } from "./types/plugins/ConsumeSharedPlugin.js";
import { ProvideSharedPlugin_exports } from "./types/plugins/ProvideSharedPlugin.js";
import { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv } from "./env.js";
import { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn } from "./utils.js";
import { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry } from "./generateSnapshotFromManifest.js";
import { bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger } from "./logger.js";
import { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper } from "./dom.js";
import { createScriptNode, loadScriptNode } from "./node.js";
import { normalizeOptions } from "./normalizeOptions.js";
import { createModuleFederationConfig } from "./createModuleFederationConfig.js";
export { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus, assert, bindLoggerToCompiler, composeKeyWithSeparator, ConsumeSharedPlugin_exports as consumeSharedPlugin, ContainerPlugin_exports as containerPlugin, ContainerReferencePlugin_exports as containerReferencePlugin, createInfrastructureLogger, createLink, createLogger, createModuleFederationConfig, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getManifestFileName, getProcessEnv, getResourceUrl, inferAutoPublicPath, infrastructureLogger, isBrowserEnv, isBrowserEnvValue, isDebugMode, isManifestProvider, isReactNativeEnv, isRequiredVersion, isStaticResourcesEqual, loadScript, loadScriptNode, logger, ModuleFederationPlugin_exports as moduleFederationPlugin, normalizeOptions, parseEntry, ProvideSharedPlugin_exports as provideSharedPlugin, safeToString, safeWrapper, SharePlugin_exports as sharePlugin, simpleJoinRemoteEntry, warn };

129
node_modules/@module-federation/sdk/dist/logger.cjs generated vendored Normal file
View File

@@ -0,0 +1,129 @@
const require_env = require('./env.cjs');
//#region src/logger.ts
const PREFIX = "[ Module Federation ]";
const DEFAULT_DELEGATE = console;
const LOGGER_STACK_SKIP_TOKENS = [
"logger.ts",
"logger.js",
"captureStackTrace",
"Logger.emit",
"Logger.log",
"Logger.info",
"Logger.warn",
"Logger.error",
"Logger.debug"
];
function captureStackTrace() {
try {
const stack = (/* @__PURE__ */ new Error()).stack;
if (!stack) return;
const [, ...rawLines] = stack.split("\n");
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
if (!filtered.length) return;
return `Stack trace:\n${filtered.slice(0, 5).join("\n")}`;
} catch {
return;
}
}
var Logger = class {
constructor(prefix, delegate = DEFAULT_DELEGATE) {
this.prefix = prefix;
this.delegate = delegate ?? DEFAULT_DELEGATE;
}
setPrefix(prefix) {
this.prefix = prefix;
}
setDelegate(delegate) {
this.delegate = delegate ?? DEFAULT_DELEGATE;
}
emit(method, args) {
const delegate = this.delegate;
const stackTrace = require_env.isDebugMode() ? captureStackTrace() : void 0;
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
const order = (() => {
switch (method) {
case "log": return ["log", "info"];
case "info": return ["info", "log"];
case "warn": return [
"warn",
"info",
"log"
];
case "error": return [
"error",
"warn",
"log"
];
default: return ["debug", "log"];
}
})();
for (const candidate of order) {
const handler = delegate[candidate];
if (typeof handler === "function") {
handler.call(delegate, this.prefix, ...enrichedArgs);
return;
}
}
for (const candidate of order) {
const handler = DEFAULT_DELEGATE[candidate];
if (typeof handler === "function") {
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
return;
}
}
}
log(...args) {
this.emit("log", args);
}
warn(...args) {
this.emit("warn", args);
}
error(...args) {
this.emit("error", args);
}
success(...args) {
this.emit("info", args);
}
info(...args) {
this.emit("info", args);
}
ready(...args) {
this.emit("info", args);
}
debug(...args) {
if (require_env.isDebugMode()) this.emit("debug", args);
}
};
function createLogger(prefix) {
return new Logger(prefix);
}
function createInfrastructureLogger(prefix) {
const infrastructureLogger = new Logger(prefix);
Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
value: true,
enumerable: false,
configurable: false
});
return infrastructureLogger;
}
function bindLoggerToCompiler(loggerInstance, compiler, name) {
if (!loggerInstance.__mf_infrastructure_logger__) return;
if (!compiler?.getInfrastructureLogger) return;
try {
const infrastructureLogger = compiler.getInfrastructureLogger(name);
if (infrastructureLogger && typeof infrastructureLogger === "object" && (typeof infrastructureLogger.log === "function" || typeof infrastructureLogger.info === "function" || typeof infrastructureLogger.warn === "function" || typeof infrastructureLogger.error === "function")) loggerInstance.setDelegate(infrastructureLogger);
} catch {
loggerInstance.setDelegate(void 0);
}
}
const logger = createLogger(PREFIX);
const infrastructureLogger = createInfrastructureLogger(PREFIX);
//#endregion
exports.bindLoggerToCompiler = bindLoggerToCompiler;
exports.createInfrastructureLogger = createInfrastructureLogger;
exports.createLogger = createLogger;
exports.infrastructureLogger = infrastructureLogger;
exports.logger = logger;
//# sourceMappingURL=logger.cjs.map

File diff suppressed because one or more lines are too long

34
node_modules/@module-federation/sdk/dist/logger.d.ts generated vendored Normal file
View File

@@ -0,0 +1,34 @@
//#region src/logger.d.ts
type LogMethod = 'log' | 'info' | 'warn' | 'error' | 'debug';
type LoggerDelegate = Partial<Record<LogMethod, (...args: any[]) => void>> & {
[key: string]: ((...args: any[]) => void) | undefined;
};
declare class Logger {
prefix: string;
private delegate;
constructor(prefix: string, delegate?: LoggerDelegate);
setPrefix(prefix: string): void;
setDelegate(delegate?: LoggerDelegate): void;
private emit;
log(...args: any[]): void;
warn(...args: any[]): void;
error(...args: any[]): void;
success(...args: any[]): void;
info(...args: any[]): void;
ready(...args: any[]): void;
debug(...args: any[]): void;
}
declare function createLogger(prefix: string): Logger;
type InfrastructureLogger = Logger & {
__mf_infrastructure_logger__: true;
};
declare function createInfrastructureLogger(prefix: string): InfrastructureLogger;
type InfrastructureLoggerCapableCompiler = {
getInfrastructureLogger?: (name: string) => unknown;
};
declare function bindLoggerToCompiler(loggerInstance: Logger, compiler: InfrastructureLoggerCapableCompiler, name: string): void;
declare const logger: Logger;
declare const infrastructureLogger: InfrastructureLogger;
//#endregion
export { type InfrastructureLogger, type Logger, bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger };
//# sourceMappingURL=logger.d.ts.map

125
node_modules/@module-federation/sdk/dist/logger.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
import { isDebugMode } from "./env.js";
//#region src/logger.ts
const PREFIX = "[ Module Federation ]";
const DEFAULT_DELEGATE = console;
const LOGGER_STACK_SKIP_TOKENS = [
"logger.ts",
"logger.js",
"captureStackTrace",
"Logger.emit",
"Logger.log",
"Logger.info",
"Logger.warn",
"Logger.error",
"Logger.debug"
];
function captureStackTrace() {
try {
const stack = (/* @__PURE__ */ new Error()).stack;
if (!stack) return;
const [, ...rawLines] = stack.split("\n");
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
if (!filtered.length) return;
return `Stack trace:\n${filtered.slice(0, 5).join("\n")}`;
} catch {
return;
}
}
var Logger = class {
constructor(prefix, delegate = DEFAULT_DELEGATE) {
this.prefix = prefix;
this.delegate = delegate ?? DEFAULT_DELEGATE;
}
setPrefix(prefix) {
this.prefix = prefix;
}
setDelegate(delegate) {
this.delegate = delegate ?? DEFAULT_DELEGATE;
}
emit(method, args) {
const delegate = this.delegate;
const stackTrace = isDebugMode() ? captureStackTrace() : void 0;
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
const order = (() => {
switch (method) {
case "log": return ["log", "info"];
case "info": return ["info", "log"];
case "warn": return [
"warn",
"info",
"log"
];
case "error": return [
"error",
"warn",
"log"
];
default: return ["debug", "log"];
}
})();
for (const candidate of order) {
const handler = delegate[candidate];
if (typeof handler === "function") {
handler.call(delegate, this.prefix, ...enrichedArgs);
return;
}
}
for (const candidate of order) {
const handler = DEFAULT_DELEGATE[candidate];
if (typeof handler === "function") {
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
return;
}
}
}
log(...args) {
this.emit("log", args);
}
warn(...args) {
this.emit("warn", args);
}
error(...args) {
this.emit("error", args);
}
success(...args) {
this.emit("info", args);
}
info(...args) {
this.emit("info", args);
}
ready(...args) {
this.emit("info", args);
}
debug(...args) {
if (isDebugMode()) this.emit("debug", args);
}
};
function createLogger(prefix) {
return new Logger(prefix);
}
function createInfrastructureLogger(prefix) {
const infrastructureLogger = new Logger(prefix);
Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
value: true,
enumerable: false,
configurable: false
});
return infrastructureLogger;
}
function bindLoggerToCompiler(loggerInstance, compiler, name) {
if (!loggerInstance.__mf_infrastructure_logger__) return;
if (!compiler?.getInfrastructureLogger) return;
try {
const infrastructureLogger = compiler.getInfrastructureLogger(name);
if (infrastructureLogger && typeof infrastructureLogger === "object" && (typeof infrastructureLogger.log === "function" || typeof infrastructureLogger.info === "function" || typeof infrastructureLogger.warn === "function" || typeof infrastructureLogger.error === "function")) loggerInstance.setDelegate(infrastructureLogger);
} catch {
loggerInstance.setDelegate(void 0);
}
}
const logger = createLogger(PREFIX);
const infrastructureLogger = createInfrastructureLogger(PREFIX);
//#endregion
export { bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger };
//# sourceMappingURL=logger.js.map

File diff suppressed because one or more lines are too long

122
node_modules/@module-federation/sdk/dist/node.cjs generated vendored Normal file
View File

@@ -0,0 +1,122 @@
//#region src/node.ts
const sdkImportCache = /* @__PURE__ */ new Map();
function importNodeModule(name) {
if (!name) throw new Error("import specifier is required");
if (sdkImportCache.has(name)) return sdkImportCache.get(name);
const promise = new Function("name", `return import(name)`)(name).then((res) => res).catch((error) => {
console.error(`Error importing module ${name}:`, error);
sdkImportCache.delete(name);
throw error;
});
sdkImportCache.set(name, promise);
return promise;
}
const loadNodeFetch = async () => {
const fetchModule = await importNodeModule("node-fetch");
return fetchModule.default || fetchModule;
};
const lazyLoaderHookFetch = async (input, init, loaderHook) => {
const hook = (url, init) => {
return loaderHook.lifecycle.fetch.emit(url, init);
};
const res = await hook(input, init || {});
if (!res || !(res instanceof Response)) return (typeof fetch === "undefined" ? await loadNodeFetch() : fetch)(input, init || {});
return res;
};
const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
if (loaderHook?.createScriptHook) {
const hookResult = loaderHook.createScriptHook(url);
if (hookResult && typeof hookResult === "object" && "url" in hookResult) url = hookResult.url;
}
let urlObj;
try {
urlObj = new URL(url);
} catch (e) {
console.error("Error constructing URL:", e);
cb(/* @__PURE__ */ new Error(`Invalid URL: ${e}`));
return;
}
const getFetch = async () => {
if (loaderHook?.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
};
const handleScriptFetch = async (f, urlObj) => {
try {
const res = await f(urlObj.href);
const data = await res.text();
const [path, vm] = await Promise.all([importNodeModule("path"), importNodeModule("vm")]);
const scriptContext = {
exports: {},
module: { exports: {} }
};
const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
const filename = path.basename(urlObj.pathname);
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
filename,
importModuleDynamically: vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule
});
let requireFn;
requireFn = eval("require");
script.runInThisContext()(scriptContext.exports, scriptContext.module, requireFn, urlDirname, filename);
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
if (attrs && exportedInterface && attrs["globalName"]) {
cb(void 0, exportedInterface[attrs["globalName"]] || exportedInterface);
return;
}
cb(void 0, exportedInterface);
} catch (e) {
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
}
};
getFetch().then(async (f) => {
if (attrs?.["type"] === "esm" || attrs?.["type"] === "module") return loadModule(urlObj.href, {
fetch: f,
vm: await importNodeModule("vm")
}).then(async (module) => {
await module.evaluate();
cb(void 0, module.namespace);
}).catch((e) => {
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
});
handleScriptFetch(f, urlObj);
}).catch((err) => {
cb(err);
});
} : (url, cb, attrs, loaderHook) => {
cb(/* @__PURE__ */ new Error("createScriptNode is disabled in non-Node.js environment"));
};
const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, info) => {
return new Promise((resolve, reject) => {
createScriptNode(url, (error, scriptContext) => {
if (error) reject(error);
else {
const remoteEntryKey = info?.attrs?.["globalName"] || `__FEDERATION_${info?.attrs?.["name"]}:custom__`;
resolve(globalThis[remoteEntryKey] = scriptContext);
}
}, info.attrs, info.loaderHook);
});
} : (url, info) => {
throw new Error("loadScriptNode is disabled in non-Node.js environment");
};
const esmModuleCache = /* @__PURE__ */ new Map();
async function loadModule(url, options) {
if (esmModuleCache.has(url)) return esmModuleCache.get(url);
const { fetch, vm } = options;
const code = await (await fetch(url)).text();
const module = new vm.SourceTextModule(code, { importModuleDynamically: async (specifier, script) => {
const resolvedUrl = new URL(specifier, url).href;
return loadModule(resolvedUrl, options);
} });
esmModuleCache.set(url, module);
await module.link(async (specifier) => {
const resolvedUrl = new URL(specifier, url).href;
return await loadModule(resolvedUrl, options);
});
return module;
}
//#endregion
exports.createScriptNode = createScriptNode;
exports.loadScriptNode = loadScriptNode;
//# sourceMappingURL=node.cjs.map

File diff suppressed because one or more lines are too long

15
node_modules/@module-federation/sdk/dist/node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { CreateScriptHookNode, FetchHook } from "./types/hooks.js";
//#region src/node.d.ts
declare const createScriptNode: (url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, loaderHook?: {
createScriptHook?: CreateScriptHookNode;
fetch?: FetchHook;
}) => void;
declare const loadScriptNode: (url: string, info: {
attrs?: Record<string, any>;
loaderHook?: {
createScriptHook?: CreateScriptHookNode;
};
}) => Promise<void>;
//#endregion
export { createScriptNode, loadScriptNode };
//# sourceMappingURL=node.d.ts.map

120
node_modules/@module-federation/sdk/dist/node.js generated vendored Normal file
View File

@@ -0,0 +1,120 @@
//#region src/node.ts
const sdkImportCache = /* @__PURE__ */ new Map();
function importNodeModule(name) {
if (!name) throw new Error("import specifier is required");
if (sdkImportCache.has(name)) return sdkImportCache.get(name);
const promise = new Function("name", `return import(name)`)(name).then((res) => res).catch((error) => {
console.error(`Error importing module ${name}:`, error);
sdkImportCache.delete(name);
throw error;
});
sdkImportCache.set(name, promise);
return promise;
}
const loadNodeFetch = async () => {
const fetchModule = await importNodeModule("node-fetch");
return fetchModule.default || fetchModule;
};
const lazyLoaderHookFetch = async (input, init, loaderHook) => {
const hook = (url, init) => {
return loaderHook.lifecycle.fetch.emit(url, init);
};
const res = await hook(input, init || {});
if (!res || !(res instanceof Response)) return (typeof fetch === "undefined" ? await loadNodeFetch() : fetch)(input, init || {});
return res;
};
const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
if (loaderHook?.createScriptHook) {
const hookResult = loaderHook.createScriptHook(url);
if (hookResult && typeof hookResult === "object" && "url" in hookResult) url = hookResult.url;
}
let urlObj;
try {
urlObj = new URL(url);
} catch (e) {
console.error("Error constructing URL:", e);
cb(/* @__PURE__ */ new Error(`Invalid URL: ${e}`));
return;
}
const getFetch = async () => {
if (loaderHook?.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
};
const handleScriptFetch = async (f, urlObj) => {
try {
const res = await f(urlObj.href);
const data = await res.text();
const [path, vm] = await Promise.all([importNodeModule("path"), importNodeModule("vm")]);
const scriptContext = {
exports: {},
module: { exports: {} }
};
const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
const filename = path.basename(urlObj.pathname);
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {
filename,
importModuleDynamically: vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule
});
let requireFn;
requireFn = (await importNodeModule("node:module")).createRequire(urlObj.protocol === "file:" || urlObj.protocol === "node:" ? urlObj.href : path.join(process.cwd(), "__mf_require_base__.js"));
script.runInThisContext()(scriptContext.exports, scriptContext.module, requireFn, urlDirname, filename);
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
if (attrs && exportedInterface && attrs["globalName"]) {
cb(void 0, exportedInterface[attrs["globalName"]] || exportedInterface);
return;
}
cb(void 0, exportedInterface);
} catch (e) {
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
}
};
getFetch().then(async (f) => {
if (attrs?.["type"] === "esm" || attrs?.["type"] === "module") return loadModule(urlObj.href, {
fetch: f,
vm: await importNodeModule("vm")
}).then(async (module) => {
await module.evaluate();
cb(void 0, module.namespace);
}).catch((e) => {
cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));
});
handleScriptFetch(f, urlObj);
}).catch((err) => {
cb(err);
});
} : (url, cb, attrs, loaderHook) => {
cb(/* @__PURE__ */ new Error("createScriptNode is disabled in non-Node.js environment"));
};
const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, info) => {
return new Promise((resolve, reject) => {
createScriptNode(url, (error, scriptContext) => {
if (error) reject(error);
else {
const remoteEntryKey = info?.attrs?.["globalName"] || `__FEDERATION_${info?.attrs?.["name"]}:custom__`;
resolve(globalThis[remoteEntryKey] = scriptContext);
}
}, info.attrs, info.loaderHook);
});
} : (url, info) => {
throw new Error("loadScriptNode is disabled in non-Node.js environment");
};
const esmModuleCache = /* @__PURE__ */ new Map();
async function loadModule(url, options) {
if (esmModuleCache.has(url)) return esmModuleCache.get(url);
const { fetch, vm } = options;
const code = await (await fetch(url)).text();
const module = new vm.SourceTextModule(code, { importModuleDynamically: async (specifier, script) => {
const resolvedUrl = new URL(specifier, url).href;
return loadModule(resolvedUrl, options);
} });
esmModuleCache.set(url, module);
await module.link(async (specifier) => {
const resolvedUrl = new URL(specifier, url).href;
return await loadModule(resolvedUrl, options);
});
return module;
}
//#endregion
export { createScriptNode, loadScriptNode };
//# sourceMappingURL=node.js.map

1
node_modules/@module-federation/sdk/dist/node.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,28 @@
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
let node_path = require("node:path");
//#region src/normalize-webpack-path.ts
function getWebpackPath(compiler, options = { framework: "other" }) {
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
try {
compiler.webpack();
return "";
} catch (err) {
const webpackPath = ((err.stack?.split("\n") || []).find((item) => item.includes("at webpack")) || "").replace(/[^\(\)]+/, "").slice(1, -1).split(":").slice(0, -2).join(":");
if (options?.framework === "nextjs") {
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
return "";
}
return resolveWithContext("webpack", { paths: [webpackPath] });
}
}
const normalizeWebpackPath = (fullPath) => {
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
if (process.env["FEDERATION_WEBPACK_PATH"]) return (0, node_path.resolve)(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
return fullPath;
};
//#endregion
exports.getWebpackPath = getWebpackPath;
exports.normalizeWebpackPath = normalizeWebpackPath;
//# sourceMappingURL=normalize-webpack-path.cjs.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,10 @@
import webpack from "webpack";
//#region src/normalize-webpack-path.d.ts
declare function getWebpackPath(compiler: webpack.Compiler, options?: {
framework: 'nextjs' | 'other';
}): string;
declare const normalizeWebpackPath: (fullPath: string) => string;
//#endregion
export { getWebpackPath, normalizeWebpackPath };
//# sourceMappingURL=normalize-webpack-path.d.ts.map

View File

@@ -0,0 +1,26 @@
import { resolve } from "node:path";
//#region src/normalize-webpack-path.ts
function getWebpackPath(compiler, options = { framework: "other" }) {
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
try {
compiler.webpack();
return "";
} catch (err) {
const webpackPath = ((err.stack?.split("\n") || []).find((item) => item.includes("at webpack")) || "").replace(/[^\(\)]+/, "").slice(1, -1).split(":").slice(0, -2).join(":");
if (options?.framework === "nextjs") {
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
return "";
}
return resolveWithContext("webpack", { paths: [webpackPath] });
}
}
const normalizeWebpackPath = (fullPath) => {
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
if (process.env["FEDERATION_WEBPACK_PATH"]) return resolve(process.env["FEDERATION_WEBPACK_PATH"], fullPath.replace("webpack", "../../"));
return fullPath;
};
//#endregion
export { getWebpackPath, normalizeWebpackPath };
//# sourceMappingURL=normalize-webpack-path.js.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,19 @@
//#region src/normalizeOptions.ts
function normalizeOptions(enableDefault, defaultOptions, key) {
return function(options) {
if (options === false) return false;
if (typeof options === "undefined") if (enableDefault) return defaultOptions;
else return false;
if (options === true) return defaultOptions;
if (options && typeof options === "object") return {
...defaultOptions,
...options
};
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
};
}
//#endregion
exports.normalizeOptions = normalizeOptions;
//# sourceMappingURL=normalizeOptions.cjs.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,5 @@
//#region src/normalizeOptions.d.ts
declare function normalizeOptions<T>(enableDefault: boolean, defaultOptions: T, key: string): <U extends boolean | undefined | T>(options: U) => T | false;
//#endregion
export { normalizeOptions };
//# sourceMappingURL=normalizeOptions.d.ts.map

View File

@@ -0,0 +1,18 @@
//#region src/normalizeOptions.ts
function normalizeOptions(enableDefault, defaultOptions, key) {
return function(options) {
if (options === false) return false;
if (typeof options === "undefined") if (enableDefault) return defaultOptions;
else return false;
if (options === true) return defaultOptions;
if (options && typeof options === "object") return {
...defaultOptions,
...options
};
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
};
}
//#endregion
export { normalizeOptions };
//# sourceMappingURL=normalizeOptions.js.map

View File

@@ -0,0 +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"}

View File

@@ -0,0 +1,14 @@
//#region src/types/common.d.ts
interface RemoteWithEntry {
name: string;
entry: string;
}
interface RemoteWithVersion {
name: string;
version: string;
}
type RemoteEntryInfo = RemoteWithEntry | RemoteWithVersion;
type Module = any;
//#endregion
export { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion };
//# sourceMappingURL=common.d.ts.map

View File

@@ -0,0 +1,21 @@
//#region src/types/hooks.d.ts
type CreateScriptHookReturnNode = {
url: string;
} | void;
type CreateScriptHookReturnDom = HTMLScriptElement | {
script?: HTMLScriptElement;
timeout?: number;
} | void;
type CreateLinkHookReturnDom = HTMLLinkElement | {
link?: HTMLLinkElement;
timeout?: number;
} | void;
type CreateScriptHookReturn = CreateScriptHookReturnNode | CreateScriptHookReturnDom;
type CreateScriptHookNode = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnNode;
type CreateScriptHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnDom;
type CreateLinkHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateLinkHookReturnDom;
type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
type FetchHook = (args: [string, RequestInit]) => Promise<Response> | void | false;
//#endregion
export { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook };
//# sourceMappingURL=hooks.d.ts.map

View File

@@ -0,0 +1,11 @@
import { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion } from "./common.js";
import { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared } from "./stats.js";
import { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared } from "./manifest.js";
import { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider } from "./snapshot.js";
import { ModuleFederationPlugin_d_exports } from "./plugins/ModuleFederationPlugin.js";
import { ContainerPlugin_d_exports } from "./plugins/ContainerPlugin.js";
import { ContainerReferencePlugin_d_exports } from "./plugins/ContainerReferencePlugin.js";
import { SharePlugin_d_exports } from "./plugins/SharePlugin.js";
import { ConsumeSharedPlugin_d_exports } from "./plugins/ConsumeSharedPlugin.js";
import { ProvideSharedPlugin_d_exports } from "./plugins/ProvideSharedPlugin.js";
import { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook } from "./hooks.js";

View File

@@ -0,0 +1,34 @@
import { RemoteWithEntry, RemoteWithVersion } from "./common.js";
import { BasicStatsMetaData, RemoteEntryType, StatsAssets, StatsExpose, StatsMetaData } from "./stats.js";
//#region src/types/manifest.d.ts
interface ManifestShared {
id: string;
name: string;
version: string;
singleton: boolean;
requiredVersion: string;
hash: string;
assets: StatsAssets;
fallback?: string;
fallbackName?: string;
fallbackType?: RemoteEntryType;
}
interface ManifestRemoteCommonInfo {
federationContainerName: string;
moduleName: string;
alias: string;
}
type ManifestRemote<T = ManifestRemoteCommonInfo> = (Omit<RemoteWithEntry, 'name'> & T) | (Omit<RemoteWithVersion, 'name'> & T);
type ManifestExpose = Pick<StatsExpose, 'assets' | 'id' | 'name' | 'path'>;
interface Manifest<T = BasicStatsMetaData, K = ManifestRemoteCommonInfo> {
id: string;
name: string;
metaData: StatsMetaData<T>;
shared: ManifestShared[];
remotes: ManifestRemote<K>[];
exposes: ManifestExpose[];
}
//#endregion
export { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared };
//# sourceMappingURL=manifest.d.ts.map

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/ConsumeSharedPlugin.ts
var ConsumeSharedPlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'ConsumeSharedPlugin_exports', {
enumerable: true,
get: function () {
return ConsumeSharedPlugin_exports;
}
});
//# sourceMappingURL=ConsumeSharedPlugin.cjs.map

View File

@@ -0,0 +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":""}

View File

@@ -0,0 +1,109 @@
declare namespace ConsumeSharedPlugin_d_exports {
export { ConsumeSharedPluginOptions, Consumes, ConsumesConfig, ConsumesItem, ConsumesObject, IncludeExcludeOptions };
}
/**
* A module that should be consumed from share scope.
*/
type ConsumesItem = string;
/**
* Advanced configuration for modules that should be consumed from share scope.
*/
interface ConsumesConfig {
/**
* 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.
*/
eager?: boolean;
/**
* Fallback module if no shared module is found in share scope. Defaults to the property name.
*/
import?: false | ConsumesItem;
/**
* Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
*/
packageName?: string;
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/
shareKey?: string;
/**
* Share scope name.
*/
shareScope?: string | string[];
/**
* Layer in which the shared module should be placed.
*/
layer?: string;
/**
* Layer of the issuer.
*/
issuerLayer?: string;
/**
* Import request to match on
*/
request?: string;
/**
* Allow only a single version of the shared module in share scope (disabled by default).
*/
singleton?: boolean;
/**
* 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).
*/
strictVersion?: boolean;
/**
* Filter consumed modules based on the request path.
*/
exclude?: IncludeExcludeOptions;
/**
* Filter consumed modules based on the request path (only include matches).
*/
include?: IncludeExcludeOptions;
/**
* Enable reconstructed lookup for node_modules paths for this share item
*/
allowNodeModulesSuffixMatch?: boolean;
/**
* Tree shaking mode for the shared module.
*/
treeShakingMode?: 'server-calc' | 'runtime-infer';
}
/**
* 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.
*/
interface ConsumesObject {
[k: string]: ConsumesConfig | ConsumesItem;
}
/**
* Modules that should be consumed from share scope. When provided, property names are used to match requested modules in this compilation.
*/
type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;
interface IncludeExcludeOptions {
request?: string | RegExp;
/**
* Semantic versioning range to match against the module's version.
*/
version?: string;
/**
* Optional specific version string to check against the version range instead of reading package.json.
*/
fallbackVersion?: string;
}
interface ConsumeSharedPluginOptions {
consumes: Consumes;
/**
* Share scope name used for all consumed modules (defaults to 'default').
*/
shareScope?: string | string[];
/**
* Experimental features configuration
*/
experiments?: {
/** Enable reconstructed lookup for node_modules paths */allowNodeModulesSuffixMatch?: boolean;
};
}
//#endregion
export { ConsumeSharedPlugin_d_exports, IncludeExcludeOptions };
//# sourceMappingURL=ConsumeSharedPlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/ConsumeSharedPlugin.ts
var ConsumeSharedPlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { ConsumeSharedPlugin_exports };
//# sourceMappingURL=ConsumeSharedPlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ConsumeSharedPlugin.js","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":""}

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/ContainerPlugin.ts
var ContainerPlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'ContainerPlugin_exports', {
enumerable: true,
get: function () {
return ContainerPlugin_exports;
}
});
//# sourceMappingURL=ContainerPlugin.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ContainerPlugin.cjs","names":[],"sources":["../../../src/types/plugins/ContainerPlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type {\n Exposes,\n EntryRuntime,\n LibraryOptions,\n} from './ModuleFederationPlugin';\n\nexport interface ContainerPluginOptions {\n exposes: Exposes;\n /**\n * The filename for this container relative path inside the `output.path` directory.\n */\n filename?: string;\n library?: LibraryOptions;\n /**\n * The name for this container.\n */\n name: string;\n runtime?: EntryRuntime;\n /**\n * The name of the share scope which is shared with the host (defaults to 'default').\n */\n shareScope?: string | string[];\n /**\n * Experimental features configuration\n */\n experiments?: {\n /** Enable async startup for the container */\n asyncStartup?: boolean;\n /** After setting true, the external MF runtime will be used and the runtime provided by the consumer will be used. (Please make sure your consumer has provideExternalRuntime: true set, otherwise it will not run properly!) */\n externalRuntime?: boolean;\n /** Enable providing external runtime */\n provideExternalRuntime?: boolean;\n };\n /**\n * Array of runtime plugins to be applied\n */\n runtimePlugins?: (string | unknown[])[];\n}\n"],"mappings":""}

View File

@@ -0,0 +1,38 @@
import { EntryRuntime, Exposes, LibraryOptions } from "./ModuleFederationPlugin.js";
//#region src/types/plugins/ContainerPlugin.d.ts
declare namespace ContainerPlugin_d_exports {
export { ContainerPluginOptions };
}
interface ContainerPluginOptions {
exposes: Exposes;
/**
* The filename for this container relative path inside the `output.path` directory.
*/
filename?: string;
library?: LibraryOptions;
/**
* The name for this container.
*/
name: string;
runtime?: EntryRuntime;
/**
* The name of the share scope which is shared with the host (defaults to 'default').
*/
shareScope?: string | string[];
/**
* Experimental features configuration
*/
experiments?: {
/** Enable async startup for the container */asyncStartup?: boolean; /** After setting true, the external MF runtime will be used and the runtime provided by the consumer will be used. (Please make sure your consumer has provideExternalRuntime: true set, otherwise it will not run properly!) */
externalRuntime?: boolean; /** Enable providing external runtime */
provideExternalRuntime?: boolean;
};
/**
* Array of runtime plugins to be applied
*/
runtimePlugins?: (string | unknown[])[];
}
//#endregion
export { ContainerPlugin_d_exports };
//# sourceMappingURL=ContainerPlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/ContainerPlugin.ts
var ContainerPlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { ContainerPlugin_exports };
//# sourceMappingURL=ContainerPlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ContainerPlugin.js","names":[],"sources":["../../../src/types/plugins/ContainerPlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type {\n Exposes,\n EntryRuntime,\n LibraryOptions,\n} from './ModuleFederationPlugin';\n\nexport interface ContainerPluginOptions {\n exposes: Exposes;\n /**\n * The filename for this container relative path inside the `output.path` directory.\n */\n filename?: string;\n library?: LibraryOptions;\n /**\n * The name for this container.\n */\n name: string;\n runtime?: EntryRuntime;\n /**\n * The name of the share scope which is shared with the host (defaults to 'default').\n */\n shareScope?: string | string[];\n /**\n * Experimental features configuration\n */\n experiments?: {\n /** Enable async startup for the container */\n asyncStartup?: boolean;\n /** After setting true, the external MF runtime will be used and the runtime provided by the consumer will be used. (Please make sure your consumer has provideExternalRuntime: true set, otherwise it will not run properly!) */\n externalRuntime?: boolean;\n /** Enable providing external runtime */\n provideExternalRuntime?: boolean;\n };\n /**\n * Array of runtime plugins to be applied\n */\n runtimePlugins?: (string | unknown[])[];\n}\n"],"mappings":""}

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/ContainerReferencePlugin.ts
var ContainerReferencePlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'ContainerReferencePlugin_exports', {
enumerable: true,
get: function () {
return ContainerReferencePlugin_exports;
}
});
//# sourceMappingURL=ContainerReferencePlugin.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ContainerReferencePlugin.cjs","names":[],"sources":["../../../src/types/plugins/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { ExternalsType, Remotes } from './ModuleFederationPlugin';\n\nexport interface ContainerReferencePluginOptions {\n /**\n * Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.\n */\n async?: boolean;\n /**\n * The external type of the remote containers.\n */\n remoteType: ExternalsType;\n remotes: Remotes;\n /**\n * The name of the share scope shared with all remotes (defaults to 'default').\n */\n shareScope?: string | string[];\n}\n"],"mappings":""}

View File

@@ -0,0 +1,24 @@
import { ExternalsType, Remotes } from "./ModuleFederationPlugin.js";
//#region src/types/plugins/ContainerReferencePlugin.d.ts
declare namespace ContainerReferencePlugin_d_exports {
export { ContainerReferencePluginOptions };
}
interface ContainerReferencePluginOptions {
/**
* Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.
*/
async?: boolean;
/**
* The external type of the remote containers.
*/
remoteType: ExternalsType;
remotes: Remotes;
/**
* The name of the share scope shared with all remotes (defaults to 'default').
*/
shareScope?: string | string[];
}
//#endregion
export { ContainerReferencePlugin_d_exports };
//# sourceMappingURL=ContainerReferencePlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/ContainerReferencePlugin.ts
var ContainerReferencePlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { ContainerReferencePlugin_exports };
//# sourceMappingURL=ContainerReferencePlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ContainerReferencePlugin.js","names":[],"sources":["../../../src/types/plugins/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { ExternalsType, Remotes } from './ModuleFederationPlugin';\n\nexport interface ContainerReferencePluginOptions {\n /**\n * Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.\n */\n async?: boolean;\n /**\n * The external type of the remote containers.\n */\n remoteType: ExternalsType;\n remotes: Remotes;\n /**\n * The name of the share scope shared with all remotes (defaults to 'default').\n */\n shareScope?: string | string[];\n}\n"],"mappings":""}

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/ModuleFederationPlugin.ts
var ModuleFederationPlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'ModuleFederationPlugin_exports', {
enumerable: true,
get: function () {
return ModuleFederationPlugin_exports;
}
});
//# sourceMappingURL=ModuleFederationPlugin.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,462 @@
import { Stats } from "../stats.js";
import webpack from "webpack";
//#region src/types/plugins/ModuleFederationPlugin.d.ts
declare namespace ModuleFederationPlugin_d_exports {
export { AdditionalDataOptions, AmdContainer, AsyncBoundaryOptions, AuxiliaryComment, DtsGenerateTypesHookOptions, DtsHostOptions, DtsRemoteOptions, EntryRuntime, Exposes, ExposesConfig, ExposesItem, ExposesItems, ExposesObject, ExternalsType, IncludeExcludeOptions, LibraryCustomUmdCommentObject, LibraryCustomUmdObject, LibraryExport, LibraryName, LibraryOptions, LibraryType, ModuleFederationPluginOptions, PluginDevOptions, PluginDtsOptions, PluginManifestOptions, RemoteTypeUrls, Remotes, RemotesConfig, RemotesItem, RemotesItems, RemotesObject, Shared, SharedConfig, SharedItem, SharedObject, SharedStrategy, TreeShakingConfig, UmdNamedDefine };
}
/**
* Module that should be exposed by this container.
*/
type ExposesItem = string;
/**
* Modules that should be exposed by this container.
*/
type ExposesItems = ExposesItem[];
/**
* Modules that should be exposed by this container. Property names are used as public paths.
*/
interface ExposesObject {
[k: string]: ExposesConfig | ExposesItem | ExposesItems;
}
/**
* Advanced configuration for modules that should be exposed by this container.
*/
interface ExposesConfig {
/**
* Request to a module that should be exposed by this container.
*/
import: ExposesItem | ExposesItems;
/**
* Custom chunk name for the exposed module.
*/
name?: string;
}
/**
* 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.
*/
type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
/**
* Add a container for define/require functions in the AMD module.
*/
type AmdContainer = string;
/**
* Add a comment in the UMD wrapper.
*/
type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
/**
* Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.
*/
interface LibraryCustomUmdCommentObject {
/**
* Set comment for `amd` section in UMD.
*/
amd?: string;
/**
* Set comment for `commonjs` (exports) section in UMD.
*/
commonjs?: string;
/**
* Set comment for `commonjs2` (module.exports) section in UMD.
*/
commonjs2?: string;
/**
* Set comment for `root` (global variable) section in UMD.
*/
root?: string;
}
/**
* Description object for all UMD variants of the library name.
*/
interface LibraryCustomUmdObject {
/**
* Name of the exposed AMD library in the UMD.
*/
amd?: string;
/**
* Name of the exposed commonjs export in the UMD.
*/
commonjs?: string;
/**
* Name of the property exposed globally by a UMD library.
*/
root?: string[] | string;
}
/**
* Specify which export should be exposed as library.
*/
type LibraryExport = string[] | string;
/**
* The name of the library (some types allow unnamed libraries too).
*/
type LibraryName = string[] | string | LibraryCustomUmdObject;
/**
* Type of library (types included by default are 'var', 'module', 'assign', 'assign-properties', 'this', 'window', 'self', 'global', 'commonjs', 'commonjs2', 'commonjs-module', 'commonjs-static', 'amd', 'amd-require', 'umd', 'umd2', 'jsonp', 'system', but others might be added by plugins).
*/
type LibraryType = 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | string;
/**
* Options for library.
*/
interface LibraryOptions {
amdContainer?: AmdContainer;
auxiliaryComment?: AuxiliaryComment;
export?: LibraryExport;
name?: LibraryName;
type: LibraryType;
umdNamedDefine?: UmdNamedDefine;
}
/**
* If `output.libraryTarget` is set to umd and `output.library` is set, setting this to true will name the AMD module.
*/
type UmdNamedDefine = boolean;
/**
* Specifies the default type of externals ('amd*', 'umd*', 'system' and 'jsonp' depend on output.libraryTarget set to the same value).
*/
type ExternalsType = 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'import' | 'module-import' | 'script' | 'node-commonjs';
/**
* Container location from which modules should be resolved and loaded at runtime.
*/
type RemotesItem = string;
/**
* Container locations from which modules should be resolved and loaded at runtime.
*/
type RemotesItems = RemotesItem[];
/**
* Container locations from which modules should be resolved and loaded at runtime. Property names are used as request scopes.
*/
interface RemotesObject {
[k: string]: RemotesConfig | RemotesItem | RemotesItems;
}
/**
* Advanced configuration for container locations from which modules should be resolved and loaded at runtime.
*/
interface RemotesConfig {
/**
* Container locations from which modules should be resolved and loaded at runtime.
*/
external: RemotesItem | RemotesItems;
/**
* The name of the share scope shared with this remote.
*/
shareScope?: string | string[];
}
/**
* Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
*/
type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
/**
* The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
*/
type EntryRuntime = false | string;
/**
* A module that should be shared in the share scope.
*/
type SharedItem = string;
/**
* 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.
*/
interface SharedObject {
[k: string]: SharedConfig | SharedItem;
}
/**
* Advanced configuration for modules that should be shared in the share scope.
*/
interface SharedConfig {
/**
* Include the provided and fallback module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
*/
eager?: boolean;
/**
* Options for excluding specific versions or request paths of the shared module. When specified, matching modules will not be shared. Cannot be used with 'include'.
*/
exclude?: IncludeExcludeOptions;
/**
* Options for including only specific versions or request paths of the shared module. When specified, only matching modules will be shared. Cannot be used with 'exclude'.
*/
include?: IncludeExcludeOptions;
/**
* Provided module that should be provided to share scope. Also acts as fallback module if no shared module is found in share scope or version isn't valid. Defaults to the property name.
*/
import?: false | SharedItem;
/**
* Import request to match on
*/
request?: string;
/**
* Layer in which the shared module should be placed.
*/
layer?: string;
/**
* Layer of the issuer.
*/
issuerLayer?: string;
/**
* Package name to determine required version from description file. This is only needed when package name can't be automatically determined from request.
*/
packageName?: string;
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string;
/**
* Module is looked up under this key from the share scope.
*/
shareKey?: string;
/**
* Share scope name.
*/
shareScope?: string | string[];
/**
* [Deprecated]: load shared strategy(defaults to 'version-first').
*/
shareStrategy?: 'version-first' | 'loaded-first';
/**
* Allow only a single version of the shared module in share scope (disabled by default).
*/
singleton?: boolean;
/**
* 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).
*/
strictVersion?: boolean;
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string;
/**
* Enable reconstructed lookup for node_modules paths for this share item
*/
allowNodeModulesSuffixMatch?: boolean;
/**
* Enable tree-shaking for the shared module or configure it.
*/
treeShaking?: boolean | TreeShakingConfig;
}
/**
* Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
*/
type Shared = (SharedItem | SharedObject)[] | SharedObject;
interface IncludeExcludeOptions {
/**
* A string (which can be a regex pattern) or a RegExp object to match the request path.
*/
request?: string | RegExp;
/**
* Semantic versioning range to match against the module's version.
*/
version?: string;
/**
* Semantic versioning range to match against the fallback module's version for exclusion/inclusion context where applicable.
*/
fallbackVersion?: string;
}
/**
* Tree-shake configuration for shared module.
*/
interface TreeShakingConfig {
/**
* List of export names used from the shared module.
*/
usedExports?: string[];
/**
* Tree-shake analysis mode.
*/
mode?: 'server-calc' | 'runtime-infer';
/**
* Filename for generated treeShaking metadata.
*/
filename?: string;
}
interface AdditionalDataOptions {
stats: Stats;
compiler: webpack.Compiler;
compilation: webpack.Compilation;
bundler: 'webpack' | 'rspack';
}
interface PluginManifestOptions {
filePath?: string;
disableAssetsAnalyze?: boolean;
fileName?: string;
additionalData?: (options: AdditionalDataOptions) => Promise<void | Stats> | Stats | void;
}
interface PluginDevOptions {
disableLiveReload?: boolean;
disableHotTypesReload?: boolean;
disableDynamicRemoteTypeHints?: boolean;
}
interface RemoteTypeUrl {
alias?: string;
api: string;
zip: string;
}
interface RemoteTypeUrls {
[remoteName: string]: RemoteTypeUrl;
}
interface DtsGenerateTypesHookOptions {
zipTypesPath: string;
apiTypesPath: string;
zipName: string;
apiFileName: string;
}
interface DtsHostOptions {
typesFolder?: string;
abortOnError?: boolean;
remoteTypesFolder?: string;
deleteTypesFolder?: boolean;
maxRetries?: number;
consumeAPITypes?: boolean;
runtimePkgs?: string[];
remoteTypeUrls?: (() => Promise<RemoteTypeUrls>) | RemoteTypeUrls;
timeout?: number;
/** The family of IP, used for network requests */
family?: 4 | 6;
typesOnBuild?: boolean;
}
interface DtsRemoteOptions {
tsConfigPath?: string;
typesFolder?: string;
compiledTypesFolder?: string;
/** Custom base output directory for generated types. When set, types will be emitted to this directory instead of the default compiler output directory. */
outputDir?: string;
deleteTypesFolder?: boolean;
additionalFilesToCompile?: string[];
compileInChildProcess?: boolean;
compilerInstance?: 'tsc' | 'vue-tsc' | 'tspc' | string;
generateAPITypes?: boolean;
extractThirdParty?: boolean | {
exclude?: Array<string | RegExp>;
};
extractRemoteTypes?: boolean;
abortOnError?: boolean;
deleteTsConfig?: boolean;
afterGenerate?: (options: DtsGenerateTypesHookOptions) => Promise<void> | void;
}
interface PluginDtsOptions {
generateTypes?: boolean | DtsRemoteOptions;
consumeTypes?: boolean | DtsHostOptions;
tsConfigPath?: string;
extraOptions?: Record<string, any>;
implementation?: string;
cwd?: string;
displayErrorInTerminal?: boolean;
}
type AsyncBoundaryOptions = {
eager?: RegExp | ((module: any) => boolean);
excludeChunk?: (chunk: any) => boolean;
};
interface ModuleFederationPluginOptions {
/**
* 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.
*/
exposes?: Exposes;
/**
* The filename of the container as relative path inside the `output.path` directory.
*/
filename?: string;
/**
* Options for library.
*/
library?: LibraryOptions;
/**
* The name of the container.
*/
name?: string;
/**
* The external type of the remote containers.
*/
remoteType?: ExternalsType;
/**
* Container locations and request scopes from which modules should be resolved and loaded at runtime. When provided, property name is used as request scope, otherwise request scope is automatically inferred from container location.
*/
remotes?: Remotes;
/**
* The name of the runtime chunk. If set a runtime chunk with this name is created or an existing entrypoint is used as runtime.
*/
runtime?: EntryRuntime;
/**
* Share scope name used for all shared modules (defaults to 'default').
*/
shareScope?: string | string[];
/**
* load shared strategy(defaults to 'version-first').
*/
shareStrategy?: SharedStrategy;
/**
* Modules that should be shared in the share scope. When provided, property names are used to match requested modules in this compilation.
*/
shared?: Shared;
/**
* Runtime plugin file paths or package name. Supports tuple [path, params].
*/
runtimePlugins?: (string | [string, Record<string, unknown>])[];
/**
* Custom public path function
*/
getPublicPath?: string;
/**
* Bundler runtime path
*/
implementation?: string;
manifest?: boolean | PluginManifestOptions;
dev?: boolean | PluginDevOptions;
dts?: boolean | PluginDtsOptions;
virtualRuntimeEntry?: boolean;
experiments?: {
externalRuntime?: boolean;
provideExternalRuntime?: boolean;
asyncStartup?: boolean;
/**
* Options related to build optimizations.
*/
optimization?: {
/**
* Enable optimization to skip snapshot plugin
*/
disableSnapshot?: boolean;
/**
* Target environment for the build
*/
target?: 'web' | 'node';
};
};
bridge?: {
/**
* Enables bridge router functionality for React applications.
* When enabled, automatically handles routing context and basename injection
* for micro-frontend applications using react-router-dom.
*
* @default false
*/
enableBridgeRouter?: boolean;
/**
* @deprecated Use `enableBridgeRouter: false` instead.
*
* Disables the default alias setting in the bridge.
* When true, users must manually handle basename through root component props.
*
* Migration:
* - `disableAlias: true` → `enableBridgeRouter: false`
* - `disableAlias: false` → `enableBridgeRouter: true`
*
* @default false
*/
disableAlias?: boolean;
};
/**
* Configuration for async boundary plugin
*/
async?: boolean | AsyncBoundaryOptions;
/**
* The directory to output the tree shaking shared fallback resources.
*/
treeShakingDir?: string;
/**
* Whether to inject shared used exports into bundler runtime.
*/
injectTreeShakingUsedExports?: boolean;
treeShakingSharedExcludePlugins?: string[];
treeShakingSharedPlugins?: string[];
}
type SharedStrategy = 'version-first' | 'loaded-first';
//#endregion
export { EntryRuntime, Exposes, ExternalsType, LibraryOptions, ModuleFederationPluginOptions, ModuleFederationPlugin_d_exports, Remotes, Shared };
//# sourceMappingURL=ModuleFederationPlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/ModuleFederationPlugin.ts
var ModuleFederationPlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { ModuleFederationPlugin_exports };
//# sourceMappingURL=ModuleFederationPlugin.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/ProvideSharedPlugin.ts
var ProvideSharedPlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'ProvideSharedPlugin_exports', {
enumerable: true,
get: function () {
return ProvideSharedPlugin_exports;
}
});
//# sourceMappingURL=ProvideSharedPlugin.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ProvideSharedPlugin.cjs","names":[],"sources":["../../../src/types/plugins/ProvideSharedPlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { IncludeExcludeOptions } from './ConsumeSharedPlugin';\n\n/**\n * Request to a module that should be provided as shared module to the share scope (will be resolved when relative).\n */\nexport type ProvidesItem = string;\n\n/**\n * Advanced configuration for modules that should be provided as shared modules to the share scope.\n */\nexport interface ProvidesConfig {\n /**\n * Include the provided module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.\n */\n eager?: boolean;\n /**\n * Key in the share scope under which the shared modules should be stored.\n */\n shareKey?: string;\n /**\n * Import request to match on\n */\n request?: string;\n /**\n * Share scope name.\n */\n shareScope?: string | string[];\n /**\n * Version requirement from module in share scope.\n */\n requiredVersion?: false | string;\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 * Allow only a single version of the shared module in share scope (disabled by default).\n */\n singleton?: boolean;\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 * Version of the provided module. Will replace lower matching versions, but not higher.\n */\n version?: false | string;\n /**\n * Filter for the shared module.\n */\n exclude?: IncludeExcludeOptions;\n /**\n * Options for including only certain versions or requests of the provided module. Cannot be used with 'exclude'.\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 provided as shared modules to the share scope. Property names are used as share keys.\n */\nexport interface ProvidesObject {\n [k: string]: ProvidesConfig | ProvidesItem;\n}\n\n/**\n * Modules that should be provided as shared modules to the share scope. When provided, property name is used to match modules, otherwise this is automatically inferred from share key.\n */\nexport type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject;\n\nexport interface ProvideSharedPluginOptions {\n provides: Provides;\n /**\n * Share scope name used for all provided 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":""}

View File

@@ -0,0 +1,97 @@
import { IncludeExcludeOptions } from "./ConsumeSharedPlugin.js";
//#region src/types/plugins/ProvideSharedPlugin.d.ts
declare namespace ProvideSharedPlugin_d_exports {
export { ProvideSharedPluginOptions, Provides, ProvidesConfig, ProvidesItem, ProvidesObject };
}
/**
* Request to a module that should be provided as shared module to the share scope (will be resolved when relative).
*/
type ProvidesItem = string;
/**
* Advanced configuration for modules that should be provided as shared modules to the share scope.
*/
interface ProvidesConfig {
/**
* Include the provided module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.
*/
eager?: boolean;
/**
* Key in the share scope under which the shared modules should be stored.
*/
shareKey?: string;
/**
* Import request to match on
*/
request?: string;
/**
* Share scope name.
*/
shareScope?: string | string[];
/**
* Version requirement from module in share scope.
*/
requiredVersion?: false | string;
/**
* 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).
*/
strictVersion?: boolean;
/**
* Allow only a single version of the shared module in share scope (disabled by default).
*/
singleton?: boolean;
/**
* Layer in which the shared module should be placed.
*/
layer?: string;
/**
* Layer of the issuer.
*/
issuerLayer?: string;
/**
* Version of the provided module. Will replace lower matching versions, but not higher.
*/
version?: false | string;
/**
* Filter for the shared module.
*/
exclude?: IncludeExcludeOptions;
/**
* Options for including only certain versions or requests of the provided module. Cannot be used with 'exclude'.
*/
include?: IncludeExcludeOptions;
/**
* Enable reconstructed lookup for node_modules paths for this share item
*/
allowNodeModulesSuffixMatch?: boolean;
/**
* Tree shaking mode for the shared module.
*/
treeShakingMode?: 'server-calc' | 'runtime-infer';
}
/**
* Modules that should be provided as shared modules to the share scope. Property names are used as share keys.
*/
interface ProvidesObject {
[k: string]: ProvidesConfig | ProvidesItem;
}
/**
* Modules that should be provided as shared modules to the share scope. When provided, property name is used to match modules, otherwise this is automatically inferred from share key.
*/
type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject;
interface ProvideSharedPluginOptions {
provides: Provides;
/**
* Share scope name used for all provided modules (defaults to 'default').
*/
shareScope?: string | string[];
/**
* Experimental features configuration
*/
experiments?: {
/** Enable reconstructed lookup for node_modules paths */allowNodeModulesSuffixMatch?: boolean;
};
}
//#endregion
export { ProvideSharedPlugin_d_exports };
//# sourceMappingURL=ProvideSharedPlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/ProvideSharedPlugin.ts
var ProvideSharedPlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { ProvideSharedPlugin_exports };
//# sourceMappingURL=ProvideSharedPlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ProvideSharedPlugin.js","names":[],"sources":["../../../src/types/plugins/ProvideSharedPlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { IncludeExcludeOptions } from './ConsumeSharedPlugin';\n\n/**\n * Request to a module that should be provided as shared module to the share scope (will be resolved when relative).\n */\nexport type ProvidesItem = string;\n\n/**\n * Advanced configuration for modules that should be provided as shared modules to the share scope.\n */\nexport interface ProvidesConfig {\n /**\n * Include the provided module directly instead behind an async request. This allows to use this shared module in initial load too. All possible shared modules need to be eager too.\n */\n eager?: boolean;\n /**\n * Key in the share scope under which the shared modules should be stored.\n */\n shareKey?: string;\n /**\n * Import request to match on\n */\n request?: string;\n /**\n * Share scope name.\n */\n shareScope?: string | string[];\n /**\n * Version requirement from module in share scope.\n */\n requiredVersion?: false | string;\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 * Allow only a single version of the shared module in share scope (disabled by default).\n */\n singleton?: boolean;\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 * Version of the provided module. Will replace lower matching versions, but not higher.\n */\n version?: false | string;\n /**\n * Filter for the shared module.\n */\n exclude?: IncludeExcludeOptions;\n /**\n * Options for including only certain versions or requests of the provided module. Cannot be used with 'exclude'.\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 provided as shared modules to the share scope. Property names are used as share keys.\n */\nexport interface ProvidesObject {\n [k: string]: ProvidesConfig | ProvidesItem;\n}\n\n/**\n * Modules that should be provided as shared modules to the share scope. When provided, property name is used to match modules, otherwise this is automatically inferred from share key.\n */\nexport type Provides = (ProvidesItem | ProvidesObject)[] | ProvidesObject;\n\nexport interface ProvideSharedPluginOptions {\n provides: Provides;\n /**\n * Share scope name used for all provided 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":""}

View File

@@ -0,0 +1,13 @@
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
//#region src/types/plugins/SharePlugin.ts
var SharePlugin_exports = /* @__PURE__ */ require_runtime.__exportAll({});
//#endregion
Object.defineProperty(exports, 'SharePlugin_exports', {
enumerable: true,
get: function () {
return SharePlugin_exports;
}
});
//# sourceMappingURL=SharePlugin.cjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SharePlugin.cjs","names":[],"sources":["../../../src/types/plugins/SharePlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { Shared } from './ModuleFederationPlugin';\n\nexport interface SharePluginOptions {\n /**\n * Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.\n */\n async?: boolean;\n /**\n * Share scope name used for all shared modules (defaults to 'default').\n */\n shareScope?: string | string[];\n shared: Shared;\n /**\n * Experimental features configuration\n */\n experiments?: {\n /** Enable reconstructed lookup for node_modules paths */\n allowNodeModulesSuffixMatch?: boolean;\n };\n}\n"],"mappings":""}

View File

@@ -0,0 +1,26 @@
import { Shared } from "./ModuleFederationPlugin.js";
//#region src/types/plugins/SharePlugin.d.ts
declare namespace SharePlugin_d_exports {
export { SharePluginOptions };
}
interface SharePluginOptions {
/**
* Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.
*/
async?: boolean;
/**
* Share scope name used for all shared modules (defaults to 'default').
*/
shareScope?: string | string[];
shared: Shared;
/**
* Experimental features configuration
*/
experiments?: {
/** Enable reconstructed lookup for node_modules paths */allowNodeModulesSuffixMatch?: boolean;
};
}
//#endregion
export { SharePlugin_d_exports };
//# sourceMappingURL=SharePlugin.d.ts.map

View File

@@ -0,0 +1,8 @@
import { __exportAll } from "../../_virtual/_rolldown/runtime.js";
//#region src/types/plugins/SharePlugin.ts
var SharePlugin_exports = /* @__PURE__ */ __exportAll({});
//#endregion
export { SharePlugin_exports };
//# sourceMappingURL=SharePlugin.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SharePlugin.js","names":[],"sources":["../../../src/types/plugins/SharePlugin.ts"],"sourcesContent":["/*\n * This file was automatically generated.\n * DO NOT MODIFY BY HAND.\n * Run `pnpm generate:schema -w` to update.\n */\n\nimport type { Shared } from './ModuleFederationPlugin';\n\nexport interface SharePluginOptions {\n /**\n * Enable/disable asynchronous loading of runtime modules. When enabled, entry points will be wrapped in asynchronous chunks.\n */\n async?: boolean;\n /**\n * Share scope name used for all shared modules (defaults to 'default').\n */\n shareScope?: string | string[];\n shared: Shared;\n /**\n * Experimental features configuration\n */\n experiments?: {\n /** Enable reconstructed lookup for node_modules paths */\n allowNodeModulesSuffixMatch?: boolean;\n };\n}\n"],"mappings":""}

View File

@@ -0,0 +1,6 @@
import { ModuleFederationPlugin_d_exports } from "./ModuleFederationPlugin.js";
import { ContainerPlugin_d_exports } from "./ContainerPlugin.js";
import { ContainerReferencePlugin_d_exports } from "./ContainerReferencePlugin.js";
import { SharePlugin_d_exports } from "./SharePlugin.js";
import { ConsumeSharedPlugin_d_exports } from "./ConsumeSharedPlugin.js";
import { ProvideSharedPlugin_d_exports } from "./ProvideSharedPlugin.js";

View File

@@ -0,0 +1,78 @@
import { TreeShakingStatus } from "../constant.js";
import { RemoteEntryType, StatsAssets } from "./stats.js";
//#region src/types/snapshot.d.ts
interface BasicModuleInfo {
dev?: {
version?: string;
remotes?: {
[nameWithType: string]: string;
};
};
version: string;
buildVersion: string;
remoteTypes: string;
remoteTypesZip: string;
remoteTypesAPI?: string;
remotesInfo: Record<string, {
matchedVersion: string;
}>;
shared: Array<{
sharedName: string;
fallback?: string;
fallbackName?: string;
fallbackType?: RemoteEntryType;
version?: string;
assets: StatsAssets;
treeShakingStatus?: TreeShakingStatus;
secondarySharedTreeShakingEntry?: string;
secondarySharedTreeShakingName?: string;
}>;
}
interface BasicProviderModuleInfo extends BasicModuleInfo {
remoteEntry: string;
remoteEntryType: RemoteEntryType;
ssrRemoteEntry?: string;
ssrRemoteEntryType?: RemoteEntryType;
globalName: string;
modules: Array<{
moduleName: string;
modulePath?: string;
assets: StatsAssets;
}>;
}
interface BasicProviderModuleInfoWithPublicPath extends BasicProviderModuleInfo {
publicPath: string;
ssrPublicPath?: string;
}
interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleInfo {
getPublicPath: string;
}
interface ManifestProvider {
remoteEntry: string;
ssrRemoteEntry?: string;
version?: string;
}
interface PureEntryProvider extends ManifestProvider {
globalName: string;
}
interface BasicConsumerModuleInfo extends BasicModuleInfo {
consumerList: Array<string>;
}
interface ConsumerModuleInfoWithPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
publicPath: string;
ssrPublicPath?: string;
}
interface ConsumerModuleInfoWithGetPublicPath extends BasicConsumerModuleInfo, BasicProviderModuleInfo {
getPublicPath: string;
}
type PureConsumerModuleInfo = Omit<BasicConsumerModuleInfo, 'remoteTypes'>;
type ConsumerModuleInfo = ConsumerModuleInfoWithPublicPath | ConsumerModuleInfoWithGetPublicPath;
type ProviderModuleInfo = BasicProviderModuleInfoWithPublicPath | BasicProviderModuleInfoWithGetPublicPath;
type ModuleInfo = ConsumerModuleInfo | PureConsumerModuleInfo | ProviderModuleInfo;
type GlobalModuleInfo = {
[key: string]: ModuleInfo | ManifestProvider | PureEntryProvider | undefined;
};
//#endregion
export { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider };
//# sourceMappingURL=snapshot.d.ts.map

View File

@@ -0,0 +1,101 @@
import { RemoteWithEntry, RemoteWithVersion } from "./common.js";
//#region src/types/stats.d.ts
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;
interface ResourceInfo {
path: string;
name: string;
type: RemoteEntryType;
}
interface StatsBuildInfo {
buildVersion: string;
buildName: string;
hash?: string;
target?: string[];
plugins?: string[];
excludePlugins?: string[];
}
interface MetaDataTypes {
path: string;
name: string;
api: string;
zip: string;
}
interface BasicStatsMetaData {
name: string;
globalName: string;
buildInfo: StatsBuildInfo;
remoteEntry: ResourceInfo;
ssrRemoteEntry?: ResourceInfo;
types?: MetaDataTypes;
type: string;
pluginVersion?: string;
}
type StatsMetaDataWithGetPublicPath<T = BasicStatsMetaData> = T & {
getPublicPath: string;
};
type StatsMetaDataWithPublicPath<T = BasicStatsMetaData> = T & {
publicPath: string;
ssrPublicPath?: string;
};
type StatsMetaData<T = BasicStatsMetaData> = StatsMetaDataWithGetPublicPath<T> | StatsMetaDataWithPublicPath<T>;
interface StatsAssets {
js: StatsAssetsInfo;
css: StatsAssetsInfo;
}
interface StatsAssetsInfo {
sync: string[];
async: string[];
}
interface StatsShared {
id: string;
name: string;
version: string;
singleton: boolean;
requiredVersion: string;
hash: string;
assets: StatsAssets;
deps: string[];
usedIn: string[];
usedExports: string[];
fallback: string;
fallbackName: string;
fallbackType: RemoteEntryType;
}
interface StatsRemoteVal {
moduleName: string;
federationContainerName: string;
consumingFederationContainerName: string;
alias: string;
usedIn: string[];
}
type StatsRemoteWithEntry<T = StatsRemoteVal> = T & Omit<RemoteWithEntry, 'name'>;
type StatsRemoteWithVersion<T = StatsRemoteVal> = T & Omit<RemoteWithVersion, 'name'>;
type StatsRemote<T = StatsRemoteVal> = StatsRemoteWithEntry<T> | StatsRemoteWithVersion<T>;
interface StatsModuleInfo {
name: string;
file: string[];
}
interface ManifestModuleInfos {
[exposeModuleName: string]: StatsModuleInfo;
}
interface StatsExpose {
id: string;
name: string;
path?: string;
file: string;
requires: string[];
assets: StatsAssets;
hash?: string;
}
interface Stats<T = BasicStatsMetaData, K = StatsRemoteVal> {
id: string;
name: string;
metaData: StatsMetaData<T>;
shared: StatsShared[];
remotes: StatsRemote<K>[];
exposes: StatsExpose[];
}
//#endregion
export { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared };
//# sourceMappingURL=stats.d.ts.map

127
node_modules/@module-federation/sdk/dist/utils.cjs generated vendored Normal file
View File

@@ -0,0 +1,127 @@
const require_constant = require('./constant.cjs');
const require_env = require('./env.cjs');
//#region src/utils.ts
const LOG_CATEGORY = "[ Federation Runtime ]";
const parseEntry = (str, devVerOrUrl, separator = require_constant.SEPARATOR) => {
const strSplit = str.split(separator);
const devVersionOrUrl = require_env.getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl;
const defaultVersion = "*";
const isEntry = (s) => s.startsWith("http") || s.includes(require_constant.MANIFEST_EXT);
if (strSplit.length >= 2) {
let [name, ...versionOrEntryArr] = strSplit;
if (str.startsWith(separator)) {
name = strSplit.slice(0, 2).join(separator);
versionOrEntryArr = [devVersionOrUrl || strSplit.slice(2).join(separator)];
}
let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
if (isEntry(versionOrEntry)) return {
name,
entry: versionOrEntry
};
else return {
name,
version: versionOrEntry || defaultVersion
};
} else if (strSplit.length === 1) {
const [name] = strSplit;
if (devVersionOrUrl && isEntry(devVersionOrUrl)) return {
name,
entry: devVersionOrUrl
};
return {
name,
version: devVersionOrUrl || defaultVersion
};
} else throw `Invalid entry value: ${str}`;
};
const composeKeyWithSeparator = function(...args) {
if (!args.length) return "";
return args.reduce((sum, cur) => {
if (!cur) return sum;
if (!sum) return cur;
return `${sum}${require_constant.SEPARATOR}${cur}`;
}, "");
};
const encodeName = function(name, prefix = "", withExt = false) {
try {
const ext = withExt ? ".js" : "";
return `${prefix}${name.replace(new RegExp(`${require_constant.NameTransformSymbol.AT}`, "g"), require_constant.NameTransformMap[require_constant.NameTransformSymbol.AT]).replace(new RegExp(`${require_constant.NameTransformSymbol.HYPHEN}`, "g"), require_constant.NameTransformMap[require_constant.NameTransformSymbol.HYPHEN]).replace(new RegExp(`${require_constant.NameTransformSymbol.SLASH}`, "g"), require_constant.NameTransformMap[require_constant.NameTransformSymbol.SLASH])}${ext}`;
} catch (err) {
throw err;
}
};
const decodeName = function(name, prefix, withExt) {
try {
let decodedName = name;
if (prefix) {
if (!decodedName.startsWith(prefix)) return decodedName;
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");
}
decodedName = decodedName.replace(new RegExp(`${require_constant.NameTransformMap[require_constant.NameTransformSymbol.AT]}`, "g"), require_constant.EncodedNameTransformMap[require_constant.NameTransformMap[require_constant.NameTransformSymbol.AT]]).replace(new RegExp(`${require_constant.NameTransformMap[require_constant.NameTransformSymbol.SLASH]}`, "g"), require_constant.EncodedNameTransformMap[require_constant.NameTransformMap[require_constant.NameTransformSymbol.SLASH]]).replace(new RegExp(`${require_constant.NameTransformMap[require_constant.NameTransformSymbol.HYPHEN]}`, "g"), require_constant.EncodedNameTransformMap[require_constant.NameTransformMap[require_constant.NameTransformSymbol.HYPHEN]]);
if (withExt) decodedName = decodedName.replace(".js", "");
return decodedName;
} catch (err) {
throw err;
}
};
const generateExposeFilename = (exposeName, withExt) => {
if (!exposeName) return "";
let expose = exposeName;
if (expose === ".") expose = "default_export";
if (expose.startsWith("./")) expose = expose.replace("./", "");
return encodeName(expose, "__federation_expose_", withExt);
};
const generateShareFilename = (pkgName, withExt) => {
if (!pkgName) return "";
return encodeName(pkgName, "__federation_shared_", withExt);
};
const getResourceUrl = (module, sourceUrl) => {
if ("getPublicPath" in module) {
let publicPath;
if (!module.getPublicPath.startsWith("function")) publicPath = new Function(module.getPublicPath)();
else publicPath = new Function("return " + module.getPublicPath)()();
return `${publicPath}${sourceUrl}`;
} else if ("publicPath" in module) {
if (!require_env.isBrowserEnv() && !require_env.isReactNativeEnv() && "ssrPublicPath" in module && typeof module.ssrPublicPath === "string") return `${module.ssrPublicPath}${sourceUrl}`;
return `${module.publicPath}${sourceUrl}`;
} else {
console.warn("Cannot get resource URL. If in debug mode, please ignore.", module, sourceUrl);
return "";
}
};
const assert = (condition, msg) => {
if (!condition) error(msg);
};
const error = (msg) => {
throw new Error(`${LOG_CATEGORY}: ${msg}`);
};
const warn = (msg) => {
console.warn(`${LOG_CATEGORY}: ${msg}`);
};
function safeToString(info) {
try {
return JSON.stringify(info, null, 2);
} catch (e) {
return "";
}
}
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
function isRequiredVersion(str) {
return VERSION_PATTERN_REGEXP.test(str);
}
//#endregion
exports.assert = assert;
exports.composeKeyWithSeparator = composeKeyWithSeparator;
exports.decodeName = decodeName;
exports.encodeName = encodeName;
exports.error = error;
exports.generateExposeFilename = generateExposeFilename;
exports.generateShareFilename = generateShareFilename;
exports.getResourceUrl = getResourceUrl;
exports.isRequiredVersion = isRequiredVersion;
exports.parseEntry = parseEntry;
exports.safeToString = safeToString;
exports.warn = warn;
//# sourceMappingURL=utils.cjs.map

File diff suppressed because one or more lines are too long

21
node_modules/@module-federation/sdk/dist/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { RemoteEntryInfo } from "./types/common.js";
import { ModuleInfo } from "./types/snapshot.js";
//#region src/utils.d.ts
declare const parseEntry: (str: string, devVerOrUrl?: string, separator?: string) => RemoteEntryInfo;
declare global {
var FEDERATION_DEBUG: string | undefined;
}
declare const composeKeyWithSeparator: (...args: (string | undefined)[]) => string;
declare const encodeName: (name: string, prefix?: string, withExt?: boolean) => string;
declare const decodeName: (name: string, prefix?: string, withExt?: boolean) => string;
declare const generateExposeFilename: (exposeName: string, withExt: boolean) => string;
declare const generateShareFilename: (pkgName: string, withExt: boolean) => string;
declare const getResourceUrl: (module: ModuleInfo, sourceUrl: string) => string;
declare const assert: (condition: any, msg: string) => asserts condition;
declare const error: (msg: string | Error | unknown) => never;
declare const warn: (msg: Parameters<typeof console.warn>[0]) => void;
declare function safeToString(info: any): string;
declare function isRequiredVersion(str: string): boolean;
//#endregion
export { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn };
//# sourceMappingURL=utils.d.ts.map

116
node_modules/@module-federation/sdk/dist/utils.js generated vendored Normal file
View File

@@ -0,0 +1,116 @@
import { EncodedNameTransformMap, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR } from "./constant.js";
import { getProcessEnv, isBrowserEnv, isReactNativeEnv } from "./env.js";
//#region src/utils.ts
const LOG_CATEGORY = "[ Federation Runtime ]";
const parseEntry = (str, devVerOrUrl, separator = SEPARATOR) => {
const strSplit = str.split(separator);
const devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl;
const defaultVersion = "*";
const isEntry = (s) => s.startsWith("http") || s.includes(MANIFEST_EXT);
if (strSplit.length >= 2) {
let [name, ...versionOrEntryArr] = strSplit;
if (str.startsWith(separator)) {
name = strSplit.slice(0, 2).join(separator);
versionOrEntryArr = [devVersionOrUrl || strSplit.slice(2).join(separator)];
}
let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
if (isEntry(versionOrEntry)) return {
name,
entry: versionOrEntry
};
else return {
name,
version: versionOrEntry || defaultVersion
};
} else if (strSplit.length === 1) {
const [name] = strSplit;
if (devVersionOrUrl && isEntry(devVersionOrUrl)) return {
name,
entry: devVersionOrUrl
};
return {
name,
version: devVersionOrUrl || defaultVersion
};
} else throw `Invalid entry value: ${str}`;
};
const composeKeyWithSeparator = function(...args) {
if (!args.length) return "";
return args.reduce((sum, cur) => {
if (!cur) return sum;
if (!sum) return cur;
return `${sum}${SEPARATOR}${cur}`;
}, "");
};
const encodeName = function(name, prefix = "", withExt = false) {
try {
const ext = withExt ? ".js" : "";
return `${prefix}${name.replace(new RegExp(`${NameTransformSymbol.AT}`, "g"), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp(`${NameTransformSymbol.HYPHEN}`, "g"), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp(`${NameTransformSymbol.SLASH}`, "g"), NameTransformMap[NameTransformSymbol.SLASH])}${ext}`;
} catch (err) {
throw err;
}
};
const decodeName = function(name, prefix, withExt) {
try {
let decodedName = name;
if (prefix) {
if (!decodedName.startsWith(prefix)) return decodedName;
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");
}
decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
if (withExt) decodedName = decodedName.replace(".js", "");
return decodedName;
} catch (err) {
throw err;
}
};
const generateExposeFilename = (exposeName, withExt) => {
if (!exposeName) return "";
let expose = exposeName;
if (expose === ".") expose = "default_export";
if (expose.startsWith("./")) expose = expose.replace("./", "");
return encodeName(expose, "__federation_expose_", withExt);
};
const generateShareFilename = (pkgName, withExt) => {
if (!pkgName) return "";
return encodeName(pkgName, "__federation_shared_", withExt);
};
const getResourceUrl = (module, sourceUrl) => {
if ("getPublicPath" in module) {
let publicPath;
if (!module.getPublicPath.startsWith("function")) publicPath = new Function(module.getPublicPath)();
else publicPath = new Function("return " + module.getPublicPath)()();
return `${publicPath}${sourceUrl}`;
} else if ("publicPath" in module) {
if (!isBrowserEnv() && !isReactNativeEnv() && "ssrPublicPath" in module && typeof module.ssrPublicPath === "string") return `${module.ssrPublicPath}${sourceUrl}`;
return `${module.publicPath}${sourceUrl}`;
} else {
console.warn("Cannot get resource URL. If in debug mode, please ignore.", module, sourceUrl);
return "";
}
};
const assert = (condition, msg) => {
if (!condition) error(msg);
};
const error = (msg) => {
throw new Error(`${LOG_CATEGORY}: ${msg}`);
};
const warn = (msg) => {
console.warn(`${LOG_CATEGORY}: ${msg}`);
};
function safeToString(info) {
try {
return JSON.stringify(info, null, 2);
} catch (e) {
return "";
}
}
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
function isRequiredVersion(str) {
return VERSION_PATTERN_REGEXP.test(str);
}
//#endregion
export { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn };
//# sourceMappingURL=utils.js.map

File diff suppressed because one or more lines are too long

83
node_modules/@module-federation/sdk/package.json generated vendored Normal file
View File

@@ -0,0 +1,83 @@
{
"name": "@module-federation/sdk",
"version": "2.5.0",
"type": "module",
"license": "MIT",
"description": "A sdk for support module federation",
"keywords": [
"Module Federation",
"sdk"
],
"files": [
"dist/",
"README.md",
"LICENSE"
],
"repository": {
"type": "git",
"url": "git+https://github.com/module-federation/core.git",
"directory": "packages/sdk"
},
"publishConfig": {
"access": "public"
},
"author": "zhanghang <hanric.zhang@gmail.com>",
"sideEffects": false,
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"browser": {
"url": false
},
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
},
"./normalize-webpack-path": {
"import": {
"types": "./dist/normalize-webpack-path.d.ts",
"default": "./dist/normalize-webpack-path.js"
},
"require": {
"types": "./dist/normalize-webpack-path.d.ts",
"default": "./dist/normalize-webpack-path.cjs"
}
}
},
"typesVersions": {
"*": {
".": [
"./dist/index.d.ts"
],
"normalize-webpack-path": [
"./dist/normalize-webpack-path.d.ts"
]
}
},
"devDependencies": {
"@jest/globals": "29.7.0",
"webpack": "^5.0.0"
},
"peerDependencies": {
"node-fetch": "^2.7.0 || ^3.3.2"
},
"peerDependenciesMeta": {
"node-fetch": {
"optional": true
}
},
"scripts": {
"build": "tsdown --config tsdown.config.ts",
"lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
"test": "pnpm exec jest --config jest.config.cjs --passWithNoTests",
"test:ci": "pnpm exec jest --config jest.config.cjs --passWithNoTests --ci --coverage",
"pre-release": "pnpm run test && pnpm run build"
}
}