app-builder-lib 27.0.0-alpha.8 → 27.0.0-alpha.9
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/asar/asarUtil.js +21 -11
- package/dist/asar/asarUtil.js.map +1 -1
- package/dist/configuration.d.ts +31 -1
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/electron/ElectronFramework.d.ts +2 -1
- package/dist/electron/ElectronFramework.d.ts.map +1 -1
- package/dist/electron/ElectronFramework.js +14 -7
- package/dist/electron/ElectronFramework.js.map +1 -1
- package/dist/electron/mac/electronMac.js +2 -6
- package/dist/electron/mac/electronMac.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/indexInternal.d.ts +9 -2
- package/dist/indexInternal.d.ts.map +1 -1
- package/dist/indexInternal.js +8 -2
- package/dist/indexInternal.js.map +1 -1
- package/dist/linuxPackager.d.ts.map +1 -1
- package/dist/linuxPackager.js +19 -1
- package/dist/linuxPackager.js.map +1 -1
- package/dist/macPackager.d.ts.map +1 -1
- package/dist/macPackager.js +20 -0
- package/dist/macPackager.js.map +1 -1
- package/dist/node-module-collector/index.d.ts.map +1 -1
- package/dist/node-module-collector/index.js +47 -16
- package/dist/node-module-collector/index.js.map +1 -1
- package/dist/node-module-collector/moduleManager.d.ts.map +1 -1
- package/dist/node-module-collector/moduleManager.js +16 -8
- package/dist/node-module-collector/moduleManager.js.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.d.ts +7 -2
- package/dist/node-module-collector/nodeModulesCollector.d.ts.map +1 -1
- package/dist/node-module-collector/nodeModulesCollector.js +13 -17
- package/dist/node-module-collector/nodeModulesCollector.js.map +1 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts +44 -4
- package/dist/node-module-collector/pnpmNodeModulesCollector.d.ts.map +1 -1
- package/dist/node-module-collector/pnpmNodeModulesCollector.js +130 -34
- package/dist/node-module-collector/pnpmNodeModulesCollector.js.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.d.ts +29 -0
- package/dist/options/PlatformSpecificBuildOptions.d.ts.map +1 -1
- package/dist/options/PlatformSpecificBuildOptions.js.map +1 -1
- package/dist/options/SquirrelWindowsOptions.d.ts +0 -5
- package/dist/options/SquirrelWindowsOptions.d.ts.map +1 -1
- package/dist/options/SquirrelWindowsOptions.js.map +1 -1
- package/dist/options/macOptions.d.ts +11 -6
- package/dist/options/macOptions.d.ts.map +1 -1
- package/dist/options/macOptions.js.map +1 -1
- package/dist/packager.d.ts +2 -0
- package/dist/packager.d.ts.map +1 -1
- package/dist/packager.js +47 -0
- package/dist/packager.js.map +1 -1
- package/dist/packagerApi.d.ts +1 -1
- package/dist/packagerApi.d.ts.map +1 -1
- package/dist/packagerApi.js.map +1 -1
- package/dist/platformPackager.d.ts +13 -1
- package/dist/platformPackager.d.ts.map +1 -1
- package/dist/platformPackager.js +26 -2
- package/dist/platformPackager.js.map +1 -1
- package/dist/publish/PublishManager.d.ts.map +1 -1
- package/dist/publish/PublishManager.js +89 -7
- package/dist/publish/PublishManager.js.map +1 -1
- package/dist/publish/updateInfoBuilder.d.ts.map +1 -1
- package/dist/publish/updateInfoBuilder.js +57 -4
- package/dist/publish/updateInfoBuilder.js.map +1 -1
- package/dist/targets/ArchiveTarget.js +1 -1
- package/dist/targets/ArchiveTarget.js.map +1 -1
- package/dist/targets/archive.d.ts +12 -0
- package/dist/targets/archive.d.ts.map +1 -1
- package/dist/targets/archive.js +44 -1
- package/dist/targets/archive.js.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.d.ts +2 -1
- package/dist/targets/differentialUpdateInfoBuilder.d.ts.map +1 -1
- package/dist/targets/differentialUpdateInfoBuilder.js +2 -2
- package/dist/targets/differentialUpdateInfoBuilder.js.map +1 -1
- package/dist/targets/linux/FlatpakTarget.d.ts.map +1 -1
- package/dist/targets/linux/FlatpakTarget.js +5 -1
- package/dist/targets/linux/FlatpakTarget.js.map +1 -1
- package/dist/targets/linux/FpmTarget.d.ts.map +1 -1
- package/dist/targets/linux/FpmTarget.js +25 -2
- package/dist/targets/linux/FpmTarget.js.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.d.ts +1 -0
- package/dist/targets/linux/LinuxTargetHelper.d.ts.map +1 -1
- package/dist/targets/linux/LinuxTargetHelper.js +17 -1
- package/dist/targets/linux/LinuxTargetHelper.js.map +1 -1
- package/dist/targets/linux/snap/core24.js +3 -3
- package/dist/targets/linux/snap/core24.js.map +1 -1
- package/dist/targets/linux/snap/coreLegacy.js +1 -1
- package/dist/targets/linux/snap/coreLegacy.js.map +1 -1
- package/dist/targets/mac/MacTargetHelper.d.ts +70 -4
- package/dist/targets/mac/MacTargetHelper.d.ts.map +1 -1
- package/dist/targets/mac/MacTargetHelper.js +294 -36
- package/dist/targets/mac/MacTargetHelper.js.map +1 -1
- package/dist/targets/mac/pkg.d.ts +16 -0
- package/dist/targets/mac/pkg.d.ts.map +1 -1
- package/dist/targets/mac/pkg.js +26 -0
- package/dist/targets/mac/pkg.js.map +1 -1
- package/dist/targets/win/MsiTarget.d.ts.map +1 -1
- package/dist/targets/win/MsiTarget.js +6 -3
- package/dist/targets/win/MsiTarget.js.map +1 -1
- package/dist/targets/win/nsis/Defines.d.ts +2 -0
- package/dist/targets/win/nsis/Defines.d.ts.map +1 -1
- package/dist/targets/win/nsis/Defines.js.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.d.ts +18 -0
- package/dist/targets/win/nsis/NsisTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/NsisTarget.js +79 -19
- package/dist/targets/win/nsis/NsisTarget.js.map +1 -1
- package/dist/targets/win/nsis/WebInstallerTarget.d.ts.map +1 -1
- package/dist/targets/win/nsis/WebInstallerTarget.js +19 -12
- package/dist/targets/win/nsis/WebInstallerTarget.js.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.d.ts +29 -4
- package/dist/targets/win/nsis/nsisOptions.d.ts.map +1 -1
- package/dist/targets/win/nsis/nsisOptions.js.map +1 -1
- package/dist/toolsets/wine.d.ts.map +1 -1
- package/dist/toolsets/wine.js +17 -12
- package/dist/toolsets/wine.js.map +1 -1
- package/dist/util/NodeModuleCopyHelper.js +12 -4
- package/dist/util/NodeModuleCopyHelper.js.map +1 -1
- package/dist/util/appFileCopier.d.ts +5 -0
- package/dist/util/appFileCopier.d.ts.map +1 -1
- package/dist/util/appFileCopier.js +39 -1
- package/dist/util/appFileCopier.js.map +1 -1
- package/dist/util/config/config.d.ts.map +1 -1
- package/dist/util/config/config.js +4 -0
- package/dist/util/config/config.js.map +1 -1
- package/dist/util/config/legacyConfigGuard.d.ts +7 -0
- package/dist/util/config/legacyConfigGuard.d.ts.map +1 -0
- package/dist/util/config/legacyConfigGuard.js +187 -0
- package/dist/util/config/legacyConfigGuard.js.map +1 -0
- package/dist/util/config/legacyOptions.d.ts +73 -0
- package/dist/util/config/legacyOptions.d.ts.map +1 -0
- package/dist/util/config/legacyOptions.js +369 -0
- package/dist/util/config/legacyOptions.js.map +1 -0
- package/dist/util/config/schemaValidator.d.ts.map +1 -1
- package/dist/util/config/schemaValidator.js +16 -0
- package/dist/util/config/schemaValidator.js.map +1 -1
- package/dist/util/electronGet.d.ts +0 -4
- package/dist/util/electronGet.d.ts.map +1 -1
- package/dist/util/electronGet.js +17 -0
- package/dist/util/electronGet.js.map +1 -1
- package/dist/util/flags.d.ts +5 -0
- package/dist/util/flags.d.ts.map +1 -1
- package/dist/util/flags.js +124 -1
- package/dist/util/flags.js.map +1 -1
- package/dist/util/packageMetadata.js +11 -0
- package/dist/util/packageMetadata.js.map +1 -1
- package/dist/util/resolve.js +1 -1
- package/dist/util/resolve.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +10 -10
- package/scheme.json +368 -23
- package/templates/entitlements.mac.adhoc.plist +15 -0
- package/templates/entitlements.mac.plist +9 -6
- package/templates/nsis/include/installer.nsh +1 -30
- package/templates/nsis/include/webPackage.nsh +33 -23
- package/templates/nsis/multiUserUi.nsh +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleManager.js","sourceRoot":"","sources":["../../src/node-module-collector/moduleManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAY,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,sGAAsG;AACtG,uGAAuG;AACvG,gHAAgH;AAChH,MAAM,UAAU,cAAc,CAAU,IAAY;IAClD,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,CAAN,IAAY,eAYX;AAZD,WAAY,eAAe;IACzB,wEAAqD,CAAA;IACrD,8FAA2E,CAAA;IAC3E,oEAAiD,CAAA;IACjD,mEAAgD,CAAA;IAChD,iEAA8C,CAAA;IAC9C,+EAA4D,CAAA;IAC5D,6PAAqO,CAAA;IACrO,mEAAgD,CAAA;IAChD,6LAAqK,CAAA;IACrK,8JAA2I,CAAA;IAC3I,4IAAyH,CAAA;AAC3H,CAAC,EAZW,eAAe,KAAf,eAAe,QAY1B;AACD,MAAM,CAAC,MAAM,oBAAoB,GAAsC;IACrE,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,MAAM;IAC3C,CAAC,eAAe,CAAC,4BAA4B,CAAC,EAAE,MAAM;IACtD,CAAC,eAAe,CAAC,aAAa,CAAC,EAAE,MAAM;IACvC,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,MAAM;IACzC,CAAC,eAAe,CAAC,YAAY,CAAC,EAAE,OAAO;IACvC,CAAC,eAAe,CAAC,0BAA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fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\n\n// Tolerant package.json read for the node-module collectors: swallows ALL errors (not just ENOENT) to\n// null, since the collectors intentionally skip unreadable entries (e.g. cross-drive Windows junctions\n// whose failures are not ENOENT). Distinct from builder-util's orNullIfFileNotExist, which rethrows non-ENOENT.\nexport function readJsonOrNull<T = any>(file: string): Promise<T | null> {\n return fs.readJson(file).catch(() => null)\n}\n\nexport enum LogMessageByKey {\n PKG_DUPLICATE_REF = \"duplicate dependency references\",\n PKG_DUPLICATE_REF_UNRESOLVED = \"unresolved duplicate dependency references\",\n PKG_NOT_FOUND = \"cannot find path for dependency\",\n PKG_NOT_ON_DISK = \"dependency not found on disk\",\n PKG_SELF_REF = \"self-referential dependencies\",\n PKG_OPTIONAL_NOT_INSTALLED = \"missing optional dependencies\",\n PKG_OPTIONAL_PLATFORM_NOT_INSTALLED = \"platform-specific optional dependencies not bundled — add them to your project's optionalDependencies if your app requires them (pnpm 10+ does not auto-install transitive platform binaries)\",\n PKG_COLLECTOR_OUTPUT = \"collector stderr output\",\n PKG_VERSION_OVERRIDDEN = \"dependencies resolved to a version outside the declared range (installed version accepted — likely resolved via package manager overrides)\",\n PKG_INCOMPATIBLE_PLATFORM = \"excluded platform-incompatible dependencies (package.json `cpu`/`os` does not match the target arch/platform)\",\n PKG_EXCLUDED_IGNORED = \"excluded production dependencies from the app's node_modules (see ignoredProductionDependencies)\",\n}\nexport const logMessageLevelByKey: Record<LogMessageByKey, LogLevel> = {\n [LogMessageByKey.PKG_DUPLICATE_REF]: \"info\",\n [LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED]: \"warn\",\n [LogMessageByKey.PKG_NOT_FOUND]: \"warn\",\n [LogMessageByKey.PKG_NOT_ON_DISK]: \"warn\",\n [LogMessageByKey.PKG_SELF_REF]: \"debug\",\n [LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED]: \"info\",\n [LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED]: \"warn\",\n [LogMessageByKey.PKG_COLLECTOR_OUTPUT]: \"warn\",\n [LogMessageByKey.PKG_VERSION_OVERRIDDEN]: \"debug\",\n [LogMessageByKey.PKG_INCOMPATIBLE_PLATFORM]: \"info\",\n [LogMessageByKey.PKG_EXCLUDED_IGNORED]: \"info\",\n}\n\nexport type Package = { packageDir: string; packageJson: PackageJson }\n\n// Type aliases for clarity\ntype JsonCache = Record<string, Promise<PackageJson | null>>\ntype RealPathCache = Record<string, Promise<string>>\ntype ExistsCache = Record<string, Promise<boolean>>\ntype LstatCache = Record<string, Promise<fs.Stats | null>>\ntype PackageCache = Record<string, Promise<Package | null>>\ntype LogSummaryCache = Record<LogMessageByKey, string[]>\n\nexport class ModuleManager {\n /** Cache for package.json contents (readJson) */\n readonly json: JsonCache\n /** Cache for resolved real paths (if symlink, realpath; otherwise resolve) */\n readonly realPath: RealPathCache\n /** Cache for file/directory existence checks */\n readonly exists: ExistsCache\n /** Cache for lstat results */\n readonly lstat: LstatCache\n /** Cache for package lookups (key: \"packageName||fromDir||semverRange\"). Use helper function `versionedCacheKey` */\n readonly packageData: PackageCache\n /** For logging purposes, just track all dependencies for each key */\n readonly logSummary: LogSummaryCache\n\n private readonly jsonMap: Map<string, PackageJson | null> = new Map()\n private readonly realPathMap: Map<string, string> = new Map()\n private readonly existsMap: Map<string, boolean> = new Map()\n private readonly lstatMap: Map<string, fs.Stats | null> = new Map()\n private readonly packageDataMap: Map<string, Package | null> = new Map()\n private readonly logSummaryMap: Map<LogMessageByKey, string[]> = new Map()\n\n constructor() {\n this.logSummary = this.createLogSummarySyncProxy()\n\n this.exists = this.createAsyncProxy(this.existsMap, (p: string) => exists(p))\n this.json = this.createAsyncProxy(this.jsonMap, (p: string) => readJsonOrNull(p))\n this.lstat = this.createAsyncProxy(this.lstatMap, (p: string) => fs.lstat(p).catch(() => null))\n this.packageData = this.createAsyncProxy(this.packageDataMap, (p: string) => this.locatePackageVersionFromCacheKey(p).catch(() => null))\n this.realPath = this.createAsyncProxy(this.realPathMap, async (p: string) => {\n const filePath = path.resolve(p)\n const stat = await this.lstat[filePath]\n return stat?.isSymbolicLink() ? fs.realpath(filePath) : filePath\n })\n }\n\n private createLogSummarySyncProxy(): LogSummaryCache {\n return new Proxy({} as LogSummaryCache, {\n get: (_, key: LogMessageByKey) => {\n if (!this.logSummaryMap.has(key)) {\n this.logSummaryMap.set(key, [])\n }\n return this.logSummaryMap.get(key)!\n },\n set: (_, key: LogMessageByKey, value: string[]) => {\n this.logSummaryMap.set(key, value)\n return true\n },\n has: (_, key: LogMessageByKey) => {\n return this.logSummaryMap.has(key)\n },\n // Add these to make Object.entries() work\n ownKeys: _ => {\n return Array.from(this.logSummaryMap.keys())\n },\n getOwnPropertyDescriptor: (_, key) => {\n if (this.logSummaryMap.has(key as LogMessageByKey)) {\n return {\n enumerable: true,\n configurable: true,\n }\n }\n return undefined\n },\n })\n }\n\n // this allows dot-notation access while still supporting async retrieval\n // e.g., cache.packageJson[somePath] returns Promise<PackageJson>\n private createAsyncProxy<T>(map: Map<string, T>, compute: (key: string) => T | Promise<T>): Record<string, Promise<T>> {\n return new Proxy({} as Record<string, Promise<T>>, {\n async get(_, key: string) {\n if (map.has(key)) {\n return Promise.resolve(map.get(key)!)\n }\n return await Promise.resolve(compute(key)).then(value => {\n map.set(key, value)\n return value\n })\n },\n set(_, key: string, value: T) {\n map.set(key, value)\n return true\n },\n has(_, key: string) {\n return map.has(key)\n },\n })\n }\n\n versionedCacheKey(pkg: { name: string; path: string; semver?: string }): string {\n return [pkg.name, pkg.path, pkg.semver || \"\"].join(\"||\")\n }\n\n protected async locatePackageVersionFromCacheKey(key: string): Promise<Package | null> {\n const [name, fromDir, semverRange] = key.split(\"||\")\n const result = await this.locatePackageVersion({ parentDir: fromDir, pkgName: name, requiredRange: semverRange })\n if (result == null) {\n return null\n }\n return { ...result, packageDir: await this.realPath[result.packageDir] }\n }\n\n public async locatePackageVersion({\n parentDir,\n pkgName,\n requiredRange,\n skipDownwardSearch = false,\n skipOverrideFallback = false,\n }: {\n /**\n * The directory to start searching from. Typed optional because pnpm JSON output can omit\n * the `path` field at runtime even when the TypeScript type says `string`. An undefined\n * parentDir is treated as \"package not found\" rather than a crash.\n */\n parentDir?: string\n /**\n * The package name to locate. Typed optional for the same reason as parentDir: the pnpm\n * list JSON can omit `name`/`from` fields (e.g. when the root package.json has no name),\n * producing an undefined pkgName at runtime despite the TypeScript type.\n */\n pkgName?: string\n requiredRange?: string\n /**\n * When true, skip the BFS-based `downwardSearch`. Use for layouts that are guaranteed flat\n * (e.g. pnpm's `.pnpm` virtual store), where the downward walk burns thousands of `readdir`\n * / `lstat` calls and finds nothing.\n */\n skipDownwardSearch?: boolean\n /**\n * When true, return null instead of falling back to an out-of-range (override) version.\n * Callers that search several locations use this to find a range-satisfying version in any\n * location before settling for an override version from the first location searched.\n */\n skipOverrideFallback?: boolean\n }): Promise<Package | null> {\n if (!parentDir || !pkgName) {\n return null\n }\n\n const found = await this.searchForPackage(parentDir, pkgName, requiredRange, skipDownwardSearch)\n if (found) {\n return found\n }\n\n // Second pass: find any installed version of the package when the declared-range search\n // returns nothing. This handles package manager `overrides` (Bun, npm, pnpm, Yarn) that\n // resolve a transitive dependency to a version intentionally outside its declared range.\n // File-system results are already cached, so this pass costs only JS overhead.\n if (requiredRange && !skipOverrideFallback) {\n const overrideResult = await this.searchForPackage(parentDir, pkgName, undefined, skipDownwardSearch)\n if (overrideResult) {\n log.debug(\n { pkg: pkgName, declared: requiredRange, installed: overrideResult.packageJson.version },\n \"accepting installed package version that doesn't satisfy the declared range\"\n )\n this.logSummary[LogMessageByKey.PKG_VERSION_OVERRIDDEN].push(`${pkgName}@${overrideResult.packageJson.version} (declared ${requiredRange})`)\n return overrideResult\n }\n }\n\n return null\n }\n\n private async searchForPackage(parentDir: string, pkgName: string, requiredRange: string | undefined, skipDownwardSearch: boolean): Promise<Package | null> {\n // 1) check direct parent node_modules/pkgName first\n const direct = path.join(path.resolve(parentDir), \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n // 2) upward hoisted search, then 3) downward non-hoisted search\n const upward = await this.upwardSearch(parentDir, pkgName, requiredRange)\n if (upward) {\n return upward\n }\n if (skipDownwardSearch) {\n return null\n }\n return (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null\n }\n\n private semverSatisfies(found: string, range?: string): boolean {\n if (isEmptyOrSpaces(range) || range === \"*\") {\n return true\n }\n\n if (range === found) {\n return true\n }\n\n if (semver.validRange(range) == null) {\n // ignore, we can't verify non-semver ranges\n // e.g. git urls, file:, patch:, etc. Example:\n // \"@ai-sdk/google\": \"patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch\"\n log.debug({ found, range }, \"unable to validate semver version range, assuming match\")\n return true\n }\n\n try {\n return semver.satisfies(found, range)\n } catch {\n // fallback: simple equality or basic prefix handling (^, ~)\n if (range.startsWith(\"^\") || range.startsWith(\"~\")) {\n const r = range.slice(1)\n return r === found\n }\n // if range is like \"8.x\" or \"8.*\" match major\n const m = range.match(/^(\\d+)[.(*|x)]*/)\n const fm = found.match(/^(\\d+)\\./)\n if (m && fm) {\n return m[1] === fm[1]\n }\n return false\n }\n }\n\n /**\n * Upward search (hoisted)\n */\n private async upwardSearch(parentDir: string, pkgName: string, requiredRange?: string): Promise<Package | null> {\n let current = path.resolve(parentDir)\n const root = path.parse(current).root\n while (true) {\n const candidate = path.join(current, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidate]) {\n const json = await this.json[candidate]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidate), packageJson: json }\n }\n // otherwise keep searching upward (we may find a different hoisted version)\n }\n if (current === root) {\n break\n }\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n return null\n }\n\n /**\n * Breadth-first downward search from parentDir/node_modules\n * Looks for node_modules/\\*\\/node_modules/pkgName (and deeper)\n */\n private async downwardSearch(parentDir: string, pkgName: string, requiredRange?: string, maxExplored = 2000, maxDepth = 6): Promise<Package | null> {\n const start = path.join(path.resolve(parentDir), \"node_modules\")\n if (!(await this.exists[start]) || !(await this.lstat[start])?.isDirectory()) {\n return null\n }\n\n const visited = new Set<string>()\n const queue: Array<{ dir: string; depth: number }> = [{ dir: start, depth: 0 }]\n let explored = 0\n\n while (queue.length > 0) {\n const { dir, depth } = queue.shift()!\n if (explored++ > maxExplored) {\n break\n }\n if (depth > maxDepth) {\n continue\n }\n let entries: string[]\n try {\n entries = await fs.readdir(dir)\n } catch {\n continue\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) {\n continue\n }\n const entryPath = path.join(dir, entry)\n if (entry.startsWith(\"@\")) {\n const found = await this.processScope(entryPath, pkgName, requiredRange, depth, visited, queue)\n if (found) {\n return found\n }\n continue\n }\n const found = await this.processEntry(entryPath, pkgName, requiredRange, depth, visited, queue)\n if (found) {\n return found\n }\n }\n }\n\n return null\n }\n\n /** Handle a non-scoped entry directory inside a node_modules folder. */\n private async processEntry(\n entryPath: string,\n pkgName: string,\n requiredRange: string | undefined,\n depth: number,\n visited: Set<string>,\n queue: Array<{ dir: string; depth: number }>\n ): Promise<Package | null> {\n const stat = await this.lstat[entryPath]\n if (!stat?.isDirectory()) {\n return null\n }\n\n // Check entry/node_modules/pkgName (nested dep under a package)\n const nested = path.join(entryPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[nested]) {\n const json = await this.json[nested]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(nested), packageJson: json }\n }\n }\n\n // Check entry/pkgName directly (some flat layouts place pkgName as a sibling)\n const direct = path.join(entryPath, pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n await this.enqueueIfExists(path.join(entryPath, \"node_modules\"), depth, visited, queue)\n return null\n }\n\n /** Handle a scoped-package directory (@scope) inside a node_modules folder. */\n private async processScope(\n scopePath: string,\n pkgName: string,\n requiredRange: string | undefined,\n depth: number,\n visited: Set<string>,\n queue: Array<{ dir: string; depth: number }>\n ): Promise<Package | null> {\n if (!(await this.exists[scopePath]) || !(await this.lstat[scopePath])?.isDirectory()) {\n return null\n }\n let scopeEntries: string[]\n try {\n scopeEntries = await fs.readdir(scopePath)\n } catch {\n return null\n }\n for (const sc of scopeEntries) {\n const scPath = path.join(scopePath, sc)\n const candidatePkgJson = path.join(scPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n await this.enqueueIfExists(path.join(scPath, \"node_modules\"), depth, visited, queue)\n }\n return null\n }\n\n /** Enqueue a node_modules directory for BFS only if it exists on disk and hasn't been visited. */\n private async enqueueIfExists(nmPath: string, depth: number, visited: Set<string>, queue: Array<{ dir: string; depth: number }>): Promise<void> {\n if (!visited.has(nmPath) && (await this.exists[nmPath]) && (await this.lstat[nmPath])?.isDirectory()) {\n visited.add(nmPath)\n queue.push({ dir: nmPath, depth: depth + 1 })\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"moduleManager.js","sourceRoot":"","sources":["../../src/node-module-collector/moduleManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAY,MAAM,cAAc,CAAA;AAErE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,sGAAsG;AACtG,uGAAuG;AACvG,gHAAgH;AAChH,MAAM,UAAU,cA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,CAAC,CAAA;gBAC9C,IAAI,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,CAAC;oBAC9D,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;gBAC1E,CAAC;YACH,CAAC;YACD,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;QACtF,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,kGAAkG;IAC1F,KAAK,CAAC,eAAe,CAAC,MAAc,EAAE,KAAa,EAAE,OAAoB,EAAE,KAA4C;QAC7H,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;YACrG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACnB,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;CACF","sourcesContent":["import { exists, isEmptyOrSpaces, log, LogLevel } from \"builder-util\"\nimport { PackageJson } from \"./types.js\"\nimport fs from \"fs-extra\"\nimport * as path from \"path\"\nimport * as semver from \"semver\"\n\n// Tolerant package.json read for the node-module collectors: swallows ALL errors (not just ENOENT) to\n// null, since the collectors intentionally skip unreadable entries (e.g. cross-drive Windows junctions\n// whose failures are not ENOENT). Distinct from builder-util's orNullIfFileNotExist, which rethrows non-ENOENT.\nexport function readJsonOrNull<T = any>(file: string): Promise<T | null> {\n return fs.readJson(file).catch(() => null)\n}\n\nexport enum LogMessageByKey {\n PKG_DUPLICATE_REF = \"duplicate dependency references\",\n PKG_DUPLICATE_REF_UNRESOLVED = \"unresolved duplicate dependency references\",\n PKG_NOT_FOUND = \"cannot find path for dependency\",\n PKG_NOT_ON_DISK = \"dependency not found on disk\",\n PKG_SELF_REF = \"self-referential dependencies\",\n PKG_OPTIONAL_NOT_INSTALLED = \"missing optional dependencies\",\n PKG_OPTIONAL_PLATFORM_NOT_INSTALLED = \"platform-specific optional dependencies not bundled — add them to your project's optionalDependencies if your app requires them (pnpm 10+ does not auto-install transitive platform binaries)\",\n PKG_COLLECTOR_OUTPUT = \"collector stderr output\",\n PKG_VERSION_OVERRIDDEN = \"dependencies resolved to a version outside the declared range (installed version accepted — likely resolved via package manager overrides)\",\n PKG_INCOMPATIBLE_PLATFORM = \"excluded platform-incompatible dependencies (package.json `cpu`/`os` does not match the target arch/platform)\",\n PKG_EXCLUDED_IGNORED = \"excluded production dependencies from the app's node_modules (see ignoredProductionDependencies)\",\n}\nexport const logMessageLevelByKey: Record<LogMessageByKey, LogLevel> = {\n [LogMessageByKey.PKG_DUPLICATE_REF]: \"info\",\n [LogMessageByKey.PKG_DUPLICATE_REF_UNRESOLVED]: \"warn\",\n [LogMessageByKey.PKG_NOT_FOUND]: \"warn\",\n [LogMessageByKey.PKG_NOT_ON_DISK]: \"warn\",\n [LogMessageByKey.PKG_SELF_REF]: \"debug\",\n [LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED]: \"info\",\n [LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED]: \"warn\",\n [LogMessageByKey.PKG_COLLECTOR_OUTPUT]: \"warn\",\n [LogMessageByKey.PKG_VERSION_OVERRIDDEN]: \"debug\",\n [LogMessageByKey.PKG_INCOMPATIBLE_PLATFORM]: \"info\",\n [LogMessageByKey.PKG_EXCLUDED_IGNORED]: \"info\",\n}\n\nexport type Package = { packageDir: string; packageJson: PackageJson }\n\n// Type aliases for clarity\ntype JsonCache = Record<string, Promise<PackageJson | null>>\ntype RealPathCache = Record<string, Promise<string>>\ntype ExistsCache = Record<string, Promise<boolean>>\ntype LstatCache = Record<string, Promise<fs.Stats | null>>\ntype PackageCache = Record<string, Promise<Package | null>>\ntype LogSummaryCache = Record<LogMessageByKey, string[]>\n\nexport class ModuleManager {\n /** Cache for package.json contents (readJson) */\n readonly json: JsonCache\n /** Cache for resolved real paths (if symlink, realpath; otherwise resolve) */\n readonly realPath: RealPathCache\n /** Cache for file/directory existence checks */\n readonly exists: ExistsCache\n /** Cache for lstat results */\n readonly lstat: LstatCache\n /** Cache for package lookups (key: \"packageName||fromDir||semverRange\"). Use helper function `versionedCacheKey` */\n readonly packageData: PackageCache\n /** For logging purposes, just track all dependencies for each key */\n readonly logSummary: LogSummaryCache\n\n private readonly jsonMap = new Map<string, Promise<PackageJson | null>>()\n private readonly realPathMap = new Map<string, Promise<string>>()\n private readonly existsMap = new Map<string, Promise<boolean>>()\n private readonly lstatMap = new Map<string, Promise<fs.Stats | null>>()\n private readonly packageDataMap = new Map<string, Promise<Package | null>>()\n private readonly logSummaryMap: Map<LogMessageByKey, string[]> = new Map()\n\n constructor() {\n this.logSummary = this.createLogSummarySyncProxy()\n\n this.exists = this.createAsyncProxy(this.existsMap, (p: string) => exists(p))\n this.json = this.createAsyncProxy(this.jsonMap, (p: string) => readJsonOrNull(p))\n this.lstat = this.createAsyncProxy(this.lstatMap, (p: string) => fs.lstat(p).catch(() => null))\n this.packageData = this.createAsyncProxy(this.packageDataMap, (p: string) => this.locatePackageVersionFromCacheKey(p).catch(() => null))\n this.realPath = this.createAsyncProxy(this.realPathMap, async (p: string) => {\n const filePath = path.resolve(p)\n const stat = await this.lstat[filePath]\n // A dangling link, or a Windows junction pointing at another drive, makes `realpath` throw.\n // Degrading to the path we were given keeps collection going with the next-best answer\n // instead of failing the whole build.\n return stat?.isSymbolicLink() ? fs.realpath(filePath).catch(() => filePath) : filePath\n })\n }\n\n private createLogSummarySyncProxy(): LogSummaryCache {\n return new Proxy({} as LogSummaryCache, {\n get: (_, key: LogMessageByKey) => {\n if (!this.logSummaryMap.has(key)) {\n this.logSummaryMap.set(key, [])\n }\n return this.logSummaryMap.get(key)!\n },\n set: (_, key: LogMessageByKey, value: string[]) => {\n this.logSummaryMap.set(key, value)\n return true\n },\n has: (_, key: LogMessageByKey) => {\n return this.logSummaryMap.has(key)\n },\n // Add these to make Object.entries() work\n ownKeys: _ => {\n return Array.from(this.logSummaryMap.keys())\n },\n getOwnPropertyDescriptor: (_, key) => {\n if (this.logSummaryMap.has(key as LogMessageByKey)) {\n return {\n enumerable: true,\n configurable: true,\n }\n }\n return undefined\n },\n })\n }\n\n // this allows dot-notation access while still supporting async retrieval\n // e.g., cache.packageJson[somePath] returns Promise<PackageJson>\n private createAsyncProxy<T>(map: Map<string, Promise<T>>, compute: (key: string) => T | Promise<T>): Record<string, Promise<T>> {\n return new Proxy({} as Record<string, Promise<T>>, {\n get(_, key: string) {\n const cached = map.get(key)\n if (cached != null) {\n return cached\n }\n const pending = Promise.resolve()\n .then(() => compute(key))\n .catch(error => {\n map.delete(key)\n throw error\n })\n map.set(key, pending)\n return pending\n },\n set(_, key: string, value: T) {\n map.set(key, Promise.resolve(value))\n return true\n },\n has(_, key: string) {\n return map.has(key)\n },\n })\n }\n\n versionedCacheKey(pkg: { name: string; path: string; semver?: string }): string {\n return [pkg.name, pkg.path, pkg.semver || \"\"].join(\"||\")\n }\n\n protected async locatePackageVersionFromCacheKey(key: string): Promise<Package | null> {\n const [name, fromDir, semverRange] = key.split(\"||\")\n const result = await this.locatePackageVersion({ parentDir: fromDir, pkgName: name, requiredRange: semverRange })\n if (result == null) {\n return null\n }\n return { ...result, packageDir: await this.realPath[result.packageDir] }\n }\n\n public async locatePackageVersion({\n parentDir,\n pkgName,\n requiredRange,\n skipDownwardSearch = false,\n skipOverrideFallback = false,\n }: {\n /**\n * The directory to start searching from. Typed optional because pnpm JSON output can omit\n * the `path` field at runtime even when the TypeScript type says `string`. An undefined\n * parentDir is treated as \"package not found\" rather than a crash.\n */\n parentDir?: string\n /**\n * The package name to locate. Typed optional for the same reason as parentDir: the pnpm\n * list JSON can omit `name`/`from` fields (e.g. when the root package.json has no name),\n * producing an undefined pkgName at runtime despite the TypeScript type.\n */\n pkgName?: string\n requiredRange?: string\n /**\n * When true, skip the BFS-based `downwardSearch`. Use for layouts that are guaranteed flat\n * (e.g. pnpm's `.pnpm` virtual store), where the downward walk burns thousands of `readdir`\n * / `lstat` calls and finds nothing.\n */\n skipDownwardSearch?: boolean\n /**\n * When true, return null instead of falling back to an out-of-range (override) version.\n * Callers that search several locations use this to find a range-satisfying version in any\n * location before settling for an override version from the first location searched.\n */\n skipOverrideFallback?: boolean\n }): Promise<Package | null> {\n if (!parentDir || !pkgName) {\n return null\n }\n\n const found = await this.searchForPackage(parentDir, pkgName, requiredRange, skipDownwardSearch)\n if (found) {\n return found\n }\n\n // Second pass: find any installed version of the package when the declared-range search\n // returns nothing. This handles package manager `overrides` (Bun, npm, pnpm, Yarn) that\n // resolve a transitive dependency to a version intentionally outside its declared range.\n // File-system results are already cached, so this pass costs only JS overhead.\n if (requiredRange && !skipOverrideFallback) {\n const overrideResult = await this.searchForPackage(parentDir, pkgName, undefined, skipDownwardSearch)\n if (overrideResult) {\n log.debug(\n { pkg: pkgName, declared: requiredRange, installed: overrideResult.packageJson.version },\n \"accepting installed package version that doesn't satisfy the declared range\"\n )\n this.logSummary[LogMessageByKey.PKG_VERSION_OVERRIDDEN].push(`${pkgName}@${overrideResult.packageJson.version} (declared ${requiredRange})`)\n return overrideResult\n }\n }\n\n return null\n }\n\n private async searchForPackage(parentDir: string, pkgName: string, requiredRange: string | undefined, skipDownwardSearch: boolean): Promise<Package | null> {\n // 1) check direct parent node_modules/pkgName first\n const direct = path.join(path.resolve(parentDir), \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n // 2) upward hoisted search, then 3) downward non-hoisted search\n const upward = await this.upwardSearch(parentDir, pkgName, requiredRange)\n if (upward) {\n return upward\n }\n if (skipDownwardSearch) {\n return null\n }\n return (await this.downwardSearch(parentDir, pkgName, requiredRange)) || null\n }\n\n private semverSatisfies(found: string, range?: string): boolean {\n if (isEmptyOrSpaces(range) || range === \"*\") {\n return true\n }\n\n if (range === found) {\n return true\n }\n\n if (semver.validRange(range) == null) {\n // ignore, we can't verify non-semver ranges\n // e.g. git urls, file:, patch:, etc. Example:\n // \"@ai-sdk/google\": \"patch:@ai-sdk/google@npm%3A2.0.43#~/.yarn/patches/@ai-sdk-google-npm-2.0.43-689ed559b3.patch\"\n log.debug({ found, range }, \"unable to validate semver version range, assuming match\")\n return true\n }\n\n try {\n return semver.satisfies(found, range)\n } catch {\n // fallback: simple equality or basic prefix handling (^, ~)\n if (range.startsWith(\"^\") || range.startsWith(\"~\")) {\n const r = range.slice(1)\n return r === found\n }\n // if range is like \"8.x\" or \"8.*\" match major\n const m = range.match(/^(\\d+)[.(*|x)]*/)\n const fm = found.match(/^(\\d+)\\./)\n if (m && fm) {\n return m[1] === fm[1]\n }\n return false\n }\n }\n\n /**\n * Upward search (hoisted)\n */\n private async upwardSearch(parentDir: string, pkgName: string, requiredRange?: string): Promise<Package | null> {\n let current = path.resolve(parentDir)\n const root = path.parse(current).root\n while (true) {\n const candidate = path.join(current, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidate]) {\n const json = await this.json[candidate]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidate), packageJson: json }\n }\n // otherwise keep searching upward (we may find a different hoisted version)\n }\n if (current === root) {\n break\n }\n const parent = path.dirname(current)\n if (parent === current) {\n break\n }\n current = parent\n }\n return null\n }\n\n /**\n * Breadth-first downward search from parentDir/node_modules\n * Looks for node_modules/\\*\\/node_modules/pkgName (and deeper)\n */\n private async downwardSearch(parentDir: string, pkgName: string, requiredRange?: string, maxExplored = 2000, maxDepth = 6): Promise<Package | null> {\n const start = path.join(path.resolve(parentDir), \"node_modules\")\n if (!(await this.exists[start]) || !(await this.lstat[start])?.isDirectory()) {\n return null\n }\n\n const visited = new Set<string>()\n const queue: Array<{ dir: string; depth: number }> = [{ dir: start, depth: 0 }]\n let explored = 0\n\n while (queue.length > 0) {\n const { dir, depth } = queue.shift()!\n if (explored++ > maxExplored) {\n break\n }\n if (depth > maxDepth) {\n continue\n }\n let entries: string[]\n try {\n entries = await fs.readdir(dir)\n } catch {\n continue\n }\n for (const entry of entries) {\n if (entry.startsWith(\".\")) {\n continue\n }\n const entryPath = path.join(dir, entry)\n if (entry.startsWith(\"@\")) {\n const found = await this.processScope(entryPath, pkgName, requiredRange, depth, visited, queue)\n if (found) {\n return found\n }\n continue\n }\n const found = await this.processEntry(entryPath, pkgName, requiredRange, depth, visited, queue)\n if (found) {\n return found\n }\n }\n }\n\n return null\n }\n\n /** Handle a non-scoped entry directory inside a node_modules folder. */\n private async processEntry(\n entryPath: string,\n pkgName: string,\n requiredRange: string | undefined,\n depth: number,\n visited: Set<string>,\n queue: Array<{ dir: string; depth: number }>\n ): Promise<Package | null> {\n const stat = await this.lstat[entryPath]\n if (!stat?.isDirectory()) {\n return null\n }\n\n // Check entry/node_modules/pkgName (nested dep under a package)\n const nested = path.join(entryPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[nested]) {\n const json = await this.json[nested]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(nested), packageJson: json }\n }\n }\n\n // Check entry/pkgName directly (some flat layouts place pkgName as a sibling)\n const direct = path.join(entryPath, pkgName, \"package.json\")\n if (await this.exists[direct]) {\n const json = await this.json[direct]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(direct), packageJson: json }\n }\n }\n\n await this.enqueueIfExists(path.join(entryPath, \"node_modules\"), depth, visited, queue)\n return null\n }\n\n /** Handle a scoped-package directory (@scope) inside a node_modules folder. */\n private async processScope(\n scopePath: string,\n pkgName: string,\n requiredRange: string | undefined,\n depth: number,\n visited: Set<string>,\n queue: Array<{ dir: string; depth: number }>\n ): Promise<Package | null> {\n if (!(await this.exists[scopePath]) || !(await this.lstat[scopePath])?.isDirectory()) {\n return null\n }\n let scopeEntries: string[]\n try {\n scopeEntries = await fs.readdir(scopePath)\n } catch {\n return null\n }\n for (const sc of scopeEntries) {\n const scPath = path.join(scopePath, sc)\n const candidatePkgJson = path.join(scPath, \"node_modules\", pkgName, \"package.json\")\n if (await this.exists[candidatePkgJson]) {\n const json = await this.json[candidatePkgJson]\n if (json && this.semverSatisfies(json.version, requiredRange)) {\n return { packageDir: path.dirname(candidatePkgJson), packageJson: json }\n }\n }\n await this.enqueueIfExists(path.join(scPath, \"node_modules\"), depth, visited, queue)\n }\n return null\n }\n\n /** Enqueue a node_modules directory for BFS only if it exists on disk and hasn't been visited. */\n private async enqueueIfExists(nmPath: string, depth: number, visited: Set<string>, queue: Array<{ dir: string; depth: number }>): Promise<void> {\n if (!visited.has(nmPath) && (await this.exists[nmPath]) && (await this.lstat[nmPath])?.isDirectory()) {\n visited.add(nmPath)\n queue.push({ dir: nmPath, depth: depth + 1 })\n }\n }\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export declare abstract class NodeModulesCollector<ProdDepType extends Dependenc
|
|
|
15
15
|
protected readonly allDependencies: Map<string, ProdDepType>;
|
|
16
16
|
protected readonly productionGraph: DependencyGraph;
|
|
17
17
|
protected readonly cache: ModuleManager;
|
|
18
|
+
/** Whether `node_modules` uses a hoisted (flat) layout. Overridden by collectors that detect it from disk or config. */
|
|
18
19
|
protected isHoisted: Lazy<boolean>;
|
|
19
20
|
constructor(rootDir: string, tempDirManager: TmpDir);
|
|
20
21
|
/**
|
|
@@ -146,9 +147,13 @@ export declare abstract class NodeModulesCollector<ProdDepType extends Dependenc
|
|
|
146
147
|
* @param args - Array of command-line arguments
|
|
147
148
|
* @param cwd - The working directory to execute the command in
|
|
148
149
|
* @param tempOutputFile - The path to the temporary file where stdout will be written
|
|
149
|
-
* @returns Promise that resolves
|
|
150
|
+
* @returns Promise that resolves with the exit code and captured stderr when the command completes
|
|
151
|
+
* successfully (or with a tolerated exit code), or rejects if it fails
|
|
150
152
|
* @throws {Error} If the child process spawn fails or exits with a non-zero, unexpected code
|
|
151
153
|
*/
|
|
152
|
-
protected streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string): Promise<
|
|
154
|
+
protected streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string): Promise<{
|
|
155
|
+
code: number;
|
|
156
|
+
stderr: string;
|
|
157
|
+
}>;
|
|
153
158
|
}
|
|
154
159
|
//# sourceMappingURL=nodeModulesCollector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.d.ts","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,MAAM,EAAE,MAAM,cAAc,CAAA;AAEhF,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAmB,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAA4B,EAAE,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG1F,2FAA2F;AAC3F,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;CACX;AAED,8BAAsB,oBAAoB,CAAC,WAAW,SAAS,UAAU,CAAC,WAAW,EAAE,eAAe,CAAC,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.d.ts","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,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AAI,CAAC;IAQnK;;;;;;OAMG;IACH,SAAS,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAkBjF;;;;;;;;;;OAUG;IACH,SAAS,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,WAAW;IAYpF;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,mBAAmB;IAsD3B,OAAO,CAAC,sBAAsB;YA4BhB,eAAe;IA2D7B;;;;;;;;;OASG;IACH,SAAS,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,kBAAkB,UAAQ;cAU1D,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAqB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAY3J;;;;;;;;;;;;;;;OAeG;cACa,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAkC9J"}
|
|
@@ -15,21 +15,8 @@ export class NodeModulesCollector {
|
|
|
15
15
|
this.allDependencies = new Map();
|
|
16
16
|
this.productionGraph = {};
|
|
17
17
|
this.cache = new ModuleManager();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const command = getPackageManagerCommand(manager);
|
|
21
|
-
const config = (await this.asyncExec(command, ["config", "list"])).stdout;
|
|
22
|
-
if (config == null) {
|
|
23
|
-
log.debug({ manager }, "unable to determine node-linker setting; assuming non-hoisted (virtual store) layout");
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
const lines = Object.fromEntries(config.split("\n").map(line => line.split("=").map(s => s.trim())));
|
|
27
|
-
if (lines["node-linker"] === "hoisted") {
|
|
28
|
-
log.debug({ manager }, "node_modules are hoisted");
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
});
|
|
18
|
+
/** Whether `node_modules` uses a hoisted (flat) layout. Overridden by collectors that detect it from disk or config. */
|
|
19
|
+
this.isHoisted = new Lazy(() => Promise.resolve(false));
|
|
33
20
|
}
|
|
34
21
|
/**
|
|
35
22
|
* Retrieves and collects all Node.js modules for a given package.
|
|
@@ -70,8 +57,15 @@ export class NodeModulesCollector {
|
|
|
70
57
|
suffix: "output.json",
|
|
71
58
|
});
|
|
72
59
|
return retry(async () => {
|
|
73
|
-
await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile);
|
|
60
|
+
const { code, stderr } = await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile);
|
|
74
61
|
const shellOutput = await _fsExtra.readFile(tempOutputFile, { encoding: "utf8" });
|
|
62
|
+
if (shellOutput.trim().length === 0) {
|
|
63
|
+
// Parsing an empty string would only yield a misleading "No JSON content found in output" (#10208).
|
|
64
|
+
// With npm this usually means npm itself threw while writing its buffered JSON tree at exit: npm's exit
|
|
65
|
+
// handler swallows that exception and exits 1 with nothing on stdout and only `verbose exit 1` in its log.
|
|
66
|
+
throw new Error(`\`${[path.basename(command), ...args].join(" ")}\` (cwd: ${this.rootDir}) exited with code ${code} and produced no output on stdout; ` +
|
|
67
|
+
`with npm this usually means npm itself failed while writing its JSON dependency tree. stderr: ${stderr.trim().length > 0 ? stderr.trim() : "(empty)"}`);
|
|
68
|
+
}
|
|
75
69
|
const result = await Promise.resolve(this.parseDependenciesTree(shellOutput));
|
|
76
70
|
return result;
|
|
77
71
|
}, {
|
|
@@ -402,7 +396,8 @@ export class NodeModulesCollector {
|
|
|
402
396
|
* @param args - Array of command-line arguments
|
|
403
397
|
* @param cwd - The working directory to execute the command in
|
|
404
398
|
* @param tempOutputFile - The path to the temporary file where stdout will be written
|
|
405
|
-
* @returns Promise that resolves
|
|
399
|
+
* @returns Promise that resolves with the exit code and captured stderr when the command completes
|
|
400
|
+
* successfully (or with a tolerated exit code), or rejects if it fails
|
|
406
401
|
* @throws {Error} If the child process spawn fails or exits with a non-zero, unexpected code
|
|
407
402
|
*/
|
|
408
403
|
async streamCollectorCommandToFile(command, args, cwd, tempOutputFile) {
|
|
@@ -435,6 +430,7 @@ export class NodeModulesCollector {
|
|
|
435
430
|
if (code !== 0 && !shouldIgnore) {
|
|
436
431
|
throw new Error(`Node module collector process exited with code ${code}:\n${stderr}`);
|
|
437
432
|
}
|
|
433
|
+
return { code, stderr };
|
|
438
434
|
}
|
|
439
435
|
}
|
|
440
436
|
//# sourceMappingURL=nodeModulesCollector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,qBAAqB,EAAU,MAAM,cAAc,CAAA;AAChF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAwC,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAM,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAQlE,MAAM,OAAgB,oBAAoB;IAsBxC,YACqB,OAAe,EACjB,cAAsB;QADpB,YAAO,G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AAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;QAE9D,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE;YACnF,4FAA4F;YAC5F,0FAA0F;YAC1F,8FAA8F;YAC9F,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC;YACrC,sBAAsB,EAAE,GAAG;YAC3B,+BAA+B,EAAE,GAAG;SACrC,CAAC,CAAA;QAEF,0CAA0C;QAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC5F,IAAI,YAAY,EAAE,CAAC;YACjB,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;QAC1J,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;YAC/E,yFAAyF;YACzF,qFAAqF;YACrF,uFAAuF;YACvF,yEAAyE;YACzE,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC1E,CAAC;QACH,CAAC;QACD,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAA;QACvF,CAAC;IACH,CAAC;CACF","sourcesContent":["import { exists, log, retry, stripSensitiveEnvVars, TmpDir } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist.js\"\nimport { LogMessageByKey, ModuleManager } from \"./moduleManager.js\"\nimport { getPackageManagerCommand, PM } from \"./packageManager.js\"\nimport { streamSpawnToFile } from \"../util/streamSpawnToFile.js\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types.js\"\nimport { isPackageCompatible } from \"../util/archCompatibility.js\"\n\n/** Target arch/platform used to drop `cpu`/`os`-incompatible packages while collecting. */\nexport interface ArchFilter {\n cpu: string | null\n os: string\n}\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n protected isHoisted = new Lazy<boolean>(async () => {\n const { manager } = this.installOptions\n const command = getPackageManagerCommand(manager)\n const config = (await this.asyncExec(command, [\"config\", \"list\"])).stdout\n if (config == null) {\n log.debug({ manager }, \"unable to determine node-linker setting; assuming non-hoisted (virtual store) layout\")\n return false\n }\n const lines = Object.fromEntries(config.split(\"\\n\").map(line => line.split(\"=\").map(s => s.trim())))\n if (lines[\"node-linker\"] === \"hoisted\") {\n log.debug({ manager }, \"node_modules are hoisted\")\n return true\n }\n return false\n })\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n */\n public async getNodeModules({\n packageName,\n archFilter,\n ignoredDependencies,\n }: {\n packageName: string\n archFilter?: ArchFilter\n ignoredDependencies?: ReadonlyArray<string>\n }): Promise<{\n nodeModules: NodeModuleInfo[]\n logSummary: ModuleManager[\"logSummary\"]\n }> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n this.markExcludedModules(this.productionGraph, packageName, ignoredDependencies ?? [])\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules, archFilter)\n\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return { nodeModules: this.nodeModules, logSummary: this.cache.logSummary }\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await _fsExtra.readFile(tempOutputFile, { encoding: \"utf8\" })\n const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await _fsExtra.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\n }\n\n // Both indicate truncated/polluted PM output (a transient that re-running the command clears).\n if (error.message?.includes(\"Unexpected end of JSON input\") || error.message?.includes(\"No JSON content found in output\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n // We use the key (alias name) instead of value.name for npm aliased packages\n // e.g., { \"foo\": { name: \"@scope/bar\", ... } } should be stored as \"foo@version\"\n protected normalizePackageVersion(key: string, pkg: ProdDepType) {\n return { id: `${key}@${pkg.version}`, pkgOverride: { ...pkg, name: key } }\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n let at: number\n if (identifier.startsWith(\"@\")) {\n // Scoped package: find the version separator after the scope (e.g. \"@scope/pkg@1.2.3\")\n const slashIndex = identifier.indexOf(\"/\")\n if (slashIndex === -1) {\n return { name: identifier, version: \"unknown\" }\n }\n at = identifier.indexOf(\"@\", slashIndex + 1)\n } else {\n at = identifier.indexOf(\"@\")\n }\n if (at <= 0) {\n return { name: identifier, version: \"unknown\" }\n }\n return { name: identifier.slice(0, at), version: identifier.slice(at + 1) }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return tree\n }\n\n /**\n * Flags which modules must be omitted from the *copied* app output for the given `ignoredNames` by\n * setting an `excluded` marker on the pre-hoist graph nodes.\n *\n * Only a *top-level* production dependency (one the app itself declares) can be excluded, together\n * with its exclusively-owned transitive subtree. A package that is merely a transitive dependency of\n * a non-excluded production dependency is never excluded, even if its name is in `ignoredNames`:\n * only the root's own edges to ignored names are severed, so anything still reachable through another\n * production dependency stays reachable and is kept.\n *\n * Runs on the pre-hoist graph, where the true parent->child edges still exist, so a shared (deduped)\n * transitive dependency remains reachable and is kept while an ignored package's exclusive subtree\n * becomes unreachable and is flagged.\n */\n private markExcludedModules(graph: DependencyGraph, rootId: string, ignoredNames: ReadonlyArray<string>): void {\n const ignored = new Set(ignoredNames)\n if (ignored.size === 0) {\n return\n }\n\n const rootDeps = graph[rootId]?.dependencies ?? []\n const ignoredRootEdges = new Set(rootDeps.filter(dep => ignored.has(this.parseNameVersion(dep).name)))\n if (ignoredRootEdges.size === 0) {\n return\n }\n\n const reachable = new Set<string>()\n const stack: string[] = [rootId]\n while (stack.length > 0) {\n const id = stack.pop()!\n if (reachable.has(id)) {\n continue\n }\n reachable.add(id)\n const node = graph[id]\n if (node != null) {\n for (const dep of node.dependencies) {\n if (id === rootId && ignoredRootEdges?.has(dep)) {\n continue\n }\n if (!reachable.has(dep)) {\n stack.push(dep)\n }\n }\n }\n }\n for (const id of Object.keys(graph)) {\n if (!reachable.has(id)) {\n graph[id].excluded = true\n }\n }\n\n // Only directly-declared deps that actually ended up excluded (i.e. not still reachable via a kept\n // dependency) are surfaced to the user; their exclusive transitive subtree is omitted from the log.\n // Report the full `name@version` graph id — like the other logSummary buckets — so the log stays\n // truthful when another version of the same name still ships via a kept dependency (e.g. `debug@4`\n // excluded while `debug@3` remains bundled).\n const topLevelExcluded = new Set<string>()\n for (const dep of ignoredRootEdges) {\n if (!reachable.has(dep)) {\n topLevelExcluded.add(dep)\n }\n }\n if (topLevelExcluded.size > 0) {\n this.cache.logSummary[LogMessageByKey.PKG_EXCLUDED_IGNORED].push(...Array.from(topLevelExcluded).sort())\n }\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n // a package that declares itself as a dependency (e.g. libsql) must not produce a self-edge\n if (child !== node) {\n node.dependencies.add(child)\n }\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[], archFilter?: ArchFilter, ancestors: Set<HoisterResult> = new Set()) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n // dependency cycles (including self-references) must not recurse\n if (ancestors.has(d)) {\n continue\n }\n const reference = [...d.references][0]\n const key = `${d.name}@${reference}`\n // Normalize the path to handle mixed separators from pnpm JSON output on Windows\n const rawPath = this.allDependencies.get(key)?.path\n const p = rawPath != null ? path.normalize(rawPath) : undefined\n if (p === undefined) {\n this.cache.logSummary[LogMessageByKey.PKG_NOT_FOUND].push(key)\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n this.logMissingDependency(key)\n continue\n }\n\n const dir = await this.cache.realPath[p]\n\n // Drop packages whose declared `cpu`/`os` is incompatible with the target arch/platform (and their\n // subtree). npm/pnpm install only the host's platform-specific optional packages, so without this an\n // arm64-only binary (e.g. `@esbuild/darwin-arm64`) would be bundled into the x64 build too — and into\n // both slices of a universal build, which `@electron/universal` then refuses to merge. Reuses the\n // memoized `package.json` cache populated during collection.\n if (archFilter != null) {\n const pkgJson = await this.cache.json[path.join(dir, \"package.json\")]\n if (pkgJson != null && !isPackageCompatible(pkgJson, archFilter.cpu, archFilter.os)) {\n this.cache.logSummary[LogMessageByKey.PKG_INCOMPATIBLE_PLATFORM].push(key)\n continue\n }\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir,\n excluded: this.productionGraph[key]?.excluded,\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n ancestors.add(d)\n await this._getNodeModules(d.dependencies, node.dependencies, archFilter, ancestors)\n ancestors.delete(d)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n /**\n * Records a dependency that could not be resolved on disk in the log summary.\n *\n * A platform-specific package name (e.g. `sass-embedded-linux-x64`) is always classified as a\n * platform-specific optional dependency. Otherwise, `isDeclaredOptional` decides the bucket: a\n * caller that *knows* the dependency was declared in `optionalDependencies` (e.g. the pnpm\n * collector's optional-dependency check) reports a missing *optional* dependency — an expected\n * condition — rather than the `PKG_NOT_ON_DISK` warning reserved for genuinely missing\n * production dependencies.\n */\n protected logMissingDependency(pkgName: string, isDeclaredOptional = false) {\n const PLATFORM_PACKAGE_RE = /(linux|win32|darwin|freebsd|android)[-_](x64|arm64|ia32|arm|ppc64|s390x|loong64|riscv64|universal)/\n const diskLogKey = PLATFORM_PACKAGE_RE.test(pkgName)\n ? LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED\n : isDeclaredOptional\n ? LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED\n : LogMessageByKey.PKG_NOT_ON_DISK\n this.cache.logSummary[diskLogKey].push(pkgName)\n }\n\n protected async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await _fsExtra.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a package-manager command and streams its stdout to a file.\n *\n * Delegates the spawn/stream/flush mechanics (including the Windows `powershell.exe -EncodedCommand`\n * wrapping) to {@link streamSpawnToFile}, and layers on the collector-specific interpretation of the\n * result: corepack is silenced for these invocations, `npm list` exit code 1 is tolerated, and any\n * stderr is surfaced as a collector warning only when the exit code is genuinely unexpected.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves when the command completes successfully or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero, unexpected code\n */\n protected async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string) {\n // Derive execName from the original command so the npm-list shouldIgnore check below keys off the\n // real invocation (e.g. \"npm\"), not the \"powershell\" wrapper streamSpawnToFile uses on Windows.\n const execName = path.basename(command, path.extname(command))\n\n const { code, stderr } = await streamSpawnToFile(command, args, cwd, tempOutputFile, {\n // Package manager invocations do not need signing/publishing credentials. Silence corepack:\n // strict=0 so a project's `packageManager` pin can't abort our read-only queries, and the\n // download prompt/notice off so corepack doesn't flood stdout/stderr with activation chatter.\n ...stripSensitiveEnvVars(process.env),\n COREPACK_ENABLE_STRICT: \"0\",\n COREPACK_ENABLE_DOWNLOAD_PROMPT: \"0\",\n })\n\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n // Only surface stderr as a user-visible warning when the exit code itself is unexpected.\n // When shouldIgnore is true (npm list exit code 1) the stderr is an anticipated side\n // effect of package-manager features like yarn resolutions or npm overrides that cause\n // npm to report ELSPROBLEMS for aliased packages it considers \"invalid\".\n if (!shouldIgnore) {\n this.cache.logSummary[LogMessageByKey.PKG_COLLECTOR_OUTPUT].push(stderr)\n }\n }\n if (code !== 0 && !shouldIgnore) {\n throw new Error(`Node module collector process exited with code ${code}:\\n${stderr}`)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeModulesCollector.js","sourceRoot":"","sources":["../../src/node-module-collector/nodeModulesCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,qBAAqB,EAAU,MAAM,cAAc,CAAA;AAChF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAwC,MAAM,YAAY,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,wBAAwB,EAAM,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAQlE,MAAM,OAAgB,oBAAoB;IASxC,YACqB,OAAe,EACjB,cAAsB;QADpB,YAA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AG;YAC3B,+BAA+B,EAAE,GAAG;SACrC,CAAC,CAAA;QAEF,0CAA0C;QAC1C,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC5F,IAAI,YAAY,EAAE,CAAC;YACjB,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,uIAAuI,CAAC,CAAA;QAC1J,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,wDAAwD,CAAC,CAAA;YAC/E,yFAAyF;YACzF,qFAAqF;YACrF,uFAAuF;YACvF,yEAAyE;YACzE,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC1E,CAAC;QACH,CAAC;QACD,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,kDAAkD,IAAI,MAAM,MAAM,EAAE,CAAC,CAAA;QACvF,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import { exists, log, retry, stripSensitiveEnvVars, TmpDir } from \"builder-util\"\nimport _fsExtra from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { hoist, type HoisterResult, type HoisterTree } from \"./hoist.js\"\nimport { LogMessageByKey, ModuleManager } from \"./moduleManager.js\"\nimport { getPackageManagerCommand, PM } from \"./packageManager.js\"\nimport { streamSpawnToFile } from \"../util/streamSpawnToFile.js\"\nimport type { Dependency, DependencyGraph, NodeModuleInfo, PackageJson } from \"./types.js\"\nimport { isPackageCompatible } from \"../util/archCompatibility.js\"\n\n/** Target arch/platform used to drop `cpu`/`os`-incompatible packages while collecting. */\nexport interface ArchFilter {\n cpu: string | null\n os: string\n}\n\nexport abstract class NodeModulesCollector<ProdDepType extends Dependency<ProdDepType, OptionalDepType>, OptionalDepType> {\n private readonly nodeModules: NodeModuleInfo[] = []\n protected readonly allDependencies: Map<string, ProdDepType> = new Map()\n protected readonly productionGraph: DependencyGraph = {}\n protected readonly cache: ModuleManager = new ModuleManager()\n\n /** Whether `node_modules` uses a hoisted (flat) layout. Overridden by collectors that detect it from disk or config. */\n protected isHoisted = new Lazy<boolean>(() => Promise.resolve(false))\n\n constructor(\n protected readonly rootDir: string,\n private readonly tempDirManager: TmpDir\n ) {}\n\n /**\n * Retrieves and collects all Node.js modules for a given package.\n *\n * This method orchestrates the entire module collection process by:\n * 1. Fetching the dependency tree from the package manager\n * 2. Collecting all dependencies recursively\n * 3. Extracting workspace references if applicable\n * 4. Building a production dependency graph\n * 5. Hoisting the dependencies to their final locations\n * 6. Resolving and returning module information\n */\n public async getNodeModules({\n packageName,\n archFilter,\n ignoredDependencies,\n }: {\n packageName: string\n archFilter?: ArchFilter\n ignoredDependencies?: ReadonlyArray<string>\n }): Promise<{\n nodeModules: NodeModuleInfo[]\n logSummary: ModuleManager[\"logSummary\"]\n }> {\n const tree: ProdDepType = await this.getDependenciesTree(this.installOptions.manager)\n\n await this.collectAllDependencies(tree, packageName)\n const realTree: ProdDepType = this.getTreeFromWorkspaces(tree, packageName)\n await this.extractProductionDependencyGraph(realTree, packageName)\n\n this.markExcludedModules(this.productionGraph, packageName, ignoredDependencies ?? [])\n\n const hoisterResult: HoisterResult = hoist(this.transformToHoisterTree(this.productionGraph, packageName), {\n check: log.isDebugEnabled,\n })\n\n await this._getNodeModules(hoisterResult.dependencies, this.nodeModules, archFilter)\n\n log.debug({ packageName, depCount: this.nodeModules.length }, \"node modules collection complete\")\n\n return { nodeModules: this.nodeModules, logSummary: this.cache.logSummary }\n }\n\n public abstract readonly installOptions: {\n manager: PM\n lockfile: string\n }\n\n protected abstract getArgs(): string[]\n protected abstract extractProductionDependencyGraph(tree: Dependency<ProdDepType, OptionalDepType>, dependencyId: string): Promise<void>\n protected abstract collectAllDependencies(tree: Dependency<ProdDepType, OptionalDepType>, appPackageName: string): Promise<void>\n\n /**\n * Retrieves the dependency tree from the package manager.\n *\n * Executes the appropriate package manager command to fetch the dependency tree and writes\n * the output to a temporary file. Includes retry logic to handle transient failures such as\n * incomplete JSON output or missing files. Will retry up to 1 time with exponential backoff.\n */\n protected async getDependenciesTree(pm: PM): Promise<ProdDepType> {\n const command = getPackageManagerCommand(pm)\n const args = this.getArgs()\n\n const tempOutputFile = await this.tempDirManager.getTempFile({\n prefix: path.basename(command, path.extname(command)),\n suffix: \"output.json\",\n })\n\n return retry(\n async () => {\n const { code, stderr } = await this.streamCollectorCommandToFile(command, args, this.rootDir, tempOutputFile)\n const shellOutput = await _fsExtra.readFile(tempOutputFile, { encoding: \"utf8\" })\n if (shellOutput.trim().length === 0) {\n // Parsing an empty string would only yield a misleading \"No JSON content found in output\" (#10208).\n // With npm this usually means npm itself threw while writing its buffered JSON tree at exit: npm's exit\n // handler swallows that exception and exits 1 with nothing on stdout and only `verbose exit 1` in its log.\n throw new Error(\n `\\`${[path.basename(command), ...args].join(\" \")}\\` (cwd: ${this.rootDir}) exited with code ${code} and produced no output on stdout; ` +\n `with npm this usually means npm itself failed while writing its JSON dependency tree. stderr: ${stderr.trim().length > 0 ? stderr.trim() : \"(empty)\"}`\n )\n }\n const result = await Promise.resolve(this.parseDependenciesTree(shellOutput))\n return result\n },\n {\n retries: 1,\n interval: 2000,\n backoff: 2000,\n shouldRetry: async (error: any) => {\n const fields: Record<string, string> = { error: error.message, tempOutputFile, cwd: this.rootDir, packageManager: pm }\n\n if (!(await exists(tempOutputFile))) {\n log.debug(fields, \"dependency tree output file missing, retrying\")\n return true\n }\n\n const fileContent = await _fsExtra.readFile(tempOutputFile, { encoding: \"utf8\" })\n fields.fileContentLength = fileContent.length.toString()\n\n if (fileContent.trim().length === 0) {\n log.debug(fields, \"dependency tree output file empty, retrying\")\n return true\n }\n\n // extract small start/end sample for debugging purposes (e.g. polluted console output)\n const lines = fileContent.split(\"\\n\")\n const lineSampleSize = Math.min(5, lines.length / 2)\n if (2 * lineSampleSize > 5) {\n fields.sampleStart = lines.slice(0, lineSampleSize).join(\"\\n\")\n fields.sampleEnd = lines.slice(-lineSampleSize).join(\"\\n\")\n } else {\n fields.content = fileContent\n }\n\n // Both indicate truncated/polluted PM output (a transient that re-running the command clears).\n if (error.message?.includes(\"Unexpected end of JSON input\") || error.message?.includes(\"No JSON content found in output\")) {\n log.debug(fields, \"JSON parse error in dependency tree, retrying\")\n return true\n }\n\n log.error(fields, \"error parsing dependencies tree\")\n return false\n },\n }\n )\n }\n\n /**\n * Parses the dependencies tree from shell command output.\n *\n **/\n protected parseDependenciesTree(shellOutput: string): ProdDepType | Promise<ProdDepType> {\n return this.extractJsonFromPollutedOutput<ProdDepType>(shellOutput)\n }\n\n protected extractJsonFromPollutedOutput<T>(shellOutput: string): T {\n const consoleOutput = shellOutput.trim()\n try {\n // Please for the love of all that is holy, this should cover 99% of cases where npm/pnpm/yarn output is clean JSON\n return JSON.parse(consoleOutput)\n } catch {\n // ignore\n }\n\n // DEDICATED FALLBACK FOR POLLUTED OUTPUT, non-trivial to implement correctly, not needed in most cases, and highly inefficient\n\n // Find the first index that starts with { or [\n const bracketOpen = Math.max(consoleOutput.indexOf(\"{\"), 0)\n const bracketOpenSquare = Math.max(consoleOutput.indexOf(\"[\"), 0)\n const start = Math.min(bracketOpen, bracketOpenSquare) // always non-negative due to Math.max above\n\n for (let i = start; i < consoleOutput.length; i++) {\n const slice = consoleOutput.slice(start, i + 1)\n try {\n return JSON.parse(slice)\n } catch {\n // ignore, try next\n }\n }\n throw new Error(\"No JSON content found in output\")\n }\n\n protected cacheKey(pkg: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): string {\n const rel = path.relative(this.rootDir, pkg.path)\n return `${pkg.name}::${pkg.version}::${rel ?? \".\"}`\n }\n\n // We use the key (alias name) instead of value.name for npm aliased packages\n // e.g., { \"foo\": { name: \"@scope/bar\", ... } } should be stored as \"foo@version\"\n protected normalizePackageVersion(key: string, pkg: ProdDepType) {\n return { id: `${key}@${pkg.version}`, pkgOverride: { ...pkg, name: key } }\n }\n\n /**\n * Determines if a given dependency is a production dependency of a package.\n *\n * Checks both the dependencies and optionalDependencies of a package to see if\n * the specified dependency name is listed.\n *\n * @param depName - The name of the dependency to check\n * @param pkg - The package to search for the dependency in\n * @returns True if the dependency is found in either dependencies or optionalDependencies, false otherwise\n */\n protected isProdDependency(depName: string, pkg: ProdDepType): boolean {\n const prodDeps = { ...pkg.dependencies, ...pkg.optionalDependencies }\n return prodDeps[depName] != null\n }\n\n protected async locatePackageWithVersion(depTree: Pick<ProdDepType, \"name\" | \"version\" | \"path\">): Promise<{ packageDir: string; packageJson: PackageJson } | null> {\n const result = await this.cache.locatePackageVersion({\n parentDir: depTree.path,\n pkgName: depTree.name,\n requiredRange: depTree.version,\n })\n return result\n }\n /**\n * Parses a dependency identifier string into name and version components.\n *\n * Handles both scoped packages (e.g., \"@scope/pkg@1.2.3\") and regular packages (e.g., \"pkg@1.2.3\").\n * If the identifier is malformed or cannot be parsed, defaults to treating the entire string as\n * the package name with an \"unknown\" version.\n */\n protected parseNameVersion(identifier: string): { name: string; version: string } {\n let at: number\n if (identifier.startsWith(\"@\")) {\n // Scoped package: find the version separator after the scope (e.g. \"@scope/pkg@1.2.3\")\n const slashIndex = identifier.indexOf(\"/\")\n if (slashIndex === -1) {\n return { name: identifier, version: \"unknown\" }\n }\n at = identifier.indexOf(\"@\", slashIndex + 1)\n } else {\n at = identifier.indexOf(\"@\")\n }\n if (at <= 0) {\n return { name: identifier, version: \"unknown\" }\n }\n return { name: identifier.slice(0, at), version: identifier.slice(at + 1) }\n }\n\n /**\n * Retrieves the dependency tree and handles workspace package self-references.\n *\n * If the project is a workspace project, this method removes the root package's self-reference\n * from the dependency tree to avoid circular dependencies. It promotes the root package's\n * direct dependencies to the top level of the tree.\n *\n * @param tree - The original dependency tree\n * @param packageName - The name of the package to check for and remove from the tree\n * @returns The extracted dependency subtree\n */\n protected getTreeFromWorkspaces(tree: ProdDepType, packageName: string): ProdDepType {\n if (tree.workspaces && tree.dependencies) {\n for (const [key, value] of Object.entries(tree.dependencies)) {\n if (key === packageName) {\n return value\n }\n }\n }\n\n return tree\n }\n\n /**\n * Flags which modules must be omitted from the *copied* app output for the given `ignoredNames` by\n * setting an `excluded` marker on the pre-hoist graph nodes.\n *\n * Only a *top-level* production dependency (one the app itself declares) can be excluded, together\n * with its exclusively-owned transitive subtree. A package that is merely a transitive dependency of\n * a non-excluded production dependency is never excluded, even if its name is in `ignoredNames`:\n * only the root's own edges to ignored names are severed, so anything still reachable through another\n * production dependency stays reachable and is kept.\n *\n * Runs on the pre-hoist graph, where the true parent->child edges still exist, so a shared (deduped)\n * transitive dependency remains reachable and is kept while an ignored package's exclusive subtree\n * becomes unreachable and is flagged.\n */\n private markExcludedModules(graph: DependencyGraph, rootId: string, ignoredNames: ReadonlyArray<string>): void {\n const ignored = new Set(ignoredNames)\n if (ignored.size === 0) {\n return\n }\n\n const rootDeps = graph[rootId]?.dependencies ?? []\n const ignoredRootEdges = new Set(rootDeps.filter(dep => ignored.has(this.parseNameVersion(dep).name)))\n if (ignoredRootEdges.size === 0) {\n return\n }\n\n const reachable = new Set<string>()\n const stack: string[] = [rootId]\n while (stack.length > 0) {\n const id = stack.pop()!\n if (reachable.has(id)) {\n continue\n }\n reachable.add(id)\n const node = graph[id]\n if (node != null) {\n for (const dep of node.dependencies) {\n if (id === rootId && ignoredRootEdges?.has(dep)) {\n continue\n }\n if (!reachable.has(dep)) {\n stack.push(dep)\n }\n }\n }\n }\n for (const id of Object.keys(graph)) {\n if (!reachable.has(id)) {\n graph[id].excluded = true\n }\n }\n\n // Only directly-declared deps that actually ended up excluded (i.e. not still reachable via a kept\n // dependency) are surfaced to the user; their exclusive transitive subtree is omitted from the log.\n // Report the full `name@version` graph id — like the other logSummary buckets — so the log stays\n // truthful when another version of the same name still ships via a kept dependency (e.g. `debug@4`\n // excluded while `debug@3` remains bundled).\n const topLevelExcluded = new Set<string>()\n for (const dep of ignoredRootEdges) {\n if (!reachable.has(dep)) {\n topLevelExcluded.add(dep)\n }\n }\n if (topLevelExcluded.size > 0) {\n this.cache.logSummary[LogMessageByKey.PKG_EXCLUDED_IGNORED].push(...Array.from(topLevelExcluded).sort())\n }\n }\n\n private transformToHoisterTree(obj: DependencyGraph, key: string, nodes: Map<string, HoisterTree> = new Map()): HoisterTree {\n let node = nodes.get(key)\n const { name, version } = this.parseNameVersion(key)\n\n if (!node) {\n node = {\n name,\n identName: name,\n reference: version,\n dependencies: new Set<HoisterTree>(),\n peerNames: new Set<string>(),\n }\n\n nodes.set(key, node)\n\n const deps = (obj[key] || {}).dependencies || []\n for (const dep of deps) {\n const child = this.transformToHoisterTree(obj, dep, nodes)\n // a package that declares itself as a dependency (e.g. libsql) must not produce a self-edge\n if (child !== node) {\n node.dependencies.add(child)\n }\n }\n }\n\n return node\n }\n\n private async _getNodeModules(dependencies: Set<HoisterResult>, result: NodeModuleInfo[], archFilter?: ArchFilter, ancestors: Set<HoisterResult> = new Set()) {\n if (dependencies.size === 0) {\n return\n }\n\n for (const d of dependencies.values()) {\n // dependency cycles (including self-references) must not recurse\n if (ancestors.has(d)) {\n continue\n }\n const reference = [...d.references][0]\n const key = `${d.name}@${reference}`\n // Normalize the path to handle mixed separators from pnpm JSON output on Windows\n const rawPath = this.allDependencies.get(key)?.path\n const p = rawPath != null ? path.normalize(rawPath) : undefined\n if (p === undefined) {\n this.cache.logSummary[LogMessageByKey.PKG_NOT_FOUND].push(key)\n continue\n }\n\n // fix npm list issue\n // https://github.com/npm/cli/issues/8535\n if (!(await this.cache.exists[p])) {\n this.logMissingDependency(key)\n continue\n }\n\n const dir = await this.cache.realPath[p]\n\n // Drop packages whose declared `cpu`/`os` is incompatible with the target arch/platform (and their\n // subtree). npm/pnpm install only the host's platform-specific optional packages, so without this an\n // arm64-only binary (e.g. `@esbuild/darwin-arm64`) would be bundled into the x64 build too — and into\n // both slices of a universal build, which `@electron/universal` then refuses to merge. Reuses the\n // memoized `package.json` cache populated during collection.\n if (archFilter != null) {\n const pkgJson = await this.cache.json[path.join(dir, \"package.json\")]\n if (pkgJson != null && !isPackageCompatible(pkgJson, archFilter.cpu, archFilter.os)) {\n this.cache.logSummary[LogMessageByKey.PKG_INCOMPATIBLE_PLATFORM].push(key)\n continue\n }\n }\n\n const node: NodeModuleInfo = {\n name: d.name,\n version: reference,\n dir,\n excluded: this.productionGraph[key]?.excluded,\n }\n result.push(node)\n if (d.dependencies.size > 0) {\n node.dependencies = []\n ancestors.add(d)\n await this._getNodeModules(d.dependencies, node.dependencies, archFilter, ancestors)\n ancestors.delete(d)\n }\n }\n result.sort((a, b) => a.name.localeCompare(b.name))\n }\n\n /**\n * Records a dependency that could not be resolved on disk in the log summary.\n *\n * A platform-specific package name (e.g. `sass-embedded-linux-x64`) is always classified as a\n * platform-specific optional dependency. Otherwise, `isDeclaredOptional` decides the bucket: a\n * caller that *knows* the dependency was declared in `optionalDependencies` (e.g. the pnpm\n * collector's optional-dependency check) reports a missing *optional* dependency — an expected\n * condition — rather than the `PKG_NOT_ON_DISK` warning reserved for genuinely missing\n * production dependencies.\n */\n protected logMissingDependency(pkgName: string, isDeclaredOptional = false) {\n const PLATFORM_PACKAGE_RE = /(linux|win32|darwin|freebsd|android)[-_](x64|arm64|ia32|arm|ppc64|s390x|loong64|riscv64|universal)/\n const diskLogKey = PLATFORM_PACKAGE_RE.test(pkgName)\n ? LogMessageByKey.PKG_OPTIONAL_PLATFORM_NOT_INSTALLED\n : isDeclaredOptional\n ? LogMessageByKey.PKG_OPTIONAL_NOT_INSTALLED\n : LogMessageByKey.PKG_NOT_ON_DISK\n this.cache.logSummary[diskLogKey].push(pkgName)\n }\n\n protected async asyncExec(command: string, args: string[], cwd: string = this.rootDir): Promise<{ stdout: string | undefined; stderr: string | undefined }> {\n const file = await this.tempDirManager.getTempFile({ prefix: \"exec-\", suffix: \".txt\" })\n try {\n await this.streamCollectorCommandToFile(command, args, cwd, file)\n const result = await _fsExtra.readFile(file, { encoding: \"utf8\" })\n return { stdout: result?.trim(), stderr: undefined }\n } catch (error: any) {\n log.debug({ error: error.message }, \"failed to execute command\")\n return { stdout: undefined, stderr: error.message }\n }\n }\n\n /**\n * Executes a package-manager command and streams its stdout to a file.\n *\n * Delegates the spawn/stream/flush mechanics (including the Windows `powershell.exe -EncodedCommand`\n * wrapping) to {@link streamSpawnToFile}, and layers on the collector-specific interpretation of the\n * result: corepack is silenced for these invocations, `npm list` exit code 1 is tolerated, and any\n * stderr is surfaced as a collector warning only when the exit code is genuinely unexpected.\n *\n * @param command - The command to execute\n * @param args - Array of command-line arguments\n * @param cwd - The working directory to execute the command in\n * @param tempOutputFile - The path to the temporary file where stdout will be written\n * @returns Promise that resolves with the exit code and captured stderr when the command completes\n * successfully (or with a tolerated exit code), or rejects if it fails\n * @throws {Error} If the child process spawn fails or exits with a non-zero, unexpected code\n */\n protected async streamCollectorCommandToFile(command: string, args: string[], cwd: string, tempOutputFile: string): Promise<{ code: number; stderr: string }> {\n // Derive execName from the original command so the npm-list shouldIgnore check below keys off the\n // real invocation (e.g. \"npm\"), not the \"powershell\" wrapper streamSpawnToFile uses on Windows.\n const execName = path.basename(command, path.extname(command))\n\n const { code, stderr } = await streamSpawnToFile(command, args, cwd, tempOutputFile, {\n // Package manager invocations do not need signing/publishing credentials. Silence corepack:\n // strict=0 so a project's `packageManager` pin can't abort our read-only queries, and the\n // download prompt/notice off so corepack doesn't flood stdout/stderr with activation chatter.\n ...stripSensitiveEnvVars(process.env),\n COREPACK_ENABLE_STRICT: \"0\",\n COREPACK_ENABLE_DOWNLOAD_PROMPT: \"0\",\n })\n\n // https://github.com/npm/npm/issues/17624\n const shouldIgnore = code === 1 && \"npm\" === execName.toLowerCase() && args.includes(\"list\")\n if (shouldIgnore) {\n log.debug(null, \"`npm list` returned non-zero exit code, but it MIGHT be expected (https://github.com/npm/npm/issues/17624). Check stderr for details.\")\n }\n if (stderr.length > 0) {\n log.debug({ stderr }, \"note: there was node module collector output on stderr\")\n // Only surface stderr as a user-visible warning when the exit code itself is unexpected.\n // When shouldIgnore is true (npm list exit code 1) the stderr is an anticipated side\n // effect of package-manager features like yarn resolutions or npm overrides that cause\n // npm to report ELSPROBLEMS for aliased packages it considers \"invalid\".\n if (!shouldIgnore) {\n this.cache.logSummary[LogMessageByKey.PKG_COLLECTOR_OUTPUT].push(stderr)\n }\n }\n if (code !== 0 && !shouldIgnore) {\n throw new Error(`Node module collector process exited with code ${code}:\\n${stderr}`)\n }\n return { code, stderr }\n }\n}\n"]}
|
|
@@ -11,10 +11,10 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
|
|
|
11
11
|
private _pnpmMajorVersion;
|
|
12
12
|
private readonly pnpmVersion;
|
|
13
13
|
/**
|
|
14
|
-
* Detect pnpm's installed layout from the on-disk structure rather than
|
|
15
|
-
* pnpm 11
|
|
16
|
-
* config
|
|
17
|
-
*
|
|
14
|
+
* Detect pnpm's installed layout from the on-disk structure rather than from config.
|
|
15
|
+
* pnpm 11 ignores `node-linker` in `.npmrc` (it moved to `nodeLinker` in `pnpm-workspace.yaml`),
|
|
16
|
+
* so config parsing can report "not hoisted" for a hoisted install, which would disable the
|
|
17
|
+
* downward search needed to find version-conflicted nested deps.
|
|
18
18
|
*
|
|
19
19
|
* In the default isolated store every regular top-level package resolves — through a symlink
|
|
20
20
|
* on POSIX, a junction on Windows — into `node_modules/.pnpm/<name>@<ver>/node_modules/<name>`.
|
|
@@ -25,6 +25,15 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
|
|
|
25
25
|
* otherwise mask an isolated store.
|
|
26
26
|
*/
|
|
27
27
|
protected isHoisted: Lazy<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* The pnpm workspace root containing `rootDir` (nearest ancestor with `pnpm-workspace.yaml`, as pnpm
|
|
30
|
+
* itself resolves it), or null outside a workspace or when `rootDir` is the workspace root.
|
|
31
|
+
*/
|
|
32
|
+
private readonly workspaceRoot;
|
|
33
|
+
/** `rootDir`, then the workspace root when `rootDir` is a workspace package. */
|
|
34
|
+
private readonly layoutRoots;
|
|
35
|
+
/** Returns true if `nmDir` is an isolated (`.pnpm`) store, false if hoisted, null if it holds no packages. */
|
|
36
|
+
private scanNodeModulesLayout;
|
|
28
37
|
/**
|
|
29
38
|
* Memo for `locateFromDepOrRoot`, keyed by `name@version`. pnpm's content-addressed virtual
|
|
30
39
|
* store guarantees that any given `name@version` resolves to a single location on disk, so
|
|
@@ -56,7 +65,38 @@ export declare class PnpmNodeModulesCollector extends NodeModulesCollector<PnpmD
|
|
|
56
65
|
* versions of a dep exist in the workspace.
|
|
57
66
|
*/
|
|
58
67
|
private locateFromDepOrRoot;
|
|
68
|
+
/**
|
|
69
|
+
* Resolve a located package to its real directory (the symlink target), leaving a non-symlinked
|
|
70
|
+
* hit untouched.
|
|
71
|
+
*
|
|
72
|
+
* `locatePackageVersion` returns the path it *walked*, which in pnpm's isolated store is the
|
|
73
|
+
* `node_modules/<name>` symlink rather than `.pnpm/<name>@<ver>/node_modules/<name>`. That
|
|
74
|
+
* distinction matters because the store keeps a package's dependencies as SIBLINGS inside
|
|
75
|
+
* `.pnpm/<name>@<ver>/node_modules/`, reachable only from the real path: searching upward from
|
|
76
|
+
* the symlink walks the *linking* project instead of the store and finds nothing. That is how
|
|
77
|
+
* `fs-extra`'s `universalify`/`jsonfile` (and `js-yaml`'s `argparse`) were silently dropped from
|
|
78
|
+
* the asar of an app whose `electron-updater` came from a `link:`ed checkout — pnpm reports such
|
|
79
|
+
* packages with no dependency tree, so `visitDep` resolves their deps from disk through here.
|
|
80
|
+
*
|
|
81
|
+
* Resolving the link is what Node itself does (`--preserve-symlinks` is off by default), which is
|
|
82
|
+
* why the same require works before packaging. `ModuleManager.locatePackageVersionFromCacheKey`
|
|
83
|
+
* and `TraversalNodeModulesCollector` already normalize this way.
|
|
84
|
+
*/
|
|
85
|
+
private toRealPackage;
|
|
59
86
|
protected extractProductionDependencyGraph(tree: PnpmDependency, dependencyId: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Resolve a dependency that `pnpm list` left out of a package's tree to its `allDependencies` entry.
|
|
89
|
+
* The lookup goes through the copy node itself would load from `parentPath` (the package's real store
|
|
90
|
+
* directory), filtered by the declared range, and falls back to a name-only match only when nothing on
|
|
91
|
+
* disk resolves to a collected entry (a `link:` dep, whose entry is keyed by its `link:` version).
|
|
92
|
+
*
|
|
93
|
+
* A name-only lookup returns whichever version was collected first, which is wrong as soon as two
|
|
94
|
+
* versions of the package are installed: with the app pinning es5-ext@0.10.53 while its transitive
|
|
95
|
+
* d@1.0.2 needs es5-ext ^0.10.64, `d` was wired to 0.10.53 and the nested 0.10.64 copy (with its own
|
|
96
|
+
* esniff / event-emitter / next-tick@1.1.0 closure) vanished from the asar (#8493). pnpm 10.29.3+
|
|
97
|
+
* made this common, because its deduped output routes every repeated package through this recovery.
|
|
98
|
+
*/
|
|
99
|
+
private resolveOmittedDependency;
|
|
60
100
|
protected collectAllDependencies(_tree: PnpmDependency, _appPackageName: string): Promise<void>;
|
|
61
101
|
/**
|
|
62
102
|
* Resolve a `link:` dependency to its real on-disk source directory — never the `node_modules`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmNodeModulesCollector.d.ts","sourceRoot":"","sources":["../../src/node-module-collector/pnpmNodeModulesCollector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAA4B,EAAE,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,YAAY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