@module-federation/sdk 2.9.2 → 2.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constant.d.cts +46 -0
- package/dist/createModuleFederationConfig.d.cts +6 -0
- package/dist/dom.d.cts +33 -0
- package/dist/env.d.cts +12 -0
- package/dist/generateSnapshotFromManifest.d.cts +20 -0
- package/dist/index.d.cts +21 -0
- package/dist/logger.d.cts +34 -0
- package/dist/node.d.cts +15 -0
- package/dist/normalize-webpack-path.cjs +103 -4
- package/dist/normalize-webpack-path.cjs.map +1 -1
- package/dist/normalize-webpack-path.d.cts +10 -0
- package/dist/normalize-webpack-path.js +104 -5
- package/dist/normalize-webpack-path.js.map +1 -1
- package/dist/normalizeOptions.d.cts +5 -0
- package/dist/types/common.d.cts +14 -0
- package/dist/types/hooks.d.cts +21 -0
- package/dist/types/index.d.cts +11 -0
- package/dist/types/manifest.d.cts +34 -0
- package/dist/types/plugins/ConsumeSharedPlugin.d.cts +109 -0
- package/dist/types/plugins/ContainerPlugin.d.cts +38 -0
- package/dist/types/plugins/ContainerReferencePlugin.d.cts +24 -0
- package/dist/types/plugins/ModuleFederationPlugin.d.cts +470 -0
- package/dist/types/plugins/ProvideSharedPlugin.d.cts +97 -0
- package/dist/types/plugins/SharePlugin.d.cts +26 -0
- package/dist/types/plugins/index.d.cts +6 -0
- package/dist/types/snapshot.d.cts +78 -0
- package/dist/types/stats.d.cts +101 -0
- package/dist/utils.d.cts +28 -0
- package/package.json +4 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
//#region src/constant.d.ts
|
|
2
|
+
declare const FederationModuleManifest = "federation-manifest.json";
|
|
3
|
+
declare const MANIFEST_EXT = ".json";
|
|
4
|
+
declare const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
5
|
+
declare const NameTransformSymbol: {
|
|
6
|
+
readonly AT: "@";
|
|
7
|
+
readonly HYPHEN: "-";
|
|
8
|
+
readonly SLASH: "/";
|
|
9
|
+
};
|
|
10
|
+
declare const NameTransformMap: {
|
|
11
|
+
readonly "@": "scope_";
|
|
12
|
+
readonly "-": "_";
|
|
13
|
+
readonly "/": "__";
|
|
14
|
+
};
|
|
15
|
+
declare const EncodedNameTransformMap: {
|
|
16
|
+
scope_: "@";
|
|
17
|
+
_: "-";
|
|
18
|
+
__: "/";
|
|
19
|
+
};
|
|
20
|
+
declare const SEPARATOR = ":";
|
|
21
|
+
declare const ManifestFileName = "mf-manifest.json";
|
|
22
|
+
declare const StatsFileName = "mf-stats.json";
|
|
23
|
+
declare const MFModuleType: {
|
|
24
|
+
NPM: string;
|
|
25
|
+
APP: string;
|
|
26
|
+
};
|
|
27
|
+
declare const MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
|
|
28
|
+
declare const ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
29
|
+
declare const TEMP_DIR = ".federation";
|
|
30
|
+
declare const enum TreeShakingStatus {
|
|
31
|
+
/**
|
|
32
|
+
* Not handled by deploy server, needs to infer by the real runtime period.
|
|
33
|
+
*/
|
|
34
|
+
UNKNOWN = 1,
|
|
35
|
+
/**
|
|
36
|
+
* It means the shared has been calculated , runtime should take this shared as first choice.
|
|
37
|
+
*/
|
|
38
|
+
CALCULATED = 2,
|
|
39
|
+
/**
|
|
40
|
+
* It means the shared has been calculated, and marked as no used
|
|
41
|
+
*/
|
|
42
|
+
NO_USE = 0
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { BROWSER_LOG_KEY, ENCODE_NAME_PREFIX, EncodedNameTransformMap, FederationModuleManifest, MANIFEST_EXT, MFModuleType, MODULE_DEVTOOL_IDENTIFIER, ManifestFileName, NameTransformMap, NameTransformSymbol, SEPARATOR, StatsFileName, TEMP_DIR, TreeShakingStatus };
|
|
46
|
+
//# sourceMappingURL=constant.d.cts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ModuleFederationPluginOptions } from "./types/plugins/ModuleFederationPlugin.cjs";
|
|
2
|
+
//#region src/createModuleFederationConfig.d.ts
|
|
3
|
+
declare const createModuleFederationConfig: (options: ModuleFederationPluginOptions) => ModuleFederationPluginOptions;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { createModuleFederationConfig };
|
|
6
|
+
//# sourceMappingURL=createModuleFederationConfig.d.cts.map
|
package/dist/dom.d.cts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CreateLinkHookDom, CreateScriptHookDom } from "./types/hooks.cjs";
|
|
2
|
+
//#region src/dom.d.ts
|
|
3
|
+
declare function safeWrapper<T extends (...args: Array<any>) => any>(callback: T, disableWarn?: boolean): Promise<ReturnType<T> | undefined>;
|
|
4
|
+
declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
|
|
5
|
+
declare function createScript(info: {
|
|
6
|
+
url: string;
|
|
7
|
+
cb?: (value: void | PromiseLike<void>) => void;
|
|
8
|
+
onErrorCallback?: (error: Error) => void;
|
|
9
|
+
attrs?: Record<string, any>;
|
|
10
|
+
needDeleteScript?: boolean;
|
|
11
|
+
createScriptHook?: CreateScriptHookDom;
|
|
12
|
+
}): {
|
|
13
|
+
script: HTMLScriptElement;
|
|
14
|
+
needAttach: boolean;
|
|
15
|
+
};
|
|
16
|
+
declare function createLink(info: {
|
|
17
|
+
url: string;
|
|
18
|
+
cb?: (value: void | PromiseLike<void>) => void;
|
|
19
|
+
onErrorCallback?: (error: Error) => void;
|
|
20
|
+
attrs: Record<string, string>;
|
|
21
|
+
needDeleteLink?: boolean;
|
|
22
|
+
createLinkHook?: CreateLinkHookDom;
|
|
23
|
+
}): {
|
|
24
|
+
link: HTMLLinkElement;
|
|
25
|
+
needAttach: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare function loadScript(url: string, info: {
|
|
28
|
+
attrs?: Record<string, any>;
|
|
29
|
+
createScriptHook?: CreateScriptHookDom;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper };
|
|
33
|
+
//# sourceMappingURL=dom.d.cts.map
|
package/dist/env.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/env.d.ts
|
|
2
|
+
declare global {
|
|
3
|
+
var FEDERATION_DEBUG: string | undefined;
|
|
4
|
+
}
|
|
5
|
+
declare const isBrowserEnvValue: boolean;
|
|
6
|
+
declare function isBrowserEnv(): boolean;
|
|
7
|
+
declare function isReactNativeEnv(): boolean;
|
|
8
|
+
declare function isDebugMode(): boolean;
|
|
9
|
+
declare const getProcessEnv: () => Record<string, string | undefined>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv };
|
|
12
|
+
//# sourceMappingURL=env.d.cts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Manifest } from "./types/manifest.cjs";
|
|
2
|
+
import { ManifestProvider, ModuleInfo, ProviderModuleInfo } from "./types/snapshot.cjs";
|
|
3
|
+
import { ModuleFederationPluginOptions } from "./types/plugins/ModuleFederationPlugin.cjs";
|
|
4
|
+
//#region src/generateSnapshotFromManifest.d.ts
|
|
5
|
+
interface IOptions {
|
|
6
|
+
remotes?: Record<string, string>;
|
|
7
|
+
overrides?: Record<string, string>;
|
|
8
|
+
version?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const simpleJoinRemoteEntry: (rPath: string, rName: string) => string;
|
|
11
|
+
declare function inferAutoPublicPath(url: string): string;
|
|
12
|
+
declare function generateSnapshotFromManifest(manifest: Manifest, options?: IOptions): ProviderModuleInfo;
|
|
13
|
+
declare function isManifestProvider(moduleInfo: ModuleInfo | ManifestProvider): moduleInfo is ManifestProvider;
|
|
14
|
+
declare function getManifestFileName(manifestOptions?: ModuleFederationPluginOptions['manifest']): {
|
|
15
|
+
statsFileName: string;
|
|
16
|
+
manifestFileName: string;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry };
|
|
20
|
+
//# sourceMappingURL=generateSnapshotFromManifest.d.cts.map
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
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.cjs";
|
|
2
|
+
import { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion } from "./types/common.cjs";
|
|
3
|
+
import { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared } from "./types/stats.cjs";
|
|
4
|
+
import { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared } from "./types/manifest.cjs";
|
|
5
|
+
import { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider } from "./types/snapshot.cjs";
|
|
6
|
+
import { ModuleFederationPlugin_d_exports } from "./types/plugins/ModuleFederationPlugin.cjs";
|
|
7
|
+
import { ContainerPlugin_d_exports } from "./types/plugins/ContainerPlugin.cjs";
|
|
8
|
+
import { ContainerReferencePlugin_d_exports } from "./types/plugins/ContainerReferencePlugin.cjs";
|
|
9
|
+
import { SharePlugin_d_exports } from "./types/plugins/SharePlugin.cjs";
|
|
10
|
+
import { ConsumeSharedPlugin_d_exports } from "./types/plugins/ConsumeSharedPlugin.cjs";
|
|
11
|
+
import { ProvideSharedPlugin_d_exports } from "./types/plugins/ProvideSharedPlugin.cjs";
|
|
12
|
+
import { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook } from "./types/hooks.cjs";
|
|
13
|
+
import { assert, composeKeyWithSeparator, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, getResourceUrl, isRequiredVersion, parseEntry, safeToString, warn } from "./utils.cjs";
|
|
14
|
+
import { generateSnapshotFromManifest, getManifestFileName, inferAutoPublicPath, isManifestProvider, simpleJoinRemoteEntry } from "./generateSnapshotFromManifest.cjs";
|
|
15
|
+
import { InfrastructureLogger, Logger, bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger } from "./logger.cjs";
|
|
16
|
+
import { getProcessEnv, isBrowserEnv, isBrowserEnvValue, isDebugMode, isReactNativeEnv } from "./env.cjs";
|
|
17
|
+
import { createLink, createScript, isStaticResourcesEqual, loadScript, safeWrapper } from "./dom.cjs";
|
|
18
|
+
import { createScriptNode, loadScriptNode } from "./node.cjs";
|
|
19
|
+
import { normalizeOptions } from "./normalizeOptions.cjs";
|
|
20
|
+
import { createModuleFederationConfig } from "./createModuleFederationConfig.cjs";
|
|
21
|
+
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 };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/logger.d.ts
|
|
2
|
+
type LogMethod = 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
3
|
+
type LoggerDelegate = Partial<Record<LogMethod, (...args: any[]) => void>> & {
|
|
4
|
+
[key: string]: ((...args: any[]) => void) | undefined;
|
|
5
|
+
};
|
|
6
|
+
declare class Logger {
|
|
7
|
+
prefix: string;
|
|
8
|
+
private delegate;
|
|
9
|
+
constructor(prefix: string, delegate?: LoggerDelegate);
|
|
10
|
+
setPrefix(prefix: string): void;
|
|
11
|
+
setDelegate(delegate?: LoggerDelegate): void;
|
|
12
|
+
private emit;
|
|
13
|
+
log(...args: any[]): void;
|
|
14
|
+
warn(...args: any[]): void;
|
|
15
|
+
error(...args: any[]): void;
|
|
16
|
+
success(...args: any[]): void;
|
|
17
|
+
info(...args: any[]): void;
|
|
18
|
+
ready(...args: any[]): void;
|
|
19
|
+
debug(...args: any[]): void;
|
|
20
|
+
}
|
|
21
|
+
declare function createLogger(prefix: string): Logger;
|
|
22
|
+
type InfrastructureLogger = Logger & {
|
|
23
|
+
__mf_infrastructure_logger__: true;
|
|
24
|
+
};
|
|
25
|
+
declare function createInfrastructureLogger(prefix: string): InfrastructureLogger;
|
|
26
|
+
type InfrastructureLoggerCapableCompiler = {
|
|
27
|
+
getInfrastructureLogger?: (name: string) => unknown;
|
|
28
|
+
};
|
|
29
|
+
declare function bindLoggerToCompiler(loggerInstance: Logger, compiler: InfrastructureLoggerCapableCompiler, name: string): void;
|
|
30
|
+
declare const logger: Logger;
|
|
31
|
+
declare const infrastructureLogger: InfrastructureLogger;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { type InfrastructureLogger, type Logger, bindLoggerToCompiler, createInfrastructureLogger, createLogger, infrastructureLogger, logger };
|
|
34
|
+
//# sourceMappingURL=logger.d.cts.map
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CreateScriptHookNode, FetchHook } from "./types/hooks.cjs";
|
|
2
|
+
//#region src/node.d.ts
|
|
3
|
+
declare const createScriptNode: (url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, loaderHook?: {
|
|
4
|
+
createScriptHook?: CreateScriptHookNode;
|
|
5
|
+
fetch?: FetchHook;
|
|
6
|
+
}) => void;
|
|
7
|
+
declare const loadScriptNode: (url: string, info: {
|
|
8
|
+
attrs?: Record<string, any>;
|
|
9
|
+
loaderHook?: {
|
|
10
|
+
createScriptHook?: CreateScriptHookNode;
|
|
11
|
+
};
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { createScriptNode, loadScriptNode };
|
|
15
|
+
//# sourceMappingURL=node.d.cts.map
|
|
@@ -1,9 +1,67 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_module = require("node:module");
|
|
2
4
|
let node_path = require("node:path");
|
|
5
|
+
let node_url = require("node:url");
|
|
3
6
|
|
|
4
7
|
//#region src/normalize-webpack-path.ts
|
|
8
|
+
const webpackInternalPaths = {
|
|
9
|
+
"webpack/lib/Module": "webpack/lib/module/Module",
|
|
10
|
+
"webpack/lib/ModuleFactory": "webpack/lib/module/ModuleFactory",
|
|
11
|
+
"webpack/lib/NormalModuleFactory": "webpack/lib/module/NormalModuleFactory",
|
|
12
|
+
"webpack/lib/ExternalModule": "webpack/lib/externals/ExternalModule",
|
|
13
|
+
"webpack/lib/RuntimeModule": "webpack/lib/runtime/RuntimeModule",
|
|
14
|
+
"webpack/lib/RuntimeGlobals": "webpack/lib/runtime/RuntimeGlobals",
|
|
15
|
+
"webpack/lib/RuntimeTemplate": "webpack/lib/template/RuntimeTemplate",
|
|
16
|
+
"webpack/lib/ResolverFactory": "webpack/lib/resolve/ResolverFactory",
|
|
17
|
+
"webpack/lib/ChunkGraph": "webpack/lib/graph/ChunkGraph",
|
|
18
|
+
"webpack/lib/HotUpdateChunk": "webpack/lib/graph/HotUpdateChunk",
|
|
19
|
+
"webpack/lib/dependencies/EntryDependency": "webpack/lib/entry/EntryDependency",
|
|
20
|
+
"webpack/lib/dependencies/ModuleDependency": "webpack/lib/dependencies/core/ModuleDependency",
|
|
21
|
+
"webpack/lib/dependencies/StaticExportsDependency": "webpack/lib/dependencies/core/StaticExportsDependency",
|
|
22
|
+
"webpack/lib/util/extractUrlAndGlobal": "webpack/lib/externals/extractUrlAndGlobal",
|
|
23
|
+
"webpack/lib/util/fs": "webpack/lib/fs/fs",
|
|
24
|
+
"webpack/lib/util/semver": "webpack/lib/sharing/semver"
|
|
25
|
+
};
|
|
26
|
+
let webpackRequire;
|
|
27
|
+
const callerWebpack = /* @__PURE__ */ new Map();
|
|
28
|
+
const createSdkWebpackRequire = () => (0, node_module.createRequire)(__filename);
|
|
29
|
+
const getWebpackRequire = () => {
|
|
30
|
+
if (process.env["FEDERATION_WEBPACK_PATH"]) {
|
|
31
|
+
webpackRequire ??= createSdkWebpackRequire();
|
|
32
|
+
return {
|
|
33
|
+
request: webpackRequire,
|
|
34
|
+
root: void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const prepareStackTrace = Error.prepareStackTrace;
|
|
38
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
39
|
+
try {
|
|
40
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
41
|
+
Error.stackTraceLimit = Math.max(stackTraceLimit ?? 0, 10);
|
|
42
|
+
const error = /* @__PURE__ */ new Error();
|
|
43
|
+
Error.captureStackTrace(error, getWebpackRequire);
|
|
44
|
+
const callSites = error.stack;
|
|
45
|
+
const caller = (Array.isArray(callSites) ? callSites : []).slice(1).map((callSite) => callSite.getFileName()).find((fileName) => !!fileName && ((0, node_path.isAbsolute)(fileName) || fileName.startsWith("file:")));
|
|
46
|
+
const callerFile = caller?.startsWith("file:") ? (0, node_url.fileURLToPath)(caller) : caller || (0, node_path.resolve)(process.cwd(), "package.json");
|
|
47
|
+
const callerDir = (0, node_path.dirname)(callerFile);
|
|
48
|
+
let located = callerWebpack.get(callerDir);
|
|
49
|
+
if (!located) {
|
|
50
|
+
const request = (0, node_module.createRequire)(callerFile);
|
|
51
|
+
const webpackRoot = findWebpackRoot(request);
|
|
52
|
+
located = {
|
|
53
|
+
request,
|
|
54
|
+
root: webpackRoot ? (0, node_fs.realpathSync)(webpackRoot) + node_path.sep : void 0
|
|
55
|
+
};
|
|
56
|
+
callerWebpack.set(callerDir, located);
|
|
57
|
+
}
|
|
58
|
+
return located;
|
|
59
|
+
} finally {
|
|
60
|
+
Error.prepareStackTrace = prepareStackTrace;
|
|
61
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
5
64
|
function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
6
|
-
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
|
|
7
65
|
try {
|
|
8
66
|
compiler.webpack();
|
|
9
67
|
return "";
|
|
@@ -13,13 +71,54 @@ function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
|
13
71
|
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
|
|
14
72
|
return "";
|
|
15
73
|
}
|
|
16
|
-
return
|
|
74
|
+
if (!webpackPath) return "";
|
|
75
|
+
try {
|
|
76
|
+
const entry = (0, node_module.createRequire)(webpackPath).resolve("webpack");
|
|
77
|
+
return webpackPath.startsWith((0, node_path.resolve)(entry, "../..") + node_path.sep) ? entry : "";
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
17
82
|
}
|
|
18
83
|
}
|
|
84
|
+
const findWebpackRoot = (request) => {
|
|
85
|
+
let entry;
|
|
86
|
+
try {
|
|
87
|
+
entry = request.resolve("webpack");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error.code === "MODULE_NOT_FOUND") return;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
for (let dir = (0, node_path.dirname)(entry); dir !== (0, node_path.dirname)(dir); dir = (0, node_path.dirname)(dir)) {
|
|
93
|
+
const manifest = (0, node_path.join)(dir, "package.json");
|
|
94
|
+
if ((0, node_fs.existsSync)(manifest) && JSON.parse((0, node_fs.readFileSync)(manifest, "utf8")).name === "webpack") return dir;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
19
97
|
const normalizeWebpackPath = (fullPath) => {
|
|
20
98
|
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
|
|
21
|
-
|
|
22
|
-
|
|
99
|
+
const normalize = (path) => process.env["FEDERATION_WEBPACK_PATH"] ? (0, node_path.resolve)(process.env["FEDERATION_WEBPACK_PATH"], path.replace("webpack", "../../")) : path;
|
|
100
|
+
const candidate = normalize(fullPath);
|
|
101
|
+
const relocatedPath = webpackInternalPaths[fullPath];
|
|
102
|
+
if (!relocatedPath) return candidate;
|
|
103
|
+
const { request: requestWebpack, root } = getWebpackRequire();
|
|
104
|
+
const resolves = (request, inside) => {
|
|
105
|
+
try {
|
|
106
|
+
const resolved = requestWebpack.resolve(request);
|
|
107
|
+
return !inside || (0, node_fs.realpathSync)(resolved).startsWith(inside);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
const { code } = error;
|
|
110
|
+
if (code === "MODULE_NOT_FOUND" || inside && code === "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
if (root) {
|
|
115
|
+
if (resolves(fullPath, root)) return fullPath;
|
|
116
|
+
if (resolves(relocatedPath, root)) return relocatedPath;
|
|
117
|
+
}
|
|
118
|
+
if (resolves(candidate)) return candidate;
|
|
119
|
+
const fallback = normalize(relocatedPath);
|
|
120
|
+
requestWebpack.resolve(fallback);
|
|
121
|
+
return fallback;
|
|
23
122
|
};
|
|
24
123
|
|
|
25
124
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-webpack-path.cjs","names":[],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { resolve } from 'node:path';\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\n const resolveWithContext = new Function(\n 'id',\n 'options',\n 'return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)',\n ) as (id: string, options?: { paths?: string[] }) => string;\n\n try {\n // @ts-ignore just throw err\n compiler.webpack();\n return '';\n } catch (err) {\n const trace = (err as Error).stack?.split('\\n') || [];\n const webpackErrLocation =\n trace.find((item) => item.includes('at webpack')) || '';\n const webpackLocationWithDetail = webpackErrLocation\n .replace(/[^\\(\\)]+/, '')\n .slice(1, -1);\n const webpackPath = webpackLocationWithDetail\n .split(':')\n .slice(0, -2)\n .join(':');\n if (options?.framework === 'nextjs') {\n if (webpackPath.endsWith('webpack.js')) {\n return webpackPath.replace('webpack.js', 'index.js');\n }\n return '';\n }\n return resolveWithContext('webpack', { paths: [webpackPath] });\n }\n}\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n return resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n fullPath.replace('webpack', '../../'),\n );\n }\n\n return fullPath;\n};\n"],"mappings":";;;;AAGA,SAAgB,eACd,UACA,UAA6C,EAAE,WAAW,SAAS,EAC3D;CACR,MAAM,qBAAqB,IAAI,SAC7B,MACA,WACA,gFACD;AAED,KAAI;AAEF,WAAS,SAAS;AAClB,SAAO;UACA,KAAK;EAOZ,MAAM,gBANS,IAAc,OAAO,MAAM,KAAK,IAAI,EAAE,EAE7C,MAAM,SAAS,KAAK,SAAS,aAAa,CAAC,IAAI,IAEpD,QAAQ,YAAY,GAAG,CACvB,MAAM,GAAG,GAAG,CAEZ,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;AACZ,MAAI,SAAS,cAAc,UAAU;AACnC,OAAI,YAAY,SAAS,aAAa,CACpC,QAAO,YAAY,QAAQ,cAAc,WAAW;AAEtD,UAAO;;AAET,SAAO,mBAAmB,WAAW,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;;;AAIlE,MAAa,wBAAwB,aAA6B;AAChE,KAAI,aAAa,UACf,QAAO,QAAQ,IAAI,8BAA8B;AAGnD,KAAI,QAAQ,IAAI,2BACd,+BACE,QAAQ,IAAI,4BACZ,SAAS,QAAQ,WAAW,SAAS,CACtC;AAGH,QAAO"}
|
|
1
|
+
{"version":3,"file":"normalize-webpack-path.cjs","names":["sep"],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, isAbsolute, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Webpack 5.112 reorganized internals without retaining every old location.\n// Keep the old layout preferred for older installations and patched copies.\nconst webpackInternalPaths: Record<string, string> = {\n 'webpack/lib/Module': 'webpack/lib/module/Module',\n 'webpack/lib/ModuleFactory': 'webpack/lib/module/ModuleFactory',\n 'webpack/lib/NormalModuleFactory': 'webpack/lib/module/NormalModuleFactory',\n 'webpack/lib/ExternalModule': 'webpack/lib/externals/ExternalModule',\n 'webpack/lib/RuntimeModule': 'webpack/lib/runtime/RuntimeModule',\n 'webpack/lib/RuntimeGlobals': 'webpack/lib/runtime/RuntimeGlobals',\n 'webpack/lib/RuntimeTemplate': 'webpack/lib/template/RuntimeTemplate',\n 'webpack/lib/ResolverFactory': 'webpack/lib/resolve/ResolverFactory',\n 'webpack/lib/ChunkGraph': 'webpack/lib/graph/ChunkGraph',\n 'webpack/lib/HotUpdateChunk': 'webpack/lib/graph/HotUpdateChunk',\n 'webpack/lib/dependencies/EntryDependency':\n 'webpack/lib/entry/EntryDependency',\n 'webpack/lib/dependencies/ModuleDependency':\n 'webpack/lib/dependencies/core/ModuleDependency',\n 'webpack/lib/dependencies/StaticExportsDependency':\n 'webpack/lib/dependencies/core/StaticExportsDependency',\n 'webpack/lib/util/extractUrlAndGlobal':\n 'webpack/lib/externals/extractUrlAndGlobal',\n 'webpack/lib/util/fs': 'webpack/lib/fs/fs',\n 'webpack/lib/util/semver': 'webpack/lib/sharing/semver',\n};\n\nlet webpackRequire: NodeRequire | undefined;\nconst callerWebpack = new Map<\n string,\n { request: NodeRequire; root: string | undefined }\n>();\n\nconst createSdkWebpackRequire = (): NodeRequire =>\n createRequire(\n // This entrypoint is emitted as both CJS and ESM.\n // @ts-ignore import.meta is used only in the ESM output.\n process.env.IS_ESM_BUILD === 'true' ? import.meta.url : __filename,\n );\n\nconst getWebpackRequire = (): {\n request: NodeRequire;\n root: string | undefined;\n} => {\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n webpackRequire ??= createSdkWebpackRequire();\n return { request: webpackRequire, root: undefined };\n }\n\n // The SDK has no runtime webpack dependency. Use the calling package's resolver.\n const prepareStackTrace = Error.prepareStackTrace;\n const stackTraceLimit = Error.stackTraceLimit;\n try {\n Error.prepareStackTrace = (_error, callSites) => callSites;\n Error.stackTraceLimit = Math.max(stackTraceLimit ?? 0, 10);\n const error = new Error();\n Error.captureStackTrace(error, getWebpackRequire);\n const callSites = error.stack as unknown;\n const caller = (Array.isArray(callSites) ? callSites : [])\n .slice(1)\n .map((callSite: NodeJS.CallSite) => callSite.getFileName())\n .find(\n (fileName): fileName is string =>\n !!fileName && (isAbsolute(fileName) || fileName.startsWith('file:')),\n );\n const callerFile = caller?.startsWith('file:')\n ? fileURLToPath(caller)\n : caller || resolve(process.cwd(), 'package.json');\n const callerDir = dirname(callerFile);\n let located = callerWebpack.get(callerDir);\n if (!located) {\n const request = createRequire(callerFile);\n const webpackRoot = findWebpackRoot(request);\n located = {\n request,\n root: webpackRoot ? realpathSync(webpackRoot) + sep : undefined,\n };\n callerWebpack.set(callerDir, located);\n }\n return located;\n } finally {\n Error.prepareStackTrace = prepareStackTrace;\n Error.stackTraceLimit = stackTraceLimit;\n }\n};\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\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 if (!webpackPath) {\n return '';\n }\n try {\n const entry = createRequire(webpackPath).resolve('webpack');\n // A bundled compiler resolves to an unrelated installation, or to none.\n // Only report the package that contains the active compiler.\n return webpackPath.startsWith(resolve(entry, '../..') + sep) ? entry : '';\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {\n throw error;\n }\n return '';\n }\n }\n}\n\nconst findWebpackRoot = (request: NodeRequire): string | undefined => {\n let entry: string;\n try {\n entry = request.resolve('webpack');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {\n return undefined;\n }\n throw error;\n }\n for (let dir = dirname(entry); dir !== dirname(dir); dir = dirname(dir)) {\n const manifest = join(dir, 'package.json');\n if (\n existsSync(manifest) &&\n JSON.parse(readFileSync(manifest, 'utf8')).name === 'webpack'\n ) {\n return dir;\n }\n }\n return undefined;\n};\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n const normalize = (path: string): string =>\n process.env['FEDERATION_WEBPACK_PATH']\n ? resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n path.replace('webpack', '../../'),\n )\n : path;\n const candidate = normalize(fullPath);\n const relocatedPath = webpackInternalPaths[fullPath];\n if (!relocatedPath) {\n return candidate;\n }\n\n const { request: requestWebpack, root } = getWebpackRequire();\n const resolves = (request: string, inside?: string): boolean => {\n try {\n // Resolve candidates without executing them.\n const resolved = requestWebpack.resolve(request);\n return !inside || realpathSync(resolved).startsWith(inside);\n } catch (error) {\n const { code } = error as NodeJS.ErrnoException;\n if (\n code === 'MODULE_NOT_FOUND' ||\n (inside && code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n return false;\n }\n throw error;\n }\n };\n\n if (root) {\n // Bare requests can find an ancestor webpack's internals. Accept only\n // candidates inside the caller's webpack, including PnP and exports maps.\n if (resolves(fullPath, root)) return fullPath;\n if (resolves(relocatedPath, root)) return relocatedPath;\n }\n\n if (resolves(candidate)) {\n return candidate;\n }\n const fallback = normalize(relocatedPath);\n requestWebpack.resolve(fallback);\n return fallback;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import webpack from "webpack";
|
|
2
|
+
|
|
3
|
+
//#region src/normalize-webpack-path.d.ts
|
|
4
|
+
declare function getWebpackPath(compiler: webpack.Compiler, options?: {
|
|
5
|
+
framework: 'nextjs' | 'other';
|
|
6
|
+
}): string;
|
|
7
|
+
declare const normalizeWebpackPath: (fullPath: string) => string;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getWebpackPath, normalizeWebpackPath };
|
|
10
|
+
//# sourceMappingURL=normalize-webpack-path.d.cts.map
|
|
@@ -1,8 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
2
5
|
|
|
3
6
|
//#region src/normalize-webpack-path.ts
|
|
7
|
+
const webpackInternalPaths = {
|
|
8
|
+
"webpack/lib/Module": "webpack/lib/module/Module",
|
|
9
|
+
"webpack/lib/ModuleFactory": "webpack/lib/module/ModuleFactory",
|
|
10
|
+
"webpack/lib/NormalModuleFactory": "webpack/lib/module/NormalModuleFactory",
|
|
11
|
+
"webpack/lib/ExternalModule": "webpack/lib/externals/ExternalModule",
|
|
12
|
+
"webpack/lib/RuntimeModule": "webpack/lib/runtime/RuntimeModule",
|
|
13
|
+
"webpack/lib/RuntimeGlobals": "webpack/lib/runtime/RuntimeGlobals",
|
|
14
|
+
"webpack/lib/RuntimeTemplate": "webpack/lib/template/RuntimeTemplate",
|
|
15
|
+
"webpack/lib/ResolverFactory": "webpack/lib/resolve/ResolverFactory",
|
|
16
|
+
"webpack/lib/ChunkGraph": "webpack/lib/graph/ChunkGraph",
|
|
17
|
+
"webpack/lib/HotUpdateChunk": "webpack/lib/graph/HotUpdateChunk",
|
|
18
|
+
"webpack/lib/dependencies/EntryDependency": "webpack/lib/entry/EntryDependency",
|
|
19
|
+
"webpack/lib/dependencies/ModuleDependency": "webpack/lib/dependencies/core/ModuleDependency",
|
|
20
|
+
"webpack/lib/dependencies/StaticExportsDependency": "webpack/lib/dependencies/core/StaticExportsDependency",
|
|
21
|
+
"webpack/lib/util/extractUrlAndGlobal": "webpack/lib/externals/extractUrlAndGlobal",
|
|
22
|
+
"webpack/lib/util/fs": "webpack/lib/fs/fs",
|
|
23
|
+
"webpack/lib/util/semver": "webpack/lib/sharing/semver"
|
|
24
|
+
};
|
|
25
|
+
let webpackRequire;
|
|
26
|
+
const callerWebpack = /* @__PURE__ */ new Map();
|
|
27
|
+
const createSdkWebpackRequire = () => createRequire(import.meta.url);
|
|
28
|
+
const getWebpackRequire = () => {
|
|
29
|
+
if (process.env["FEDERATION_WEBPACK_PATH"]) {
|
|
30
|
+
webpackRequire ??= createSdkWebpackRequire();
|
|
31
|
+
return {
|
|
32
|
+
request: webpackRequire,
|
|
33
|
+
root: void 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const prepareStackTrace = Error.prepareStackTrace;
|
|
37
|
+
const stackTraceLimit = Error.stackTraceLimit;
|
|
38
|
+
try {
|
|
39
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
40
|
+
Error.stackTraceLimit = Math.max(stackTraceLimit ?? 0, 10);
|
|
41
|
+
const error = /* @__PURE__ */ new Error();
|
|
42
|
+
Error.captureStackTrace(error, getWebpackRequire);
|
|
43
|
+
const callSites = error.stack;
|
|
44
|
+
const caller = (Array.isArray(callSites) ? callSites : []).slice(1).map((callSite) => callSite.getFileName()).find((fileName) => !!fileName && (isAbsolute(fileName) || fileName.startsWith("file:")));
|
|
45
|
+
const callerFile = caller?.startsWith("file:") ? fileURLToPath(caller) : caller || resolve(process.cwd(), "package.json");
|
|
46
|
+
const callerDir = dirname(callerFile);
|
|
47
|
+
let located = callerWebpack.get(callerDir);
|
|
48
|
+
if (!located) {
|
|
49
|
+
const request = createRequire(callerFile);
|
|
50
|
+
const webpackRoot = findWebpackRoot(request);
|
|
51
|
+
located = {
|
|
52
|
+
request,
|
|
53
|
+
root: webpackRoot ? realpathSync(webpackRoot) + sep : void 0
|
|
54
|
+
};
|
|
55
|
+
callerWebpack.set(callerDir, located);
|
|
56
|
+
}
|
|
57
|
+
return located;
|
|
58
|
+
} finally {
|
|
59
|
+
Error.prepareStackTrace = prepareStackTrace;
|
|
60
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
4
63
|
function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
5
|
-
const resolveWithContext = new Function("id", "options", "return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)");
|
|
6
64
|
try {
|
|
7
65
|
compiler.webpack();
|
|
8
66
|
return "";
|
|
@@ -12,13 +70,54 @@ function getWebpackPath(compiler, options = { framework: "other" }) {
|
|
|
12
70
|
if (webpackPath.endsWith("webpack.js")) return webpackPath.replace("webpack.js", "index.js");
|
|
13
71
|
return "";
|
|
14
72
|
}
|
|
15
|
-
return
|
|
73
|
+
if (!webpackPath) return "";
|
|
74
|
+
try {
|
|
75
|
+
const entry = createRequire(webpackPath).resolve("webpack");
|
|
76
|
+
return webpackPath.startsWith(resolve(entry, "../..") + sep) ? entry : "";
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error.code !== "MODULE_NOT_FOUND") throw error;
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
16
81
|
}
|
|
17
82
|
}
|
|
83
|
+
const findWebpackRoot = (request) => {
|
|
84
|
+
let entry;
|
|
85
|
+
try {
|
|
86
|
+
entry = request.resolve("webpack");
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error.code === "MODULE_NOT_FOUND") return;
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
for (let dir = dirname(entry); dir !== dirname(dir); dir = dirname(dir)) {
|
|
92
|
+
const manifest = join(dir, "package.json");
|
|
93
|
+
if (existsSync(manifest) && JSON.parse(readFileSync(manifest, "utf8")).name === "webpack") return dir;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
18
96
|
const normalizeWebpackPath = (fullPath) => {
|
|
19
97
|
if (fullPath === "webpack") return process.env["FEDERATION_WEBPACK_PATH"] || fullPath;
|
|
20
|
-
|
|
21
|
-
|
|
98
|
+
const normalize = (path) => process.env["FEDERATION_WEBPACK_PATH"] ? resolve(process.env["FEDERATION_WEBPACK_PATH"], path.replace("webpack", "../../")) : path;
|
|
99
|
+
const candidate = normalize(fullPath);
|
|
100
|
+
const relocatedPath = webpackInternalPaths[fullPath];
|
|
101
|
+
if (!relocatedPath) return candidate;
|
|
102
|
+
const { request: requestWebpack, root } = getWebpackRequire();
|
|
103
|
+
const resolves = (request, inside) => {
|
|
104
|
+
try {
|
|
105
|
+
const resolved = requestWebpack.resolve(request);
|
|
106
|
+
return !inside || realpathSync(resolved).startsWith(inside);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const { code } = error;
|
|
109
|
+
if (code === "MODULE_NOT_FOUND" || inside && code === "ERR_PACKAGE_PATH_NOT_EXPORTED") return false;
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
if (root) {
|
|
114
|
+
if (resolves(fullPath, root)) return fullPath;
|
|
115
|
+
if (resolves(relocatedPath, root)) return relocatedPath;
|
|
116
|
+
}
|
|
117
|
+
if (resolves(candidate)) return candidate;
|
|
118
|
+
const fallback = normalize(relocatedPath);
|
|
119
|
+
requestWebpack.resolve(fallback);
|
|
120
|
+
return fallback;
|
|
22
121
|
};
|
|
23
122
|
|
|
24
123
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-webpack-path.js","names":[],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { resolve } from 'node:path';\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\n const resolveWithContext = new Function(\n 'id',\n 'options',\n 'return typeof require === \"undefined\" ? \"\" : require.resolve(id, options)',\n ) as (id: string, options?: { paths?: string[] }) => string;\n\n try {\n // @ts-ignore just throw err\n compiler.webpack();\n return '';\n } catch (err) {\n const trace = (err as Error).stack?.split('\\n') || [];\n const webpackErrLocation =\n trace.find((item) => item.includes('at webpack')) || '';\n const webpackLocationWithDetail = webpackErrLocation\n .replace(/[^\\(\\)]+/, '')\n .slice(1, -1);\n const webpackPath = webpackLocationWithDetail\n .split(':')\n .slice(0, -2)\n .join(':');\n if (options?.framework === 'nextjs') {\n if (webpackPath.endsWith('webpack.js')) {\n return webpackPath.replace('webpack.js', 'index.js');\n }\n return '';\n }\n return resolveWithContext('webpack', { paths: [webpackPath] });\n }\n}\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n return resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n fullPath.replace('webpack', '../../'),\n );\n }\n\n return fullPath;\n};\n"],"mappings":";;;AAGA,SAAgB,eACd,UACA,UAA6C,EAAE,WAAW,SAAS,EAC3D;CACR,MAAM,qBAAqB,IAAI,SAC7B,MACA,WACA,gFACD;AAED,KAAI;AAEF,WAAS,SAAS;AAClB,SAAO;UACA,KAAK;EAOZ,MAAM,gBANS,IAAc,OAAO,MAAM,KAAK,IAAI,EAAE,EAE7C,MAAM,SAAS,KAAK,SAAS,aAAa,CAAC,IAAI,IAEpD,QAAQ,YAAY,GAAG,CACvB,MAAM,GAAG,GAAG,CAEZ,MAAM,IAAI,CACV,MAAM,GAAG,GAAG,CACZ,KAAK,IAAI;AACZ,MAAI,SAAS,cAAc,UAAU;AACnC,OAAI,YAAY,SAAS,aAAa,CACpC,QAAO,YAAY,QAAQ,cAAc,WAAW;AAEtD,UAAO;;AAET,SAAO,mBAAmB,WAAW,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;;;AAIlE,MAAa,wBAAwB,aAA6B;AAChE,KAAI,aAAa,UACf,QAAO,QAAQ,IAAI,8BAA8B;AAGnD,KAAI,QAAQ,IAAI,2BACd,QAAO,QACL,QAAQ,IAAI,4BACZ,SAAS,QAAQ,WAAW,SAAS,CACtC;AAGH,QAAO"}
|
|
1
|
+
{"version":3,"file":"normalize-webpack-path.js","names":[],"sources":["../src/normalize-webpack-path.ts"],"sourcesContent":["import type webpack from 'webpack';\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, isAbsolute, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Webpack 5.112 reorganized internals without retaining every old location.\n// Keep the old layout preferred for older installations and patched copies.\nconst webpackInternalPaths: Record<string, string> = {\n 'webpack/lib/Module': 'webpack/lib/module/Module',\n 'webpack/lib/ModuleFactory': 'webpack/lib/module/ModuleFactory',\n 'webpack/lib/NormalModuleFactory': 'webpack/lib/module/NormalModuleFactory',\n 'webpack/lib/ExternalModule': 'webpack/lib/externals/ExternalModule',\n 'webpack/lib/RuntimeModule': 'webpack/lib/runtime/RuntimeModule',\n 'webpack/lib/RuntimeGlobals': 'webpack/lib/runtime/RuntimeGlobals',\n 'webpack/lib/RuntimeTemplate': 'webpack/lib/template/RuntimeTemplate',\n 'webpack/lib/ResolverFactory': 'webpack/lib/resolve/ResolverFactory',\n 'webpack/lib/ChunkGraph': 'webpack/lib/graph/ChunkGraph',\n 'webpack/lib/HotUpdateChunk': 'webpack/lib/graph/HotUpdateChunk',\n 'webpack/lib/dependencies/EntryDependency':\n 'webpack/lib/entry/EntryDependency',\n 'webpack/lib/dependencies/ModuleDependency':\n 'webpack/lib/dependencies/core/ModuleDependency',\n 'webpack/lib/dependencies/StaticExportsDependency':\n 'webpack/lib/dependencies/core/StaticExportsDependency',\n 'webpack/lib/util/extractUrlAndGlobal':\n 'webpack/lib/externals/extractUrlAndGlobal',\n 'webpack/lib/util/fs': 'webpack/lib/fs/fs',\n 'webpack/lib/util/semver': 'webpack/lib/sharing/semver',\n};\n\nlet webpackRequire: NodeRequire | undefined;\nconst callerWebpack = new Map<\n string,\n { request: NodeRequire; root: string | undefined }\n>();\n\nconst createSdkWebpackRequire = (): NodeRequire =>\n createRequire(\n // This entrypoint is emitted as both CJS and ESM.\n // @ts-ignore import.meta is used only in the ESM output.\n process.env.IS_ESM_BUILD === 'true' ? import.meta.url : __filename,\n );\n\nconst getWebpackRequire = (): {\n request: NodeRequire;\n root: string | undefined;\n} => {\n if (process.env['FEDERATION_WEBPACK_PATH']) {\n webpackRequire ??= createSdkWebpackRequire();\n return { request: webpackRequire, root: undefined };\n }\n\n // The SDK has no runtime webpack dependency. Use the calling package's resolver.\n const prepareStackTrace = Error.prepareStackTrace;\n const stackTraceLimit = Error.stackTraceLimit;\n try {\n Error.prepareStackTrace = (_error, callSites) => callSites;\n Error.stackTraceLimit = Math.max(stackTraceLimit ?? 0, 10);\n const error = new Error();\n Error.captureStackTrace(error, getWebpackRequire);\n const callSites = error.stack as unknown;\n const caller = (Array.isArray(callSites) ? callSites : [])\n .slice(1)\n .map((callSite: NodeJS.CallSite) => callSite.getFileName())\n .find(\n (fileName): fileName is string =>\n !!fileName && (isAbsolute(fileName) || fileName.startsWith('file:')),\n );\n const callerFile = caller?.startsWith('file:')\n ? fileURLToPath(caller)\n : caller || resolve(process.cwd(), 'package.json');\n const callerDir = dirname(callerFile);\n let located = callerWebpack.get(callerDir);\n if (!located) {\n const request = createRequire(callerFile);\n const webpackRoot = findWebpackRoot(request);\n located = {\n request,\n root: webpackRoot ? realpathSync(webpackRoot) + sep : undefined,\n };\n callerWebpack.set(callerDir, located);\n }\n return located;\n } finally {\n Error.prepareStackTrace = prepareStackTrace;\n Error.stackTraceLimit = stackTraceLimit;\n }\n};\n\nexport function getWebpackPath(\n compiler: webpack.Compiler,\n options: { framework: 'nextjs' | 'other' } = { framework: 'other' },\n): string {\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 if (!webpackPath) {\n return '';\n }\n try {\n const entry = createRequire(webpackPath).resolve('webpack');\n // A bundled compiler resolves to an unrelated installation, or to none.\n // Only report the package that contains the active compiler.\n return webpackPath.startsWith(resolve(entry, '../..') + sep) ? entry : '';\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') {\n throw error;\n }\n return '';\n }\n }\n}\n\nconst findWebpackRoot = (request: NodeRequire): string | undefined => {\n let entry: string;\n try {\n entry = request.resolve('webpack');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {\n return undefined;\n }\n throw error;\n }\n for (let dir = dirname(entry); dir !== dirname(dir); dir = dirname(dir)) {\n const manifest = join(dir, 'package.json');\n if (\n existsSync(manifest) &&\n JSON.parse(readFileSync(manifest, 'utf8')).name === 'webpack'\n ) {\n return dir;\n }\n }\n return undefined;\n};\n\nexport const normalizeWebpackPath = (fullPath: string): string => {\n if (fullPath === 'webpack') {\n return process.env['FEDERATION_WEBPACK_PATH'] || fullPath;\n }\n\n const normalize = (path: string): string =>\n process.env['FEDERATION_WEBPACK_PATH']\n ? resolve(\n process.env['FEDERATION_WEBPACK_PATH'],\n path.replace('webpack', '../../'),\n )\n : path;\n const candidate = normalize(fullPath);\n const relocatedPath = webpackInternalPaths[fullPath];\n if (!relocatedPath) {\n return candidate;\n }\n\n const { request: requestWebpack, root } = getWebpackRequire();\n const resolves = (request: string, inside?: string): boolean => {\n try {\n // Resolve candidates without executing them.\n const resolved = requestWebpack.resolve(request);\n return !inside || realpathSync(resolved).startsWith(inside);\n } catch (error) {\n const { code } = error as NodeJS.ErrnoException;\n if (\n code === 'MODULE_NOT_FOUND' ||\n (inside && code === 'ERR_PACKAGE_PATH_NOT_EXPORTED')\n ) {\n return false;\n }\n throw error;\n }\n };\n\n if (root) {\n // Bare requests can find an ancestor webpack's internals. Accept only\n // candidates inside the caller's webpack, including PnP and exports maps.\n if (resolves(fullPath, root)) return fullPath;\n if (resolves(relocatedPath, root)) return relocatedPath;\n }\n\n if (resolves(candidate)) {\n return candidate;\n }\n const fallback = normalize(relocatedPath);\n requestWebpack.resolve(fallback);\n return fallback;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/normalizeOptions.d.ts
|
|
2
|
+
declare function normalizeOptions<T>(enableDefault: boolean, defaultOptions: T, key: string): <U extends boolean | undefined | T>(options: U) => T | false;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { normalizeOptions };
|
|
5
|
+
//# sourceMappingURL=normalizeOptions.d.cts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/types/common.d.ts
|
|
2
|
+
interface RemoteWithEntry {
|
|
3
|
+
name: string;
|
|
4
|
+
entry: string;
|
|
5
|
+
}
|
|
6
|
+
interface RemoteWithVersion {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
}
|
|
10
|
+
type RemoteEntryInfo = RemoteWithEntry | RemoteWithVersion;
|
|
11
|
+
type Module = any;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion };
|
|
14
|
+
//# sourceMappingURL=common.d.cts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/types/hooks.d.ts
|
|
2
|
+
type CreateScriptHookReturnNode = {
|
|
3
|
+
url: string;
|
|
4
|
+
} | void;
|
|
5
|
+
type CreateScriptHookReturnDom = HTMLScriptElement | {
|
|
6
|
+
script?: HTMLScriptElement;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
} | void;
|
|
9
|
+
type CreateLinkHookReturnDom = HTMLLinkElement | {
|
|
10
|
+
link?: HTMLLinkElement;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
} | void;
|
|
13
|
+
type CreateScriptHookReturn = CreateScriptHookReturnNode | CreateScriptHookReturnDom;
|
|
14
|
+
type CreateScriptHookNode = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnNode;
|
|
15
|
+
type CreateScriptHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturnDom;
|
|
16
|
+
type CreateLinkHookDom = (url: string, attrs?: Record<string, any> | undefined) => CreateLinkHookReturnDom;
|
|
17
|
+
type CreateScriptHook = (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
18
|
+
type FetchHook = (args: [string, RequestInit]) => Promise<Response> | void | false;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook };
|
|
21
|
+
//# sourceMappingURL=hooks.d.cts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module, RemoteEntryInfo, RemoteWithEntry, RemoteWithVersion } from "./common.cjs";
|
|
2
|
+
import { BasicStatsMetaData, ManifestModuleInfos, MetaDataTypes, RemoteEntryType, ResourceInfo, Stats, StatsAssets, StatsBuildInfo, StatsExpose, StatsMetaData, StatsMetaDataWithGetPublicPath, StatsMetaDataWithPublicPath, StatsModuleInfo, StatsRemote, StatsRemoteVal, StatsRemoteWithEntry, StatsRemoteWithVersion, StatsShared } from "./stats.cjs";
|
|
3
|
+
import { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared } from "./manifest.cjs";
|
|
4
|
+
import { BasicProviderModuleInfo, ConsumerModuleInfo, ConsumerModuleInfoWithPublicPath, GlobalModuleInfo, ManifestProvider, ModuleInfo, ProviderModuleInfo, PureConsumerModuleInfo, PureEntryProvider } from "./snapshot.cjs";
|
|
5
|
+
import { ModuleFederationPlugin_d_exports } from "./plugins/ModuleFederationPlugin.cjs";
|
|
6
|
+
import { ContainerPlugin_d_exports } from "./plugins/ContainerPlugin.cjs";
|
|
7
|
+
import { ContainerReferencePlugin_d_exports } from "./plugins/ContainerReferencePlugin.cjs";
|
|
8
|
+
import { SharePlugin_d_exports } from "./plugins/SharePlugin.cjs";
|
|
9
|
+
import { ConsumeSharedPlugin_d_exports } from "./plugins/ConsumeSharedPlugin.cjs";
|
|
10
|
+
import { ProvideSharedPlugin_d_exports } from "./plugins/ProvideSharedPlugin.cjs";
|
|
11
|
+
import { CreateLinkHookDom, CreateLinkHookReturnDom, CreateScriptHook, CreateScriptHookDom, CreateScriptHookNode, CreateScriptHookReturn, CreateScriptHookReturnDom, CreateScriptHookReturnNode, FetchHook } from "./hooks.cjs";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RemoteWithEntry, RemoteWithVersion } from "./common.cjs";
|
|
2
|
+
import { BasicStatsMetaData, RemoteEntryType, StatsAssets, StatsExpose, StatsMetaData } from "./stats.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/types/manifest.d.ts
|
|
5
|
+
interface ManifestShared {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
singleton: boolean;
|
|
10
|
+
requiredVersion: string;
|
|
11
|
+
hash: string;
|
|
12
|
+
assets: StatsAssets;
|
|
13
|
+
fallback?: string;
|
|
14
|
+
fallbackName?: string;
|
|
15
|
+
fallbackType?: RemoteEntryType;
|
|
16
|
+
}
|
|
17
|
+
interface ManifestRemoteCommonInfo {
|
|
18
|
+
federationContainerName: string;
|
|
19
|
+
moduleName: string;
|
|
20
|
+
alias: string;
|
|
21
|
+
}
|
|
22
|
+
type ManifestRemote<T = ManifestRemoteCommonInfo> = (Omit<RemoteWithEntry, 'name'> & T) | (Omit<RemoteWithVersion, 'name'> & T);
|
|
23
|
+
type ManifestExpose = Pick<StatsExpose, 'assets' | 'id' | 'name' | 'path'>;
|
|
24
|
+
interface Manifest<T = BasicStatsMetaData, K = ManifestRemoteCommonInfo> {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
metaData: StatsMetaData<T>;
|
|
28
|
+
shared: ManifestShared[];
|
|
29
|
+
remotes: ManifestRemote<K>[];
|
|
30
|
+
exposes: ManifestExpose[];
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Manifest, ManifestExpose, ManifestRemote, ManifestRemoteCommonInfo, ManifestShared };
|
|
34
|
+
//# sourceMappingURL=manifest.d.cts.map
|