@_linked/cli 1.43.1 → 1.44.0

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +11 -8
  3. package/lib/esm/cli.js +4 -10
  4. package/lib/esm/cli.js.map +1 -1
  5. package/lib/esm/client-dep-includes.d.ts +9 -3
  6. package/lib/esm/client-dep-includes.d.ts.map +1 -1
  7. package/lib/esm/client-dep-includes.js +10 -4
  8. package/lib/esm/client-dep-includes.js.map +1 -1
  9. package/lib/esm/commands/localize.d.ts +1 -1
  10. package/lib/esm/commands/localize.d.ts.map +1 -1
  11. package/lib/esm/commands/localize.js +15 -2
  12. package/lib/esm/commands/localize.js.map +1 -1
  13. package/lib/esm/localize/ensure.d.ts +4 -2
  14. package/lib/esm/localize/ensure.d.ts.map +1 -1
  15. package/lib/esm/localize/ensure.js +26 -41
  16. package/lib/esm/localize/ensure.js.map +1 -1
  17. package/lib/esm/localize/list.d.ts +2 -0
  18. package/lib/esm/localize/list.d.ts.map +1 -1
  19. package/lib/esm/localize/list.js +35 -1
  20. package/lib/esm/localize/list.js.map +1 -1
  21. package/lib/esm/localize/localize.d.ts.map +1 -1
  22. package/lib/esm/localize/localize.js +1 -1
  23. package/lib/esm/localize/localize.js.map +1 -1
  24. package/lib/esm/localize/manifest.d.ts +9 -0
  25. package/lib/esm/localize/manifest.d.ts.map +1 -1
  26. package/lib/esm/localize/manifest.js +2 -2
  27. package/lib/esm/localize/manifest.js.map +1 -1
  28. package/lib/esm/localize/one-copy-hook.d.ts +16 -0
  29. package/lib/esm/localize/one-copy-hook.d.ts.map +1 -0
  30. package/lib/esm/localize/one-copy-hook.js +20 -0
  31. package/lib/esm/localize/one-copy-hook.js.map +1 -0
  32. package/lib/esm/localize/prune.d.ts +115 -8
  33. package/lib/esm/localize/prune.d.ts.map +1 -1
  34. package/lib/esm/localize/prune.js +355 -126
  35. package/lib/esm/localize/prune.js.map +1 -1
  36. package/lib/esm/localize/relink.d.ts +3 -1
  37. package/lib/esm/localize/relink.d.ts.map +1 -1
  38. package/lib/esm/localize/relink.js +10 -5
  39. package/lib/esm/localize/relink.js.map +1 -1
  40. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"client-dep-includes.js","sourceRoot":"","sources":["../../src/client-dep-includes.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4EAA4E;AAC5E,6BAA6B;AAC7B,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,qEAAqE;AACrE,8EAA8E;AAC9E,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,6EAA6E;AAC7E,wEAAwE;AACxE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,IAAI,IAAI,SAAS,EAAE,KAAK,IAAI,YAAY,EAAC,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AA+DzE,wFAAwF;AACxF,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AACrE,oGAAoG;AACpG,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,SAAS;IACT,MAAM;IACN,OAAO;IACP,SAAS;IACT,aAAa;IACb,MAAM;IACN,KAAK;IACL,QAAQ;IACR,cAAc;CACf,CAAC,CAAC;AACH,4EAA4E;AAC5E,MAAM,eAAe,GACnB,uHAAuH,CAAC;AAC1H,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAA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gCACtB,CAAC,CAAC,SAAS;gCACX,CAAC,CAAC,CAAC,MAAA,IAAI,CAAC,SAAS,mCAAI,yBAAyB,CAAC,GAAG,CAAC,CAAC;yBACzD,CAAC,CAAC;wBACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAA,YAAY,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC;wBACrD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO;6BACvB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;6BACnB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;wBACnC,iBAAiB,CAAC,OAAO,GAAG;4BAC1B,GAAG;4BACH,IAAI;4BACJ,UAAU;4BACV,OAAO,EAAE,MAAA,YAAY,CAAC,OAAO,mCAAI,EAAE;yBACpC,CAAC;wBACF,IAAI,YAAY,EAAE,EAAE,CAAC;4BACnB,OAAO,CAAC,GAAG,CACT,kCAAkC,KAAK,CAAC,MAAM,oDAAoD;gCAChG,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,YAAY,SAAS;gCAC5E,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACxC,CAAC;wBACJ,CAAC;wBACD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC;oBACrE,CAAC;iBAAA;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// `optimizeDeps.include` entries for the third-party client dependencies of\n// linked framework packages.\n//\n// Apps exclude the framework packages (`@_linked/*`, `lincd-*`, anything marked\n// `\"linkedPackage\": true`) from Vite's dependency optimizer, so the browser\n// loads exactly one copy of each. The cost of that exclusion: Vite no longer\n// crawls into those packages, so it never learns about THEIR dependencies until\n// the browser happens to request one. Two things then go wrong:\n//\n// - a CommonJS dependency (`use-sync-external-store/shim`, `js-cookie`) is\n// served raw, and the browser fails on `require`/`module.exports`;\n// - any other dependency is discovered mid-session, and Vite re-optimises and\n// reloads the page — which can mix old and new chunks into two Reacts.\n//\n// So apps used to list every such dependency in `optimizeDeps.include` by hand,\n// including nested installs (`'@_linked/primitives > vaul'`, where npm put vaul\n// under primitives because its React peer range excluded the app's React).\n//\n// Reading `package.json` dependencies would list server-only packages too\n// (bcrypt, express, sharp…), which then fail in esbuild. This module reads the\n// import graph instead: which bare specifiers the framework packages' client\n// entry files actually import, and which of those can run in a browser.\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport {isBuiltin} from 'node:module';\nimport {init as initLexer, parse as parseImports} from 'es-module-lexer';\nimport {isFrameworkPkg, readInstalledPkg} from './installed-packages.js';\nimport type {Plugin} from 'vite';\n\nexport interface SourceWorkspace {\n name: string;\n srcDir: string;\n}\n\nexport interface ClientDepEntry {\n /** The `optimizeDeps.include` entry: `dep/sub` or `from > dep/sub`. */\n entry: string;\n /** The specifier as the framework package imports it. */\n specifier: string;\n /** The framework package the import was found in. */\n from: string;\n /** Package name of the dependency. */\n depName: string;\n /** Real path of the dependency's package root, as resolved from `from`. */\n depRoot: string;\n /** True when the app root does not resolve `depName` to that same copy. */\n nested: boolean;\n}\n\nexport type SkipReason =\n 'unresolved' | 'server-only' | 'server-code' | 'excluded' | 'denied';\n\nexport interface SkippedClientDep {\n specifier: string;\n from: string;\n reason: SkipReason;\n}\n\nexport interface ClientDepScanOptions {\n /** App root. Default `process.cwd()`. */\n cwd?: string;\n /** Framework packages served from source: their `src/` is scanned instead of `lib/`. */\n sourceWorkspaces?: SourceWorkspace[];\n /** Entries never to add, matched against the entry, the specifier and the package name. */\n deny?: (string | RegExp)[];\n /**\n * JSON file remembering what does not change between runs: the module graphs\n * of installed (non-source) framework packages and the server-only verdicts\n * of dependencies, keyed by real path and version. Omit to scan everything.\n */\n cacheFile?: string;\n}\n\nexport interface ScannedFrameworkPackage {\n name: string;\n root: string;\n json: any;\n source: boolean;\n}\n\nexport interface ClientDepScan {\n entries: ClientDepEntry[];\n skipped: SkippedClientDep[];\n frameworkPackages: ScannedFrameworkPackage[];\n /** Excluded names that the app root does not resolve at all. */\n unresolvedExcludes: string[];\n filesScanned: number;\n}\n\n/** Conditions a browser build resolves, in the order a client resolver prefers them. */\nconst CLIENT_CONDITIONS = ['browser', 'import', 'module', 'default'];\n/** Conditions never taken for a client file. `development` points at `src/`, scanned separately. */\nconst NON_CLIENT_CONDITIONS = new Set([\n 'require',\n 'node',\n 'types',\n 'typings',\n 'development',\n 'deno',\n 'bun',\n 'worker',\n 'react-native',\n]);\n/** Specifiers that are assets, not modules the optimizer can pre-bundle. */\nconst ASSET_SPECIFIER =\n /\\.(css|scss|sass|less|styl|pcss|svg|png|jpe?g|gif|webp|avif|ico|bmp|woff2?|ttf|otf|eot|json|wasm|html?|txt|md|glsl)$/i;\nconst SOURCE_FILE = /\\.(m?[jt]sx?|cjs)$/;\nconst IGNORED_SOURCE_FILE = /(\\.d\\.ts|\\.(test|spec|stories)\\.[mc]?[jt]sx?)$/;\nconst IGNORED_SOURCE_DIR = new Set([\n 'node_modules',\n '__tests__',\n '__mocks__',\n '__fixtures__',\n]);\n/**\n * Never listed, whoever imports them. `typescript` is a peer of packages that\n * analyse source at build time (translation key sync); it declares a `browser`\n * field, so it passes the server-only test, and pre-bundling it costs seconds.\n */\nexport const DEFAULT_DENY: (string | RegExp)[] = ['typescript'];\n/** A server-only check stops after this many files of one dependency. */\nconst MAX_DEP_FILES = 400;\n\n/** `@scope/name/sub` → `@scope/name`; `name/sub` → `name`. */\nexport function packageNameOf(specifier: string): string {\n const parts = specifier.split('/');\n return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n}\n\n/** A bare module specifier naming another package (not relative, builtin, virtual, asset or `#import`). */\nexport function isBarePackageSpecifier(specifier: string): boolean {\n if (!specifier || specifier.startsWith('.') || specifier.startsWith('/'))\n return false;\n if (specifier.startsWith('#') || specifier.startsWith('\\0')) return false;\n if (specifier.includes(':') || specifier.includes('?')) return false; // node:, virtual:, http:, ?raw\n if (isBuiltin(specifier)) return false;\n if (ASSET_SPECIFIER.test(specifier)) return false;\n return /^(@[\\w.-]+\\/)?[\\w.-]/.test(specifier);\n}\n\nconst matchesDeny = (deny: (string | RegExp)[], ...values: string[]): boolean =>\n deny.some((d) =>\n values.some((v) => (typeof d === 'string' ? d === v : d.test(v))),\n );\n\nasync function realpath(p: string): Promise<string> {\n try {\n return await fs.realpath(p);\n } catch {\n return path.resolve(p);\n }\n}\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await fs.stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\nasync function listFiles(\n dir: string,\n accept: (file: string) => boolean,\n): Promise<string[]> {\n const out: string[] = [];\n const walk = async (d: string): Promise<void> => {\n let entries;\n try {\n entries = await fs.readdir(d, {withFileTypes: true});\n } catch {\n return;\n }\n await Promise.all(\n entries.map(async (ent) => {\n const full = path.join(d, ent.name);\n if (ent.isDirectory()) {\n if (!IGNORED_SOURCE_DIR.has(ent.name)) await walk(full);\n } else if (accept(full)) {\n out.push(full);\n }\n }),\n );\n };\n await walk(dir);\n return out;\n}\n\n/** Pick the target of one export entry for the given conditions (nested condition objects allowed). */\nfunction pickConditional(target: any, conditions: string[]): string | null {\n if (typeof target === 'string') return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = pickConditional(t, conditions);\n if (hit) return hit;\n }\n return null;\n }\n if (target && typeof target === 'object') {\n for (const [key, value] of Object.entries(target)) {\n if (key === 'default' || conditions.includes(key)) {\n const hit = pickConditional(value, conditions);\n if (hit) return hit;\n }\n }\n }\n return null;\n}\n\n/** Normalise `exports` to a subpath map (`{'.': …}`), or null when there is none. */\nfunction exportsMap(exportsField: any): Record<string, any> | null {\n if (exportsField === undefined || exportsField === null) return null;\n if (typeof exportsField === 'string' || Array.isArray(exportsField))\n return {'.': exportsField};\n const keys = Object.keys(exportsField);\n if (keys.length > 0 && keys.every((k) => !k.startsWith('.')))\n return {'.': exportsField};\n return exportsField;\n}\n\n/**\n * Resolve a package subpath (`.` or `./shim`) through `exports` for the given\n * conditions, the way Node does (exact key first, then the longest `*` pattern).\n * Returns the relative target, `null` when the subpath is not exported, or\n * `undefined` when the package has no `exports` at all.\n */\nexport function resolveExportsSubpath(\n json: any,\n subpath: string,\n conditions: string[],\n): string | null | undefined {\n const map = exportsMap(json?.exports);\n if (!map) return undefined;\n if (subpath in map) return pickConditional(map[subpath], conditions);\n let best: {key: string; star: string} | null = null;\n for (const key of Object.keys(map)) {\n const star = key.indexOf('*');\n if (star < 0) continue;\n const prefix = key.slice(0, star);\n const suffix = key.slice(star + 1);\n if (\n subpath.startsWith(prefix) &&\n subpath.endsWith(suffix) &&\n subpath.length >= key.length - 1 &&\n (!best || prefix.length > best.key.indexOf('*'))\n ) {\n best = {\n key,\n star: subpath.slice(prefix.length, subpath.length - suffix.length),\n };\n }\n }\n if (!best) return null;\n const target = pickConditional(map[best.key], conditions);\n return target ? target.split('*').join(best.star) : null;\n}\n\n/** Probe a file path the way a CommonJS/ESM loader would (extension, then directory index). */\nasync function probeFile(base: string): Promise<string | null> {\n for (const candidate of [\n base,\n `${base}.js`,\n `${base}.mjs`,\n `${base}.cjs`,\n path.join(base, 'index.js'),\n path.join(base, 'index.mjs'),\n ]) {\n if (await isFile(candidate)) return candidate;\n }\n return null;\n}\n\n/** The file a package subpath resolves to for a browser-or-anything lookup; null when none exists. */\nexport async function resolvePackageFile(\n root: string,\n json: any,\n subpath: string,\n conditions: string[] = [\n 'browser',\n 'import',\n 'module',\n 'default',\n 'require',\n 'node',\n ],\n): Promise<string | null> {\n const viaExports = resolveExportsSubpath(json, subpath, conditions);\n if (viaExports !== undefined) {\n return viaExports ? probeFile(path.join(root, viaExports)) : null;\n }\n if (subpath === '.') {\n const browser =\n conditions.includes('browser') &&\n typeof json.browser === 'string' &&\n json.browser;\n const main = browser || json.module || json.main || 'index.js';\n return probeFile(path.join(root, main));\n }\n return probeFile(path.join(root, subpath));\n}\n\n/** Every string target under client conditions, anywhere in `exports`. */\nfunction clientExportTargets(json: any): string[] {\n const map = exportsMap(json?.exports);\n if (!map) {\n const main =\n (typeof json?.browser === 'string' && json.browser) ||\n json?.module ||\n json?.main ||\n 'index.js';\n return [main];\n }\n const out: string[] = [];\n const visit = (target: any): void => {\n if (typeof target === 'string') out.push(target);\n else if (Array.isArray(target)) target.forEach(visit);\n else if (target && typeof target === 'object') {\n for (const [key, value] of Object.entries(target)) {\n if (!NON_CLIENT_CONDITIONS.has(key)) visit(value);\n }\n }\n };\n Object.values(map).forEach(visit);\n return out;\n}\n\n/** Expand one export target (possibly a `*` pattern) to the files it can reach. */\nasync function expandTarget(root: string, target: string): Promise<string[]> {\n const abs = path.join(root, target);\n const star = abs.indexOf('*');\n if (star < 0) {\n const file = await probeFile(abs);\n return file ? [file] : [];\n }\n const prefix = abs.slice(0, star);\n const suffix = abs.slice(star + 1);\n const dir = prefix.endsWith(path.sep) ? prefix : path.dirname(prefix);\n return listFiles(\n dir,\n (f) => f.startsWith(prefix) && f.endsWith(suffix) && !f.endsWith('.d.ts'),\n );\n}\n\nlet lexerReady: Promise<void> | null = null;\nlet esbuildTransform:\n ((code: string, opts: any) => Promise<{code: string}>) | null = null;\n\n/** The static and literal-dynamic import specifiers of a module, plus `require('x')` calls. */\nexport async function importSpecifiers(\n code: string,\n file: string,\n): Promise<string[]> {\n lexerReady ??= initLexer;\n await lexerReady;\n let js = code;\n if (/\\.[mc]?tsx?$/.test(file) || /\\.jsx$/.test(file)) {\n esbuildTransform ??= (await import('esbuild')).transform as any;\n try {\n js = (\n await esbuildTransform!(code, {\n loader: file.endsWith('x')\n ? /\\.tsx$/.test(file)\n ? 'tsx'\n : 'jsx'\n : 'ts',\n format: 'esm',\n jsx: 'automatic',\n tsconfigRaw: {compilerOptions: {experimentalDecorators: true}},\n logLevel: 'silent',\n })\n ).code;\n } catch {\n return [];\n }\n }\n const out = new Set<string>();\n try {\n const [imports] = parseImports(js);\n for (const imp of imports) if (imp.n) out.add(imp.n);\n } catch {\n // Not parseable as a module (JSX in a .js file, say): fall back to the textual forms.\n for (const m of js.matchAll(\n /(?:\\bfrom\\s*|\\bimport\\s*\\(?\\s*)['\"]([^'\"\\n]+)['\"]/g,\n ))\n out.add(m[1]);\n }\n for (const m of js.matchAll(/\\brequire\\s*\\(\\s*['\"]([^'\"\\n]+)['\"]\\s*\\)/g))\n out.add(m[1]);\n return [...out];\n}\n\ninterface ScanCacheData {\n version: number;\n graphs: Record<string, Record<string, {bare: string[]; rel: string[]}>>;\n serverOnly: Record<string, boolean>;\n}\nconst CACHE_VERSION = 1;\n\nasync function loadCache(\n file: string | undefined,\n): Promise<{data: ScanCacheData; dirty: boolean}> {\n const empty = {\n data: {version: CACHE_VERSION, graphs: {}, serverOnly: {}},\n dirty: false,\n };\n if (!file) return empty;\n try {\n const data = JSON.parse(await fs.readFile(file, 'utf8'));\n return data?.version === CACHE_VERSION && data.graphs && data.serverOnly\n ? {data, dirty: false}\n : empty;\n } catch {\n return empty;\n }\n}\n\nasync function saveCache(\n file: string | undefined,\n cache: {data: ScanCacheData; dirty: boolean},\n): Promise<void> {\n if (!file || !cache.dirty) return;\n try {\n await fs.mkdir(path.dirname(file), {recursive: true});\n const tmp = `${file}.${process.pid}.tmp`;\n await fs.writeFile(tmp, JSON.stringify(cache.data));\n await fs.rename(tmp, file);\n } catch {\n // A cache is an optimisation: an unwritable node_modules just means a full scan next time.\n }\n}\n\n/** Limit concurrent file reads: a few hundred open at once can exceed the fd limit. */\nfunction semaphore(limit: number): <T>(fn: () => Promise<T>) => Promise<T> {\n let active = 0;\n const waiting: (() => void)[] = [];\n return async (fn) => {\n if (active >= limit) await new Promise<void>((r) => waiting.push(r));\n active++;\n try {\n return await fn();\n } finally {\n active--;\n waiting.shift()?.();\n }\n };\n}\n\n/** Resolve a relative import to a module file, including the TS-source `./Sibling.js` → `.ts(x)` convention. */\nasync function resolveRelative(\n importer: string,\n specifier: string,\n): Promise<string | null> {\n if (ASSET_SPECIFIER.test(specifier)) return null;\n const base = path.resolve(path.dirname(importer), specifier);\n const candidates: string[] = [];\n if (/\\.[mc]?tsx?$/.test(importer) && /\\.jsx?$/.test(base)) {\n candidates.push(\n base.replace(/\\.jsx?$/, '.ts'),\n base.replace(/\\.jsx?$/, '.tsx'),\n );\n }\n candidates.push(base);\n for (const ext of ['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx'])\n candidates.push(base + ext);\n for (const ext of ['.js', '.mjs', '.ts', '.tsx'])\n candidates.push(path.join(base, 'index' + ext));\n for (const c of candidates) {\n if (SOURCE_FILE.test(c) && (await isFile(c))) return c;\n }\n return null;\n}\n\nexport interface ModuleNode {\n file: string;\n /** Bare specifiers the module imports (packages and builtins). */\n bare: string[];\n /** Module files it imports relatively. */\n rel: string[];\n}\n\ninterface ReadGraphOptions {\n maxFiles?: number;\n /** Also follow a bare import: return the file it resolves to, or null to not follow it. */\n followBare?: (specifier: string, importer: string) => Promise<string | null>;\n /** Stop reading once this returns true for a node. */\n stopWhen?: (node: ModuleNode) => boolean;\n}\n\nconst readLimit = semaphore(64);\n\n/** Read the module graph reachable from `entries` through relative imports (and `followBare`). */\nasync function readGraph(\n entries: string[],\n opts: ReadGraphOptions = {},\n): Promise<Map<string, ModuleNode>> {\n const nodes = new Map<string, ModuleNode>();\n const maxFiles = opts.maxFiles ?? Infinity;\n let stopped = false;\n const visit = async (file: string): Promise<void> => {\n if (stopped || nodes.has(file) || nodes.size >= maxFiles) return;\n const node: ModuleNode = {file, bare: [], rel: []};\n nodes.set(file, node);\n const specs = await readLimit(async () => {\n try {\n return await importSpecifiers(await fs.readFile(file, 'utf8'), file);\n } catch {\n return [];\n }\n });\n const children: (string | null)[] = await Promise.all(\n specs.map(async (spec) => {\n if (spec.startsWith('.') || spec.startsWith('/')) {\n const resolved = await resolveRelative(file, spec);\n if (resolved) node.rel.push(resolved);\n return resolved;\n }\n node.bare.push(spec);\n return opts.followBare ? opts.followBare(spec, file) : null;\n }),\n );\n if (opts.stopWhen?.(node)) {\n stopped = true;\n return;\n }\n await Promise.all(children.filter((c): c is string => !!c).map(visit));\n };\n await Promise.all(entries.map(visit));\n return nodes;\n}\n\n/** True when the package declares a browser entry anywhere (`browser` field or condition). */\nfunction hasBrowserEntry(json: any): boolean {\n if (json?.browser) return true;\n let found = false;\n const visit = (v: any): void => {\n if (found || !v || typeof v !== 'object') return;\n for (const [key, value] of Object.entries(v)) {\n if (key === 'browser') found = true;\n else visit(value);\n }\n };\n visit(json?.exports);\n return found;\n}\n\nconst isBuiltinSpecifier = (spec: string): boolean =>\n spec.startsWith('node:') || isBuiltin(spec);\nconst subpathOf = (specifier: string): string => {\n const name = packageNameOf(specifier);\n return specifier === name ? '.' : `.${specifier.slice(name.length)}`;\n};\nconst NODE_CONDITIONS = ['import', 'module', 'default', 'require', 'node'];\n\ntype InstalledLookup = (\n name: string,\n fromDir: string,\n) => Promise<{root: string; json: any} | null>;\n\n/** `readInstalledPkg`, memoised for one scan. */\nfunction memoInstalled(): InstalledLookup {\n const cache = new Map<string, Promise<{root: string; json: any} | null>>();\n return (name, fromDir) => {\n const key = `${name}\\0${fromDir}`;\n if (!cache.has(key)) cache.set(key, readInstalledPkg(name, fromDir));\n return cache.get(key)!;\n };\n}\n\n/**\n * Server-only: no browser entry, and the module graph behind the imported\n * subpath — followed through its own dependencies, as long as those have no\n * browser entry either — reaches a Node builtin. Such a package (express,\n * sharp, bcrypt, jsonwebtoken, cookie-parser) serves a framework package's\n * server code; listing it would make esbuild bundle it for the browser.\n */\nexport async function isServerOnlyDependency(\n root: string,\n json: any,\n subpath: string,\n lookup: InstalledLookup = readInstalledPkg,\n): Promise<boolean> {\n if (hasBrowserEntry(json)) return false;\n const entry = await resolvePackageFile(root, json, subpath, NODE_CONDITIONS);\n if (!entry) return false;\n let builtin = false;\n await readGraph([entry], {\n maxFiles: MAX_DEP_FILES,\n followBare: async (spec, importer) => {\n if (!isBarePackageSpecifier(spec)) return null;\n const dep = await lookup(packageNameOf(spec), path.dirname(importer));\n if (!dep || hasBrowserEntry(dep.json)) return null;\n return resolvePackageFile(\n dep.root,\n dep.json,\n subpathOf(spec),\n NODE_CONDITIONS,\n );\n },\n stopWhen: (node) =>\n (builtin = builtin || node.bare.some(isBuiltinSpecifier)),\n });\n return builtin;\n}\n\n/** The files a framework package's client code can start from. */\nasync function clientEntryFiles(\n pkg: ScannedFrameworkPackage,\n): Promise<string[]> {\n if (pkg.source) {\n return listFiles(\n path.join(pkg.root, 'src'),\n (f) => SOURCE_FILE.test(f) && !IGNORED_SOURCE_FILE.test(f),\n );\n }\n return (\n await Promise.all(\n clientExportTargets(pkg.json).map((t) => expandTarget(pkg.root, t)),\n )\n ).flat();\n}\n\ninterface DepVerdict {\n reason?: 'unresolved' | 'server-only';\n depName: string;\n depRoot?: string;\n}\n\n/**\n * Scan the framework packages among `excluded` for the third-party\n * dependencies their client code imports, and work out the\n * `optimizeDeps.include` entry for each.\n *\n * Framework packages export whole directories (`\"./*\": \"./lib/esm/*.js\"`), so\n * \"reachable from the client exports\" is every file — server code included. A\n * file is therefore treated as SERVER code when it imports a Node builtin or a\n * server-only dependency, or relatively imports a file that does; only the\n * imports of the remaining files are listed.\n */\nexport async function scanLinkedClientDeps(\n excluded: string[],\n opts: ClientDepScanOptions = {},\n): Promise<ClientDepScan> {\n const cwd = path.resolve(opts.cwd ?? process.cwd());\n const deny = [...DEFAULT_DENY, ...(opts.deny ?? [])];\n const excludedSet = new Set(excluded);\n const sourceByName = new Map(\n (opts.sourceWorkspaces ?? []).map((w) => [w.name, w]),\n );\n const lookup = memoInstalled();\n const cache = await loadCache(opts.cacheFile);\n const unresolvedExcludes: string[] = [];\n\n // 1. The excluded packages to scan: every source workspace (Vite does not crawl\n // an excluded package, whatever it is), and the installed framework packages.\n // A package with a `bin` is a command-line tool (`@_linked/cli`), whose code\n // no browser loads; scanning it would only list build tooling.\n const frameworkPackages = (\n await Promise.all(\n [...excludedSet].map(\n async (name): Promise<ScannedFrameworkPackage | null> => {\n const ws = sourceByName.get(name);\n if (ws) {\n const root = await realpath(path.dirname(ws.srcDir));\n let json: any = {};\n try {\n json = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf8'),\n );\n } catch {}\n return {name, root, json, source: true};\n }\n const installed = await lookup(name, cwd);\n if (!installed) {\n unresolvedExcludes.push(name);\n return null;\n }\n if (!isFrameworkPkg(name) && installed.json.linkedPackage !== true)\n return null;\n return {\n name,\n root: await realpath(installed.root),\n json: installed.json,\n source: false,\n };\n },\n ),\n )\n ).filter((p): p is ScannedFrameworkPackage => !!p && !p.json?.bin);\n\n // 2. Each package's module graph.\n const owner = new Map<string, ScannedFrameworkPackage>();\n const nodes = new Map<string, ModuleNode>();\n await Promise.all(\n frameworkPackages.map(async (pkg) => {\n const cacheKey = pkg.source ? null : `${pkg.root}\\0${pkg.json.version}`;\n let graph: Map<string, ModuleNode>;\n if (cacheKey && cache.data.graphs[cacheKey]) {\n graph = new Map(\n Object.entries(cache.data.graphs[cacheKey]).map(([file, n]) => [\n file,\n {file, ...n},\n ]),\n );\n } else {\n graph = await readGraph(await clientEntryFiles(pkg));\n if (cacheKey) {\n cache.data.graphs[cacheKey] = Object.fromEntries(\n [...graph].map(([file, n]) => [file, {bare: n.bare, rel: n.rel}]),\n );\n cache.dirty = true;\n }\n }\n for (const [file, node] of graph) {\n if (nodes.has(file)) continue;\n nodes.set(file, node);\n owner.set(file, pkg);\n }\n }),\n );\n\n // 3. A verdict for every (package, dependency specifier) pair.\n const verdicts = new Map<string, Promise<DepVerdict | null>>();\n const serverOnly = new Map<string, Promise<boolean>>();\n const pairKey = (pkg: ScannedFrameworkPackage, spec: string): string =>\n `${pkg.name}\\0${spec}`;\n const verdictFor = (\n pkg: ScannedFrameworkPackage,\n spec: string,\n ): Promise<DepVerdict | null> => {\n const key = pairKey(pkg, spec);\n if (!verdicts.has(key)) {\n verdicts.set(\n key,\n (async (): Promise<DepVerdict | null> => {\n if (!isBarePackageSpecifier(spec)) return null;\n const depName = packageNameOf(spec);\n if (depName === pkg.name || isFrameworkPkg(depName)) return null;\n const installed = await lookup(depName, pkg.root);\n if (!installed) return {reason: 'unresolved', depName};\n if (installed.json.linkedPackage === true) return null;\n const depRoot = await realpath(installed.root);\n const cacheKey = `${depRoot}\\0${subpathOf(spec)}`;\n if (!serverOnly.has(cacheKey)) {\n const persisted = `${cacheKey}\\0${installed.json.version}`;\n serverOnly.set(\n cacheKey,\n persisted in cache.data.serverOnly\n ? Promise.resolve(cache.data.serverOnly[persisted])\n : isServerOnlyDependency(\n depRoot,\n installed.json,\n subpathOf(spec),\n lookup,\n ).then((v) => {\n cache.data.serverOnly[persisted] = v;\n cache.dirty = true;\n return v;\n }),\n );\n }\n return {\n reason: (await serverOnly.get(cacheKey))\n ? 'server-only'\n : undefined,\n depName,\n depRoot,\n };\n })(),\n );\n }\n return verdicts.get(key)!;\n };\n await Promise.all(\n [...nodes.values()].flatMap((n) =>\n n.bare.map((spec) => verdictFor(owner.get(n.file)!, spec)),\n ),\n );\n\n // 4. Server code: files importing a builtin or a server-only dependency, and\n // every file that relatively imports one of those.\n const server = new Set<string>();\n const importers = new Map<string, string[]>();\n for (const node of nodes.values()) {\n for (const dep of node.rel) {\n if (!importers.has(dep)) importers.set(dep, []);\n importers.get(dep)!.push(node.file);\n }\n }\n const queue: string[] = [];\n for (const node of nodes.values()) {\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) {\n if (\n isBuiltinSpecifier(spec) ||\n (await verdicts.get(pairKey(pkg, spec)))?.reason === 'server-only'\n ) {\n server.add(node.file);\n queue.push(node.file);\n break;\n }\n }\n }\n while (queue.length) {\n for (const parent of importers.get(queue.pop()!) ?? []) {\n if (!server.has(parent)) {\n server.add(parent);\n queue.push(parent);\n }\n }\n }\n\n // 5. Entries from client files; everything else is reported as skipped.\n const rootCopy = new Map<string, Promise<string | null>>();\n const rootResolution = (depName: string): Promise<string | null> => {\n if (!rootCopy.has(depName)) {\n rootCopy.set(\n depName,\n lookup(depName, cwd).then((r) => (r ? realpath(r.root) : null)),\n );\n }\n return rootCopy.get(depName)!;\n };\n const entries = new Map<string, ClientDepEntry>();\n const clientPairs = new Set<string>();\n const skipped = new Map<string, SkippedClientDep>();\n const skip = (specifier: string, from: string, reason: SkipReason): void => {\n skipped.set(`${specifier}\\0${from}`, {specifier, from, reason});\n };\n for (const node of nodes.values()) {\n if (server.has(node.file)) continue;\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) clientPairs.add(pairKey(pkg, spec));\n }\n for (const node of nodes.values()) {\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) {\n const key = pairKey(pkg, spec);\n const verdict = await verdicts.get(key);\n if (!verdict) continue;\n if (verdict.reason) {\n skip(spec, pkg.name, verdict.reason);\n continue;\n }\n if (!clientPairs.has(key)) {\n if (!skipped.has(`${spec}\\0${pkg.name}`))\n skip(spec, pkg.name, 'server-code');\n continue;\n }\n if (excludedSet.has(verdict.depName) || excludedSet.has(spec)) {\n skip(spec, pkg.name, 'excluded');\n continue;\n }\n const nested =\n (await rootResolution(verdict.depName)) !== verdict.depRoot;\n const entry = nested ? `${pkg.name} > ${spec}` : spec;\n if (matchesDeny(deny, entry, spec, verdict.depName)) {\n skip(spec, pkg.name, 'denied');\n continue;\n }\n if (!entries.has(entry)) {\n entries.set(entry, {\n entry,\n specifier: spec,\n from: pkg.name,\n depName: verdict.depName,\n depRoot: verdict.depRoot!,\n nested,\n });\n }\n }\n }\n for (const {specifier, from} of entries.values())\n skipped.delete(`${specifier}\\0${from}`);\n await saveCache(opts.cacheFile, cache);\n\n return {\n entries: [...entries.values()].sort((a, b) =>\n a.entry.localeCompare(b.entry),\n ),\n skipped: [...skipped.values()].sort(\n (a, b) =>\n a.specifier.localeCompare(b.specifier) || a.from.localeCompare(b.from),\n ),\n frameworkPackages,\n unresolvedExcludes,\n filesScanned: nodes.size,\n };\n}\n\n/** Just the entries, for `optimizeDeps.include`. */\nexport async function linkedClientDepIncludes(\n excluded: string[],\n opts: ClientDepScanOptions = {},\n): Promise<string[]> {\n return (await scanLinkedClientDeps(excluded, opts)).entries.map(\n (e) => e.entry,\n );\n}\n\nexport interface RecordedClientDepScan {\n cwd: string;\n scan: ClientDepScan;\n /** The app's own `optimizeDeps.include`, before anything was added. */\n appInclude: string[];\n exclude: string[];\n}\n\n/**\n * The most recent scan the plugin ran in this process, with the app's own\n * include list — `linked app-doctor` loads the app's config and reads this, so it\n * checks exactly what the dev server would use.\n */\nexport const lastClientDepScan: {current: RecordedClientDepScan | null} = ((\n globalThis as any\n)[Symbol.for('@_linked/cli.lastClientDepScan')] ??= {current: null});\n\nexport interface ClientDepIncludesPluginOptions {\n /** Framework packages served from source (the discovered workspaces). */\n sourceWorkspaces?: SourceWorkspace[];\n /** Entries never to add. See `ClientDepScanOptions.deny`. */\n deny?: (string | RegExp)[];\n /** Override the scan cache location; `false` disables the cache. */\n cacheFile?: string | false;\n}\n\n/** Where the scan cache lives: beside Vite's own cache, inside the app's node_modules. */\nexport const defaultClientDepCacheFile = (cwd: string): string =>\n path.join(cwd, 'node_modules', '.cache', 'linked', 'client-deps.json');\n\nconst debugEnabled = (): boolean =>\n /(^|[\\s,])(linked(:[\\w*]+)?|\\*)($|[\\s,])/.test(process.env.DEBUG ?? '');\n\n/**\n * Adds the scan's entries to `optimizeDeps.include` in dev.\n *\n * It is a `config` hook ordered `post` rather than a value computed inside\n * `createViteConfig`, because the exclude list it reads is only final once the\n * app has merged its own config on top — an app that excludes every installed\n * `@_linked/*` package does that in its own `vite.config.ts`. Vite concatenates\n * the returned array onto the app's own `include`, which is never replaced.\n */\nexport function linkedClientDepIncludesPlugin(\n opts: ClientDepIncludesPluginOptions = {},\n): Plugin[] {\n // What the app itself lists, before other plugins add theirs\n // (@vitejs/plugin-react adds `react`, `react/jsx-runtime`…): `linked app-doctor`\n // must not tell anyone to delete an entry they never wrote.\n let appInclude: string[] = [];\n const snapshot: Plugin = {\n name: 'linked:client-dep-includes:app-include',\n apply: 'serve',\n config: {\n order: 'pre',\n handler(userConfig) {\n appInclude = [...(userConfig.optimizeDeps?.include ?? [])];\n },\n },\n };\n return [\n snapshot,\n {\n name: 'linked:client-dep-includes',\n apply: 'serve',\n config: {\n order: 'post',\n async handler(userConfig) {\n const optimizeDeps = userConfig.optimizeDeps ?? {};\n // `linked start --api-only` has no browser client to optimise for.\n if (optimizeDeps.noDiscovery) return;\n const cwd = path.resolve(userConfig.root ?? process.cwd());\n const started = performance.now();\n const scan = await scanLinkedClientDeps(optimizeDeps.exclude ?? [], {\n cwd,\n sourceWorkspaces: opts.sourceWorkspaces,\n deny: opts.deny,\n cacheFile:\n opts.cacheFile === false\n ? undefined\n : (opts.cacheFile ?? defaultClientDepCacheFile(cwd)),\n });\n const existing = new Set(optimizeDeps.include ?? []);\n const added = scan.entries\n .map((e) => e.entry)\n .filter((e) => !existing.has(e));\n lastClientDepScan.current = {\n cwd,\n scan,\n appInclude,\n exclude: optimizeDeps.exclude ?? [],\n };\n if (debugEnabled()) {\n console.log(\n `[linked] optimizeDeps.include: ${added.length} entries for linked packages' client dependencies ` +\n `(${Math.round(performance.now() - started)}ms, ${scan.filesScanned} files)` +\n added.map((e) => `\\n ${e}`).join(''),\n );\n }\n return added.length ? {optimizeDeps: {include: added}} : undefined;\n },\n },\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"client-dep-includes.js","sourceRoot":"","sources":["../../src/client-dep-includes.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,4EAA4E;AAC5E,6BAA6B;AAC7B,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,6EAA6E;AAC7E,gFAAgF;AAChF,gEAAgE;AAChE,EAAE;AACF,2EAA2E;AAC3E,q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C,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;wBACnC,iBAAiB,CAAC,OAAO,GAAG;4BAC1B,GAAG;4BACH,IAAI;4BACJ,UAAU;4BACV,OAAO,EAAE,MAAA,YAAY,CAAC,OAAO,mCAAI,EAAE;yBACpC,CAAC;wBACF,IAAI,YAAY,EAAE,EAAE,CAAC;4BACnB,OAAO,CAAC,GAAG,CACT,kCAAkC,KAAK,CAAC,MAAM,oDAAoD;gCAChG,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,YAAY,SAAS;gCAC5E,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACxC,CAAC;wBACJ,CAAC;wBACD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAC,YAAY,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC;oBACrE,CAAC;iBAAA;aACF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["// `optimizeDeps.include` entries for the third-party client dependencies of\n// linked framework packages.\n//\n// Apps exclude the framework packages (`@_linked/*`, `lincd-*`, anything marked\n// `\"linkedPackage\": true`) from Vite's dependency optimizer, so the browser\n// loads exactly one copy of each. The cost of that exclusion: Vite no longer\n// crawls into those packages, so it never learns about THEIR dependencies until\n// the browser happens to request one. Two things then go wrong:\n//\n// - a CommonJS dependency (`use-sync-external-store/shim`, `js-cookie`) is\n// served raw, and the browser fails on `require`/`module.exports`;\n// - any other dependency is discovered mid-session, and Vite re-optimises and\n// reloads the page — which can mix old and new chunks into two Reacts.\n//\n// So apps used to list every such dependency in `optimizeDeps.include` by hand,\n// including nested installs (`'@_linked/primitives > vaul'`, where npm put vaul\n// under primitives because its React peer range excluded the app's React).\n//\n// Reading `package.json` dependencies would list server-only packages too\n// (bcrypt, express, sharp…), which then fail in esbuild. This module reads the\n// import graph instead: which bare specifiers the framework packages' client\n// entry files actually import, and which of those can run in a browser.\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport {isBuiltin} from 'node:module';\nimport {init as initLexer, parse as parseImports} from 'es-module-lexer';\nimport {isFrameworkPkg, readInstalledPkg} from './installed-packages.js';\nimport type {Plugin} from 'vite';\n\nexport interface SourceWorkspace {\n name: string;\n srcDir: string;\n}\n\nexport interface ClientDepEntry {\n /** The `optimizeDeps.include` entry: `dep/sub` or `from > dep/sub`. */\n entry: string;\n /** The specifier as the framework package imports it. */\n specifier: string;\n /** The framework package the import was found in. */\n from: string;\n /** Package name of the dependency. */\n depName: string;\n /** Real path of the dependency's package root, as resolved from `from`. */\n depRoot: string;\n /** True when the app root does not resolve `depName` to that same copy. */\n nested: boolean;\n}\n\nexport type SkipReason =\n 'unresolved' | 'server-only' | 'server-code' | 'excluded' | 'denied';\n\nexport interface SkippedClientDep {\n specifier: string;\n from: string;\n reason: SkipReason;\n}\n\nexport interface ClientDepScanOptions {\n /** App root. Default `process.cwd()`. */\n cwd?: string;\n /** Framework packages served from source: their `src/` is scanned instead of `lib/`. */\n sourceWorkspaces?: SourceWorkspace[];\n /** Entries never to add, matched against the entry, the specifier and the package name. */\n deny?: (string | RegExp)[];\n /**\n * JSON file remembering what does not change between runs: the module graphs\n * of installed (non-source) framework packages and the server-only verdicts\n * of dependencies, keyed by real path and version. Omit to scan everything.\n */\n cacheFile?: string;\n}\n\nexport interface ScannedFrameworkPackage {\n name: string;\n root: string;\n json: any;\n source: boolean;\n}\n\nexport interface ClientDepScan {\n entries: ClientDepEntry[];\n skipped: SkippedClientDep[];\n frameworkPackages: ScannedFrameworkPackage[];\n /** Excluded names that the app root does not resolve at all. */\n unresolvedExcludes: string[];\n filesScanned: number;\n}\n\n/** Conditions a browser build resolves, in the order a client resolver prefers them. */\nconst CLIENT_CONDITIONS = ['browser', 'import', 'module', 'default'];\n/** Conditions never taken for a client file. `development` points at `src/`, scanned separately. */\nconst NON_CLIENT_CONDITIONS = new Set([\n 'require',\n 'node',\n 'types',\n 'typings',\n 'development',\n 'deno',\n 'bun',\n 'worker',\n 'react-native',\n]);\n/** Specifiers that are assets, not modules the optimizer can pre-bundle. */\nconst ASSET_SPECIFIER =\n /\\.(css|scss|sass|less|styl|pcss|svg|png|jpe?g|gif|webp|avif|ico|bmp|woff2?|ttf|otf|eot|json|wasm|html?|txt|md|glsl)$/i;\nconst SOURCE_FILE = /\\.(m?[jt]sx?|cjs)$/;\nconst IGNORED_SOURCE_FILE = /(\\.d\\.ts|\\.(test|spec|stories)\\.[mc]?[jt]sx?)$/;\nconst IGNORED_SOURCE_DIR = new Set([\n 'node_modules',\n '__tests__',\n '__mocks__',\n '__fixtures__',\n]);\n/**\n * Never listed, whoever imports them.\n *\n * - `typescript` is a peer of packages that analyse source at build time\n * (translation key sync); it declares a `browser` field, so it passes the\n * server-only test, and pre-bundling it costs seconds.\n * - `react-native` reaches the scan from a package with a native entry whose\n * own install carries it (a localized checkout's devDependencies). A web\n * build never loads it, and its published source is Flow, which esbuild\n * cannot parse: listing it fails the dev server's dependency optimizer.\n */\nexport const DEFAULT_DENY: (string | RegExp)[] = ['typescript', 'react-native'];\n/** A server-only check stops after this many files of one dependency. */\nconst MAX_DEP_FILES = 400;\n\n/** `@scope/name/sub` → `@scope/name`; `name/sub` → `name`. */\nexport function packageNameOf(specifier: string): string {\n const parts = specifier.split('/');\n return specifier.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n}\n\n/** A bare module specifier naming another package (not relative, builtin, virtual, asset or `#import`). */\nexport function isBarePackageSpecifier(specifier: string): boolean {\n if (!specifier || specifier.startsWith('.') || specifier.startsWith('/'))\n return false;\n if (specifier.startsWith('#') || specifier.startsWith('\\0')) return false;\n if (specifier.includes(':') || specifier.includes('?')) return false; // node:, virtual:, http:, ?raw\n if (isBuiltin(specifier)) return false;\n if (ASSET_SPECIFIER.test(specifier)) return false;\n return /^(@[\\w.-]+\\/)?[\\w.-]/.test(specifier);\n}\n\nconst matchesDeny = (deny: (string | RegExp)[], ...values: string[]): boolean =>\n deny.some((d) =>\n values.some((v) => (typeof d === 'string' ? d === v : d.test(v))),\n );\n\nasync function realpath(p: string): Promise<string> {\n try {\n return await fs.realpath(p);\n } catch {\n return path.resolve(p);\n }\n}\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await fs.stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\nasync function listFiles(\n dir: string,\n accept: (file: string) => boolean,\n): Promise<string[]> {\n const out: string[] = [];\n const walk = async (d: string): Promise<void> => {\n let entries;\n try {\n entries = await fs.readdir(d, {withFileTypes: true});\n } catch {\n return;\n }\n await Promise.all(\n entries.map(async (ent) => {\n const full = path.join(d, ent.name);\n if (ent.isDirectory()) {\n if (!IGNORED_SOURCE_DIR.has(ent.name)) await walk(full);\n } else if (accept(full)) {\n out.push(full);\n }\n }),\n );\n };\n await walk(dir);\n return out;\n}\n\n/** Pick the target of one export entry for the given conditions (nested condition objects allowed). */\nfunction pickConditional(target: any, conditions: string[]): string | null {\n if (typeof target === 'string') return target;\n if (Array.isArray(target)) {\n for (const t of target) {\n const hit = pickConditional(t, conditions);\n if (hit) return hit;\n }\n return null;\n }\n if (target && typeof target === 'object') {\n for (const [key, value] of Object.entries(target)) {\n if (key === 'default' || conditions.includes(key)) {\n const hit = pickConditional(value, conditions);\n if (hit) return hit;\n }\n }\n }\n return null;\n}\n\n/** Normalise `exports` to a subpath map (`{'.': …}`), or null when there is none. */\nfunction exportsMap(exportsField: any): Record<string, any> | null {\n if (exportsField === undefined || exportsField === null) return null;\n if (typeof exportsField === 'string' || Array.isArray(exportsField))\n return {'.': exportsField};\n const keys = Object.keys(exportsField);\n if (keys.length > 0 && keys.every((k) => !k.startsWith('.')))\n return {'.': exportsField};\n return exportsField;\n}\n\n/**\n * Resolve a package subpath (`.` or `./shim`) through `exports` for the given\n * conditions, the way Node does (exact key first, then the longest `*` pattern).\n * Returns the relative target, `null` when the subpath is not exported, or\n * `undefined` when the package has no `exports` at all.\n */\nexport function resolveExportsSubpath(\n json: any,\n subpath: string,\n conditions: string[],\n): string | null | undefined {\n const map = exportsMap(json?.exports);\n if (!map) return undefined;\n if (subpath in map) return pickConditional(map[subpath], conditions);\n let best: {key: string; star: string} | null = null;\n for (const key of Object.keys(map)) {\n const star = key.indexOf('*');\n if (star < 0) continue;\n const prefix = key.slice(0, star);\n const suffix = key.slice(star + 1);\n if (\n subpath.startsWith(prefix) &&\n subpath.endsWith(suffix) &&\n subpath.length >= key.length - 1 &&\n (!best || prefix.length > best.key.indexOf('*'))\n ) {\n best = {\n key,\n star: subpath.slice(prefix.length, subpath.length - suffix.length),\n };\n }\n }\n if (!best) return null;\n const target = pickConditional(map[best.key], conditions);\n return target ? target.split('*').join(best.star) : null;\n}\n\n/** Probe a file path the way a CommonJS/ESM loader would (extension, then directory index). */\nasync function probeFile(base: string): Promise<string | null> {\n for (const candidate of [\n base,\n `${base}.js`,\n `${base}.mjs`,\n `${base}.cjs`,\n path.join(base, 'index.js'),\n path.join(base, 'index.mjs'),\n ]) {\n if (await isFile(candidate)) return candidate;\n }\n return null;\n}\n\n/** The file a package subpath resolves to for a browser-or-anything lookup; null when none exists. */\nexport async function resolvePackageFile(\n root: string,\n json: any,\n subpath: string,\n conditions: string[] = [\n 'browser',\n 'import',\n 'module',\n 'default',\n 'require',\n 'node',\n ],\n): Promise<string | null> {\n const viaExports = resolveExportsSubpath(json, subpath, conditions);\n if (viaExports !== undefined) {\n return viaExports ? probeFile(path.join(root, viaExports)) : null;\n }\n if (subpath === '.') {\n const browser =\n conditions.includes('browser') &&\n typeof json.browser === 'string' &&\n json.browser;\n const main = browser || json.module || json.main || 'index.js';\n return probeFile(path.join(root, main));\n }\n return probeFile(path.join(root, subpath));\n}\n\n/** Every string target under client conditions, anywhere in `exports`. */\nfunction clientExportTargets(json: any): string[] {\n const map = exportsMap(json?.exports);\n if (!map) {\n const main =\n (typeof json?.browser === 'string' && json.browser) ||\n json?.module ||\n json?.main ||\n 'index.js';\n return [main];\n }\n const out: string[] = [];\n const visit = (target: any): void => {\n if (typeof target === 'string') out.push(target);\n else if (Array.isArray(target)) target.forEach(visit);\n else if (target && typeof target === 'object') {\n for (const [key, value] of Object.entries(target)) {\n if (!NON_CLIENT_CONDITIONS.has(key)) visit(value);\n }\n }\n };\n Object.values(map).forEach(visit);\n return out;\n}\n\n/** Expand one export target (possibly a `*` pattern) to the files it can reach. */\nasync function expandTarget(root: string, target: string): Promise<string[]> {\n const abs = path.join(root, target);\n const star = abs.indexOf('*');\n if (star < 0) {\n const file = await probeFile(abs);\n return file ? [file] : [];\n }\n const prefix = abs.slice(0, star);\n const suffix = abs.slice(star + 1);\n const dir = prefix.endsWith(path.sep) ? prefix : path.dirname(prefix);\n return listFiles(\n dir,\n (f) => f.startsWith(prefix) && f.endsWith(suffix) && !f.endsWith('.d.ts'),\n );\n}\n\nlet lexerReady: Promise<void> | null = null;\nlet esbuildTransform:\n ((code: string, opts: any) => Promise<{code: string}>) | null = null;\n\n/** The static and literal-dynamic import specifiers of a module, plus `require('x')` calls. */\nexport async function importSpecifiers(\n code: string,\n file: string,\n): Promise<string[]> {\n lexerReady ??= initLexer;\n await lexerReady;\n let js = code;\n if (/\\.[mc]?tsx?$/.test(file) || /\\.jsx$/.test(file)) {\n esbuildTransform ??= (await import('esbuild')).transform as any;\n try {\n js = (\n await esbuildTransform!(code, {\n loader: file.endsWith('x')\n ? /\\.tsx$/.test(file)\n ? 'tsx'\n : 'jsx'\n : 'ts',\n format: 'esm',\n jsx: 'automatic',\n tsconfigRaw: {compilerOptions: {experimentalDecorators: true}},\n logLevel: 'silent',\n })\n ).code;\n } catch {\n return [];\n }\n }\n const out = new Set<string>();\n try {\n const [imports] = parseImports(js);\n for (const imp of imports) if (imp.n) out.add(imp.n);\n } catch {\n // Not parseable as a module (JSX in a .js file, say): fall back to the textual forms.\n for (const m of js.matchAll(\n /(?:\\bfrom\\s*|\\bimport\\s*\\(?\\s*)['\"]([^'\"\\n]+)['\"]/g,\n ))\n out.add(m[1]);\n }\n for (const m of js.matchAll(/\\brequire\\s*\\(\\s*['\"]([^'\"\\n]+)['\"]\\s*\\)/g))\n out.add(m[1]);\n return [...out];\n}\n\ninterface ScanCacheData {\n version: number;\n graphs: Record<string, Record<string, {bare: string[]; rel: string[]}>>;\n serverOnly: Record<string, boolean>;\n}\nconst CACHE_VERSION = 1;\n\nasync function loadCache(\n file: string | undefined,\n): Promise<{data: ScanCacheData; dirty: boolean}> {\n const empty = {\n data: {version: CACHE_VERSION, graphs: {}, serverOnly: {}},\n dirty: false,\n };\n if (!file) return empty;\n try {\n const data = JSON.parse(await fs.readFile(file, 'utf8'));\n return data?.version === CACHE_VERSION && data.graphs && data.serverOnly\n ? {data, dirty: false}\n : empty;\n } catch {\n return empty;\n }\n}\n\nasync function saveCache(\n file: string | undefined,\n cache: {data: ScanCacheData; dirty: boolean},\n): Promise<void> {\n if (!file || !cache.dirty) return;\n try {\n await fs.mkdir(path.dirname(file), {recursive: true});\n const tmp = `${file}.${process.pid}.tmp`;\n await fs.writeFile(tmp, JSON.stringify(cache.data));\n await fs.rename(tmp, file);\n } catch {\n // A cache is an optimisation: an unwritable node_modules just means a full scan next time.\n }\n}\n\n/** Limit concurrent file reads: a few hundred open at once can exceed the fd limit. */\nfunction semaphore(limit: number): <T>(fn: () => Promise<T>) => Promise<T> {\n let active = 0;\n const waiting: (() => void)[] = [];\n return async (fn) => {\n if (active >= limit) await new Promise<void>((r) => waiting.push(r));\n active++;\n try {\n return await fn();\n } finally {\n active--;\n waiting.shift()?.();\n }\n };\n}\n\n/** Resolve a relative import to a module file, including the TS-source `./Sibling.js` → `.ts(x)` convention. */\nasync function resolveRelative(\n importer: string,\n specifier: string,\n): Promise<string | null> {\n if (ASSET_SPECIFIER.test(specifier)) return null;\n const base = path.resolve(path.dirname(importer), specifier);\n const candidates: string[] = [];\n if (/\\.[mc]?tsx?$/.test(importer) && /\\.jsx?$/.test(base)) {\n candidates.push(\n base.replace(/\\.jsx?$/, '.ts'),\n base.replace(/\\.jsx?$/, '.tsx'),\n );\n }\n candidates.push(base);\n for (const ext of ['.js', '.mjs', '.cjs', '.ts', '.tsx', '.jsx'])\n candidates.push(base + ext);\n for (const ext of ['.js', '.mjs', '.ts', '.tsx'])\n candidates.push(path.join(base, 'index' + ext));\n for (const c of candidates) {\n if (SOURCE_FILE.test(c) && (await isFile(c))) return c;\n }\n return null;\n}\n\nexport interface ModuleNode {\n file: string;\n /** Bare specifiers the module imports (packages and builtins). */\n bare: string[];\n /** Module files it imports relatively. */\n rel: string[];\n}\n\ninterface ReadGraphOptions {\n maxFiles?: number;\n /** Also follow a bare import: return the file it resolves to, or null to not follow it. */\n followBare?: (specifier: string, importer: string) => Promise<string | null>;\n /** Stop reading once this returns true for a node. */\n stopWhen?: (node: ModuleNode) => boolean;\n}\n\nconst readLimit = semaphore(64);\n\n/** Read the module graph reachable from `entries` through relative imports (and `followBare`). */\nasync function readGraph(\n entries: string[],\n opts: ReadGraphOptions = {},\n): Promise<Map<string, ModuleNode>> {\n const nodes = new Map<string, ModuleNode>();\n const maxFiles = opts.maxFiles ?? Infinity;\n let stopped = false;\n const visit = async (file: string): Promise<void> => {\n if (stopped || nodes.has(file) || nodes.size >= maxFiles) return;\n const node: ModuleNode = {file, bare: [], rel: []};\n nodes.set(file, node);\n const specs = await readLimit(async () => {\n try {\n return await importSpecifiers(await fs.readFile(file, 'utf8'), file);\n } catch {\n return [];\n }\n });\n const children: (string | null)[] = await Promise.all(\n specs.map(async (spec) => {\n if (spec.startsWith('.') || spec.startsWith('/')) {\n const resolved = await resolveRelative(file, spec);\n if (resolved) node.rel.push(resolved);\n return resolved;\n }\n node.bare.push(spec);\n return opts.followBare ? opts.followBare(spec, file) : null;\n }),\n );\n if (opts.stopWhen?.(node)) {\n stopped = true;\n return;\n }\n await Promise.all(children.filter((c): c is string => !!c).map(visit));\n };\n await Promise.all(entries.map(visit));\n return nodes;\n}\n\n/** True when the package declares a browser entry anywhere (`browser` field or condition). */\nfunction hasBrowserEntry(json: any): boolean {\n if (json?.browser) return true;\n let found = false;\n const visit = (v: any): void => {\n if (found || !v || typeof v !== 'object') return;\n for (const [key, value] of Object.entries(v)) {\n if (key === 'browser') found = true;\n else visit(value);\n }\n };\n visit(json?.exports);\n return found;\n}\n\nconst isBuiltinSpecifier = (spec: string): boolean =>\n spec.startsWith('node:') || isBuiltin(spec);\nconst subpathOf = (specifier: string): string => {\n const name = packageNameOf(specifier);\n return specifier === name ? '.' : `.${specifier.slice(name.length)}`;\n};\nconst NODE_CONDITIONS = ['import', 'module', 'default', 'require', 'node'];\n\ntype InstalledLookup = (\n name: string,\n fromDir: string,\n) => Promise<{root: string; json: any} | null>;\n\n/** `readInstalledPkg`, memoised for one scan. */\nfunction memoInstalled(): InstalledLookup {\n const cache = new Map<string, Promise<{root: string; json: any} | null>>();\n return (name, fromDir) => {\n const key = `${name}\\0${fromDir}`;\n if (!cache.has(key)) cache.set(key, readInstalledPkg(name, fromDir));\n return cache.get(key)!;\n };\n}\n\n/**\n * Server-only: no browser entry, and the module graph behind the imported\n * subpath — followed through its own dependencies, as long as those have no\n * browser entry either — reaches a Node builtin. Such a package (express,\n * sharp, bcrypt, jsonwebtoken, cookie-parser) serves a framework package's\n * server code; listing it would make esbuild bundle it for the browser.\n */\nexport async function isServerOnlyDependency(\n root: string,\n json: any,\n subpath: string,\n lookup: InstalledLookup = readInstalledPkg,\n): Promise<boolean> {\n if (hasBrowserEntry(json)) return false;\n const entry = await resolvePackageFile(root, json, subpath, NODE_CONDITIONS);\n if (!entry) return false;\n let builtin = false;\n await readGraph([entry], {\n maxFiles: MAX_DEP_FILES,\n followBare: async (spec, importer) => {\n if (!isBarePackageSpecifier(spec)) return null;\n const dep = await lookup(packageNameOf(spec), path.dirname(importer));\n if (!dep || hasBrowserEntry(dep.json)) return null;\n return resolvePackageFile(\n dep.root,\n dep.json,\n subpathOf(spec),\n NODE_CONDITIONS,\n );\n },\n stopWhen: (node) =>\n (builtin = builtin || node.bare.some(isBuiltinSpecifier)),\n });\n return builtin;\n}\n\n/** The files a framework package's client code can start from. */\nasync function clientEntryFiles(\n pkg: ScannedFrameworkPackage,\n): Promise<string[]> {\n if (pkg.source) {\n return listFiles(\n path.join(pkg.root, 'src'),\n (f) => SOURCE_FILE.test(f) && !IGNORED_SOURCE_FILE.test(f),\n );\n }\n return (\n await Promise.all(\n clientExportTargets(pkg.json).map((t) => expandTarget(pkg.root, t)),\n )\n ).flat();\n}\n\ninterface DepVerdict {\n reason?: 'unresolved' | 'server-only';\n depName: string;\n depRoot?: string;\n}\n\n/**\n * Scan the framework packages among `excluded` for the third-party\n * dependencies their client code imports, and work out the\n * `optimizeDeps.include` entry for each.\n *\n * Framework packages export whole directories (`\"./*\": \"./lib/esm/*.js\"`), so\n * \"reachable from the client exports\" is every file — server code included. A\n * file is therefore treated as SERVER code when it imports a Node builtin or a\n * server-only dependency, or relatively imports a file that does; only the\n * imports of the remaining files are listed.\n */\nexport async function scanLinkedClientDeps(\n excluded: string[],\n opts: ClientDepScanOptions = {},\n): Promise<ClientDepScan> {\n const cwd = path.resolve(opts.cwd ?? process.cwd());\n const deny = [...DEFAULT_DENY, ...(opts.deny ?? [])];\n const excludedSet = new Set(excluded);\n const sourceByName = new Map(\n (opts.sourceWorkspaces ?? []).map((w) => [w.name, w]),\n );\n const lookup = memoInstalled();\n const cache = await loadCache(opts.cacheFile);\n const unresolvedExcludes: string[] = [];\n\n // 1. The excluded packages to scan: every source workspace (Vite does not crawl\n // an excluded package, whatever it is), and the installed framework packages.\n // A package with a `bin` is a command-line tool (`@_linked/cli`), whose code\n // no browser loads; scanning it would only list build tooling.\n const frameworkPackages = (\n await Promise.all(\n [...excludedSet].map(\n async (name): Promise<ScannedFrameworkPackage | null> => {\n const ws = sourceByName.get(name);\n if (ws) {\n const root = await realpath(path.dirname(ws.srcDir));\n let json: any = {};\n try {\n json = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf8'),\n );\n } catch {}\n return {name, root, json, source: true};\n }\n const installed = await lookup(name, cwd);\n if (!installed) {\n unresolvedExcludes.push(name);\n return null;\n }\n if (!isFrameworkPkg(name) && installed.json.linkedPackage !== true)\n return null;\n return {\n name,\n root: await realpath(installed.root),\n json: installed.json,\n source: false,\n };\n },\n ),\n )\n ).filter((p): p is ScannedFrameworkPackage => !!p && !p.json?.bin);\n\n // 2. Each package's module graph.\n const owner = new Map<string, ScannedFrameworkPackage>();\n const nodes = new Map<string, ModuleNode>();\n await Promise.all(\n frameworkPackages.map(async (pkg) => {\n const cacheKey = pkg.source ? null : `${pkg.root}\\0${pkg.json.version}`;\n let graph: Map<string, ModuleNode>;\n if (cacheKey && cache.data.graphs[cacheKey]) {\n graph = new Map(\n Object.entries(cache.data.graphs[cacheKey]).map(([file, n]) => [\n file,\n {file, ...n},\n ]),\n );\n } else {\n graph = await readGraph(await clientEntryFiles(pkg));\n if (cacheKey) {\n cache.data.graphs[cacheKey] = Object.fromEntries(\n [...graph].map(([file, n]) => [file, {bare: n.bare, rel: n.rel}]),\n );\n cache.dirty = true;\n }\n }\n for (const [file, node] of graph) {\n if (nodes.has(file)) continue;\n nodes.set(file, node);\n owner.set(file, pkg);\n }\n }),\n );\n\n // 3. A verdict for every (package, dependency specifier) pair.\n const verdicts = new Map<string, Promise<DepVerdict | null>>();\n const serverOnly = new Map<string, Promise<boolean>>();\n const pairKey = (pkg: ScannedFrameworkPackage, spec: string): string =>\n `${pkg.name}\\0${spec}`;\n const verdictFor = (\n pkg: ScannedFrameworkPackage,\n spec: string,\n ): Promise<DepVerdict | null> => {\n const key = pairKey(pkg, spec);\n if (!verdicts.has(key)) {\n verdicts.set(\n key,\n (async (): Promise<DepVerdict | null> => {\n if (!isBarePackageSpecifier(spec)) return null;\n const depName = packageNameOf(spec);\n if (depName === pkg.name || isFrameworkPkg(depName)) return null;\n const installed = await lookup(depName, pkg.root);\n if (!installed) return {reason: 'unresolved', depName};\n if (installed.json.linkedPackage === true) return null;\n const depRoot = await realpath(installed.root);\n const cacheKey = `${depRoot}\\0${subpathOf(spec)}`;\n if (!serverOnly.has(cacheKey)) {\n const persisted = `${cacheKey}\\0${installed.json.version}`;\n serverOnly.set(\n cacheKey,\n persisted in cache.data.serverOnly\n ? Promise.resolve(cache.data.serverOnly[persisted])\n : isServerOnlyDependency(\n depRoot,\n installed.json,\n subpathOf(spec),\n lookup,\n ).then((v) => {\n cache.data.serverOnly[persisted] = v;\n cache.dirty = true;\n return v;\n }),\n );\n }\n return {\n reason: (await serverOnly.get(cacheKey))\n ? 'server-only'\n : undefined,\n depName,\n depRoot,\n };\n })(),\n );\n }\n return verdicts.get(key)!;\n };\n await Promise.all(\n [...nodes.values()].flatMap((n) =>\n n.bare.map((spec) => verdictFor(owner.get(n.file)!, spec)),\n ),\n );\n\n // 4. Server code: files importing a builtin or a server-only dependency, and\n // every file that relatively imports one of those.\n const server = new Set<string>();\n const importers = new Map<string, string[]>();\n for (const node of nodes.values()) {\n for (const dep of node.rel) {\n if (!importers.has(dep)) importers.set(dep, []);\n importers.get(dep)!.push(node.file);\n }\n }\n const queue: string[] = [];\n for (const node of nodes.values()) {\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) {\n if (\n isBuiltinSpecifier(spec) ||\n (await verdicts.get(pairKey(pkg, spec)))?.reason === 'server-only'\n ) {\n server.add(node.file);\n queue.push(node.file);\n break;\n }\n }\n }\n while (queue.length) {\n for (const parent of importers.get(queue.pop()!) ?? []) {\n if (!server.has(parent)) {\n server.add(parent);\n queue.push(parent);\n }\n }\n }\n\n // 5. Entries from client files; everything else is reported as skipped.\n const rootCopy = new Map<string, Promise<string | null>>();\n const rootResolution = (depName: string): Promise<string | null> => {\n if (!rootCopy.has(depName)) {\n rootCopy.set(\n depName,\n lookup(depName, cwd).then((r) => (r ? realpath(r.root) : null)),\n );\n }\n return rootCopy.get(depName)!;\n };\n const entries = new Map<string, ClientDepEntry>();\n const clientPairs = new Set<string>();\n const skipped = new Map<string, SkippedClientDep>();\n const skip = (specifier: string, from: string, reason: SkipReason): void => {\n skipped.set(`${specifier}\\0${from}`, {specifier, from, reason});\n };\n for (const node of nodes.values()) {\n if (server.has(node.file)) continue;\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) clientPairs.add(pairKey(pkg, spec));\n }\n for (const node of nodes.values()) {\n const pkg = owner.get(node.file)!;\n for (const spec of node.bare) {\n const key = pairKey(pkg, spec);\n const verdict = await verdicts.get(key);\n if (!verdict) continue;\n if (verdict.reason) {\n skip(spec, pkg.name, verdict.reason);\n continue;\n }\n if (!clientPairs.has(key)) {\n if (!skipped.has(`${spec}\\0${pkg.name}`))\n skip(spec, pkg.name, 'server-code');\n continue;\n }\n if (excludedSet.has(verdict.depName) || excludedSet.has(spec)) {\n skip(spec, pkg.name, 'excluded');\n continue;\n }\n const nested =\n (await rootResolution(verdict.depName)) !== verdict.depRoot;\n const entry = nested ? `${pkg.name} > ${spec}` : spec;\n if (matchesDeny(deny, entry, spec, verdict.depName)) {\n skip(spec, pkg.name, 'denied');\n continue;\n }\n if (!entries.has(entry)) {\n entries.set(entry, {\n entry,\n specifier: spec,\n from: pkg.name,\n depName: verdict.depName,\n depRoot: verdict.depRoot!,\n nested,\n });\n }\n }\n }\n for (const {specifier, from} of entries.values())\n skipped.delete(`${specifier}\\0${from}`);\n await saveCache(opts.cacheFile, cache);\n\n return {\n entries: [...entries.values()].sort((a, b) =>\n a.entry.localeCompare(b.entry),\n ),\n skipped: [...skipped.values()].sort(\n (a, b) =>\n a.specifier.localeCompare(b.specifier) || a.from.localeCompare(b.from),\n ),\n frameworkPackages,\n unresolvedExcludes,\n filesScanned: nodes.size,\n };\n}\n\n/** Just the entries, for `optimizeDeps.include`. */\nexport async function linkedClientDepIncludes(\n excluded: string[],\n opts: ClientDepScanOptions = {},\n): Promise<string[]> {\n return (await scanLinkedClientDeps(excluded, opts)).entries.map(\n (e) => e.entry,\n );\n}\n\nexport interface RecordedClientDepScan {\n cwd: string;\n scan: ClientDepScan;\n /** The app's own `optimizeDeps.include`, before anything was added. */\n appInclude: string[];\n exclude: string[];\n}\n\n/**\n * The most recent scan the plugin ran in this process, with the app's own\n * include list — `linked app-doctor` loads the app's config and reads this, so it\n * checks exactly what the dev server would use.\n */\nexport const lastClientDepScan: {current: RecordedClientDepScan | null} = ((\n globalThis as any\n)[Symbol.for('@_linked/cli.lastClientDepScan')] ??= {current: null});\n\nexport interface ClientDepIncludesPluginOptions {\n /** Framework packages served from source (the discovered workspaces). */\n sourceWorkspaces?: SourceWorkspace[];\n /** Entries never to add. See `ClientDepScanOptions.deny`. */\n deny?: (string | RegExp)[];\n /** Override the scan cache location; `false` disables the cache. */\n cacheFile?: string | false;\n}\n\n/** Where the scan cache lives: beside Vite's own cache, inside the app's node_modules. */\nexport const defaultClientDepCacheFile = (cwd: string): string =>\n path.join(cwd, 'node_modules', '.cache', 'linked', 'client-deps.json');\n\nconst debugEnabled = (): boolean =>\n /(^|[\\s,])(linked(:[\\w*]+)?|\\*)($|[\\s,])/.test(process.env.DEBUG ?? '');\n\n/**\n * Adds the scan's entries to `optimizeDeps.include` in dev.\n *\n * It is a `config` hook ordered `post` rather than a value computed inside\n * `createViteConfig`, because the exclude list it reads is only final once the\n * app has merged its own config on top — an app that excludes every installed\n * `@_linked/*` package does that in its own `vite.config.ts`. Vite concatenates\n * the returned array onto the app's own `include`, which is never replaced.\n */\nexport function linkedClientDepIncludesPlugin(\n opts: ClientDepIncludesPluginOptions = {},\n): Plugin[] {\n // What the app itself lists, before other plugins add theirs\n // (@vitejs/plugin-react adds `react`, `react/jsx-runtime`…): `linked app-doctor`\n // must not tell anyone to delete an entry they never wrote.\n let appInclude: string[] = [];\n const snapshot: Plugin = {\n name: 'linked:client-dep-includes:app-include',\n apply: 'serve',\n config: {\n order: 'pre',\n handler(userConfig) {\n appInclude = [...(userConfig.optimizeDeps?.include ?? [])];\n },\n },\n };\n return [\n snapshot,\n {\n name: 'linked:client-dep-includes',\n apply: 'serve',\n config: {\n order: 'post',\n async handler(userConfig) {\n const optimizeDeps = userConfig.optimizeDeps ?? {};\n // `linked start --api-only` has no browser client to optimise for.\n if (optimizeDeps.noDiscovery) return;\n const cwd = path.resolve(userConfig.root ?? process.cwd());\n const started = performance.now();\n const scan = await scanLinkedClientDeps(optimizeDeps.exclude ?? [], {\n cwd,\n sourceWorkspaces: opts.sourceWorkspaces,\n deny: opts.deny,\n cacheFile:\n opts.cacheFile === false\n ? undefined\n : (opts.cacheFile ?? defaultClientDepCacheFile(cwd)),\n });\n const existing = new Set(optimizeDeps.include ?? []);\n const added = scan.entries\n .map((e) => e.entry)\n .filter((e) => !existing.has(e));\n lastClientDepScan.current = {\n cwd,\n scan,\n appInclude,\n exclude: optimizeDeps.exclude ?? [],\n };\n if (debugEnabled()) {\n console.log(\n `[linked] optimizeDeps.include: ${added.length} entries for linked packages' client dependencies ` +\n `(${Math.round(performance.now() - started)}ms, ${scan.filesScanned} files)` +\n added.map((e) => `\\n ${e}`).join(''),\n );\n }\n return added.length ? {optimizeDeps: {include: added}} : undefined;\n },\n },\n },\n ];\n}\n"]}
@@ -5,7 +5,7 @@ export interface LocalizeCommandOptions {
5
5
  list?: boolean;
6
6
  check?: boolean;
7
7
  relink?: boolean;
8
- /** Check every checkout for a copy of what the app provides and prune it; exit 0. */
8
+ /** Check every checkout for a copy of what the app provides and prune it; exit 0. No names. */
9
9
  ensure?: boolean;
10
10
  /** `npm install` in this package's checkout, then prune it. */
11
11
  reinstall?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"localize.d.ts","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":"AAiDA,4EAA4E;AAC5E,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,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* any localized sibling in its `node_modules`, and Node loads those instead of
34
34
  * the app's: a localized package then never sees a localized sibling, and core
35
35
  * loads once per copy. localize removes those copies by default wherever the
36
- * app's version satisfies the checkout's ranges (`--no-prune` turns it off).
36
+ * app's version satisfies the checkout's ranges (`--no-prune` turns it off for
37
+ * that checkout, and is recorded so the run-time check honours it too).
37
38
  * What the app provides is one rule, `providedPackages` (localize/provided.ts),
38
39
  * shared with the run-time check (`--ensure`, and before `linked start` etc.)
39
40
  * and Vite's dedupe.
@@ -65,8 +66,20 @@ export function runLocalize() {
65
66
  return;
66
67
  }
67
68
  if (options.ensure) {
69
+ if (packages.length) {
70
+ // A name would read as "check only these", which it is not: say so
71
+ // rather than ignore it.
72
+ console.error('[localize] --ensure takes no package names: it checks every recorded checkout ' +
73
+ '(one localized with --no-prune is skipped). To reinstall one checkout and prune it: ' +
74
+ '`linked localize --reinstall <package>`.');
75
+ process.exitCode = 2;
76
+ return;
77
+ }
78
+ // `--ensure --no-prune` asks for nothing: a no-op, so a script can turn
79
+ // the check off without removing the hook.
68
80
  // For an app's npm `pre*` scripts: never fails the script it guards.
69
- checkOneCopy(deps.appRoot, deps);
81
+ if (prune.prune)
82
+ checkOneCopy(deps.appRoot, deps);
70
83
  process.exitCode = 0;
71
84
  return;
72
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,MAAM,GACP,MAAM,sBAAsB,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAqBpD,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,QAA6B,I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C,GAAG,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAC3B,QAAQ,EACR,EAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAC,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\n * `linked localize` / `linked delocalize` — develop an npm dependency from a\n * git checkout.\n *\n * All of the work lives in `../localize/` (once the separate\n * `@_linked/localize` package), which knows nothing about this framework on\n * purpose: it resolves a package's repository from the registry, clones it,\n * installs inside the checkout and symlinks it into `node_modules`, without\n * touching `package.json` or `package-lock.json`. This module is the commander\n * adapter over it.\n *\n * The one thing it deliberately does not know is how to build what it cloned.\n * That is the seam this module fills: `@_linked/cli` passes `build: 'linked\n * build'`, because in this ecosystem that is what building a package means.\n * A failing build only warns — a package whose build is broken is usually\n * exactly what you localized it to fix.\n *\n * Packages are named exactly as npm names them (`@_linked/rdfs`, `lodash`).\n * There is no short-name expansion and no org probing: the repository comes\n * from the registry's `repository` field, so a name that npm cannot resolve is\n * an error rather than a guess.\n *\n * A checkout's own install leaves its own copies of `@_linked/core`, React and\n * any localized sibling in its `node_modules`, and Node loads those instead of\n * the app's: a localized package then never sees a localized sibling, and core\n * loads once per copy. localize removes those copies by default wherever the\n * app's version satisfies the checkout's ranges (`--no-prune` turns it off).\n * What the app provides is one rule, `providedPackages` (localize/provided.ts),\n * shared with the run-time check (`--ensure`, and before `linked start` etc.)\n * and Vite's dedupe.\n *\n * `--adopt` is the exception to \"clone from the registry\": it links a git\n * checkout that is already in `packages-local/` under its localize name, with\n * no clone and no lookup — a package created locally, or a clone put there by\n * hand. It takes no `--subdir`: an adopted checkout is the package itself.\n */\nimport process from 'node:process';\n\nimport {\n adopt,\n checkOneCopy,\n defaultDeps,\n delocalize,\n list,\n localize,\n reinstall,\n relink,\n} from '../localize/index.js';\n\n/** The build command `localize` runs inside a fresh checkout by default. */\nexport const DEFAULT_BUILD_COMMAND = 'linked build';\n\nexport interface LocalizeCommandOptions {\n adopt?: boolean;\n list?: boolean;\n check?: boolean;\n relink?: boolean;\n /** Check every checkout for a copy of what the app provides and prune it; exit 0. */\n ensure?: boolean;\n /** `npm install` in this package's checkout, then prune it. */\n reinstall?: string;\n dir?: string;\n repo?: string;\n subdir?: string;\n build?: string;\n force?: boolean;\n purge?: boolean;\n /** Commander's `--no-prune` sets this to false; absent means on. */\n prune?: boolean;\n}\n\n/** localize's prune options for a run: on unless explicitly turned off. */\nexport function pruneOptions(prune: boolean | undefined = true): {\n prune: boolean;\n} {\n return {prune: prune !== false};\n}\n\n/**\n * `localize` reports failure through an exit code rather than by throwing, so\n * that a partial run still prints what it did. Mirror that: set `exitCode` and\n * return, instead of exiting, so pending output is flushed.\n */\nexport async function runLocalize(\n packages: string[] = [],\n options: LocalizeCommandOptions = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n const prune = pruneOptions(options.prune);\n\n if (options.relink) {\n process.exitCode = relink(deps, prune);\n return;\n }\n if (options.ensure) {\n // For an app's npm `pre*` scripts: never fails the script it guards.\n checkOneCopy(deps.appRoot, deps);\n process.exitCode = 0;\n return;\n }\n if (options.reinstall) {\n process.exitCode = reinstall(options.reinstall, prune, deps);\n return;\n }\n if (options.adopt && packages.length === 0) {\n console.error('[localize] --adopt needs at least one package name.');\n process.exitCode = 2;\n return;\n }\n if (options.adopt && options.subdir) {\n console.error(\n '[localize] --adopt takes no --subdir: an adopted checkout is the package itself.',\n );\n process.exitCode = 2;\n return;\n }\n if (options.list || packages.length === 0) {\n process.exitCode = list({check: options.check}, deps);\n return;\n }\n // `--build ''` is how you ask for no build at all.\n const build =\n options.build === undefined ? DEFAULT_BUILD_COMMAND : options.build;\n if (options.adopt) {\n process.exitCode = adopt(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n build,\n ...prune,\n },\n deps,\n );\n return;\n }\n process.exitCode = localize(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n subdir: options.subdir,\n build,\n ...prune,\n },\n deps,\n );\n}\n\n/**\n * Adopt one checkout that already sits in `packages-local/` under its localize\n * name: install inside it, build it, link it and record it. This is how\n * `create-package` hands a new package with its own repository to localize.\n *\n * @returns localize's exit code, rather than setting `process.exitCode`, so the\n * caller decides what a failure means.\n */\nexport async function adoptPackage(\n name: string,\n options: {appRoot: string; build: string; repo?: string},\n): Promise<number> {\n // Exit codes are localize's public contract; EXIT_WARNED (5) is the one a\n // caller usually tolerates, meaning the build failed but the link is in place.\n return adopt(\n [name],\n {\n build: options.build,\n repo: options.repo,\n ...pruneOptions(),\n },\n defaultDeps(options.appRoot),\n );\n}\n\n/** `linked delocalize [packages...]` — unlink and forget; no names means all. */\nexport async function runDelocalize(\n packages: string[] = [],\n options: Pick<LocalizeCommandOptions, 'purge' | 'force'> = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n process.exitCode = delocalize(\n packages,\n {purge: options.purge, force: options.force},\n deps,\n );\n}\n"]}
1
+ {"version":3,"file":"localize.js","sourceRoot":"","sources":["../../../src/commands/localize.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,KAAK,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,MAAM,GACP,MAAM,sBAAsB,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAqBpD,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,QAA6B,IAAI;IAG5D,OAAO,EAAC,KAAK,EAAE,KAAK,KAAK,KAAK,EAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAgB,WAAW;yDAC/B,WAAqB,EAAE,EACvB,UAAkC,EAAE;QAEpC,MAAM,IAAI,GAAG,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AM,UAAgB,aAAa;yDACjC,WAAqB,EAAE,EACvB,UAA2D,EAAE;QAE7D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,QAAQ,GAAG,UAAU,CAC3B,QAAQ,EACR,EAAC,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAC,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/**\n * `linked localize` / `linked delocalize` — develop an npm dependency from a\n * git checkout.\n *\n * All of the work lives in `../localize/` (once the separate\n * `@_linked/localize` package), which knows nothing about this framework on\n * purpose: it resolves a package's repository from the registry, clones it,\n * installs inside the checkout and symlinks it into `node_modules`, without\n * touching `package.json` or `package-lock.json`. This module is the commander\n * adapter over it.\n *\n * The one thing it deliberately does not know is how to build what it cloned.\n * That is the seam this module fills: `@_linked/cli` passes `build: 'linked\n * build'`, because in this ecosystem that is what building a package means.\n * A failing build only warns — a package whose build is broken is usually\n * exactly what you localized it to fix.\n *\n * Packages are named exactly as npm names them (`@_linked/rdfs`, `lodash`).\n * There is no short-name expansion and no org probing: the repository comes\n * from the registry's `repository` field, so a name that npm cannot resolve is\n * an error rather than a guess.\n *\n * A checkout's own install leaves its own copies of `@_linked/core`, React and\n * any localized sibling in its `node_modules`, and Node loads those instead of\n * the app's: a localized package then never sees a localized sibling, and core\n * loads once per copy. localize removes those copies by default wherever the\n * app's version satisfies the checkout's ranges (`--no-prune` turns it off for\n * that checkout, and is recorded so the run-time check honours it too).\n * What the app provides is one rule, `providedPackages` (localize/provided.ts),\n * shared with the run-time check (`--ensure`, and before `linked start` etc.)\n * and Vite's dedupe.\n *\n * `--adopt` is the exception to \"clone from the registry\": it links a git\n * checkout that is already in `packages-local/` under its localize name, with\n * no clone and no lookup — a package created locally, or a clone put there by\n * hand. It takes no `--subdir`: an adopted checkout is the package itself.\n */\nimport process from 'node:process';\n\nimport {\n adopt,\n checkOneCopy,\n defaultDeps,\n delocalize,\n list,\n localize,\n reinstall,\n relink,\n} from '../localize/index.js';\n\n/** The build command `localize` runs inside a fresh checkout by default. */\nexport const DEFAULT_BUILD_COMMAND = 'linked build';\n\nexport interface LocalizeCommandOptions {\n adopt?: boolean;\n list?: boolean;\n check?: boolean;\n relink?: boolean;\n /** Check every checkout for a copy of what the app provides and prune it; exit 0. No names. */\n ensure?: boolean;\n /** `npm install` in this package's checkout, then prune it. */\n reinstall?: string;\n dir?: string;\n repo?: string;\n subdir?: string;\n build?: string;\n force?: boolean;\n purge?: boolean;\n /** Commander's `--no-prune` sets this to false; absent means on. */\n prune?: boolean;\n}\n\n/** localize's prune options for a run: on unless explicitly turned off. */\nexport function pruneOptions(prune: boolean | undefined = true): {\n prune: boolean;\n} {\n return {prune: prune !== false};\n}\n\n/**\n * `localize` reports failure through an exit code rather than by throwing, so\n * that a partial run still prints what it did. Mirror that: set `exitCode` and\n * return, instead of exiting, so pending output is flushed.\n */\nexport async function runLocalize(\n packages: string[] = [],\n options: LocalizeCommandOptions = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n const prune = pruneOptions(options.prune);\n\n if (options.relink) {\n process.exitCode = relink(deps, prune);\n return;\n }\n if (options.ensure) {\n if (packages.length) {\n // A name would read as \"check only these\", which it is not: say so\n // rather than ignore it.\n console.error(\n '[localize] --ensure takes no package names: it checks every recorded checkout ' +\n '(one localized with --no-prune is skipped). To reinstall one checkout and prune it: ' +\n '`linked localize --reinstall <package>`.',\n );\n process.exitCode = 2;\n return;\n }\n // `--ensure --no-prune` asks for nothing: a no-op, so a script can turn\n // the check off without removing the hook.\n // For an app's npm `pre*` scripts: never fails the script it guards.\n if (prune.prune) checkOneCopy(deps.appRoot, deps);\n process.exitCode = 0;\n return;\n }\n if (options.reinstall) {\n process.exitCode = reinstall(options.reinstall, prune, deps);\n return;\n }\n if (options.adopt && packages.length === 0) {\n console.error('[localize] --adopt needs at least one package name.');\n process.exitCode = 2;\n return;\n }\n if (options.adopt && options.subdir) {\n console.error(\n '[localize] --adopt takes no --subdir: an adopted checkout is the package itself.',\n );\n process.exitCode = 2;\n return;\n }\n if (options.list || packages.length === 0) {\n process.exitCode = list({check: options.check}, deps);\n return;\n }\n // `--build ''` is how you ask for no build at all.\n const build =\n options.build === undefined ? DEFAULT_BUILD_COMMAND : options.build;\n if (options.adopt) {\n process.exitCode = adopt(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n build,\n ...prune,\n },\n deps,\n );\n return;\n }\n process.exitCode = localize(\n packages,\n {\n force: options.force,\n dir: options.dir,\n repo: options.repo,\n subdir: options.subdir,\n build,\n ...prune,\n },\n deps,\n );\n}\n\n/**\n * Adopt one checkout that already sits in `packages-local/` under its localize\n * name: install inside it, build it, link it and record it. This is how\n * `create-package` hands a new package with its own repository to localize.\n *\n * @returns localize's exit code, rather than setting `process.exitCode`, so the\n * caller decides what a failure means.\n */\nexport async function adoptPackage(\n name: string,\n options: {appRoot: string; build: string; repo?: string},\n): Promise<number> {\n // Exit codes are localize's public contract; EXIT_WARNED (5) is the one a\n // caller usually tolerates, meaning the build failed but the link is in place.\n return adopt(\n [name],\n {\n build: options.build,\n repo: options.repo,\n ...pruneOptions(),\n },\n defaultDeps(options.appRoot),\n );\n}\n\n/** `linked delocalize [packages...]` — unlink and forget; no names means all. */\nexport async function runDelocalize(\n packages: string[] = [],\n options: Pick<LocalizeCommandOptions, 'purge' | 'force'> = {},\n): Promise<void> {\n const deps = defaultDeps(process.cwd());\n process.exitCode = delocalize(\n packages,\n {purge: options.purge, force: options.force},\n deps,\n );\n}\n"]}
@@ -11,12 +11,14 @@ import type { Deps } from './run.js';
11
11
  * @returns 0, or `EXIT_WARNED` when the prune failed (the install stands).
12
12
  * @throws {LocalizeError} `EXIT_INSTALL_FAILED` when `npm install` fails.
13
13
  */
14
- export declare function ensure(entry: Pick<ManifestEntry, 'path' | 'subdir'>, deps: Deps, opts?: PruneOptions): number;
14
+ export declare function ensure(entry: Pick<ManifestEntry, 'path' | 'subdir' | 'prune'>, deps: Deps, opts?: PruneOptions): number;
15
15
  /** `linked localize --reinstall <pkg>`: `ensure` for one recorded package. */
16
16
  export declare function reinstall(name: string, opts: PruneOptions, deps: Deps): number;
17
17
  /**
18
18
  * The run-time check: remove every recorded checkout's own copy of what the
19
- * app provides. Stat-only until there is something to remove.
19
+ * app provides -- exactly what `pruneProvided` would remove, decided first
20
+ * without it, so the common case (nothing to remove, some copies kept) never
21
+ * reaches the prune.
20
22
  *
21
23
  * @returns what was removed, as `<checkout>/node_modules/<name>@<version>`.
22
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ensure.d.ts","sourceRoot":"","sources":["../../../src/localize/ensure.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAQjD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAG7C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAGnC;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,CAAC,EAC7C,IAAI,EAAE,IAAI,EACV,IAAI,GAAE,YAAiB,GACtB,MAAM,CA0BR;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,IAAI,GACT,MAAM,CAoBR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,MAAsB,EAC/B,IAAI,GAAE,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAwB,GACtD;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAC,CAsDpB"}
1
+ {"version":3,"file":"ensure.d.ts","sourceRoot":"","sources":["../../../src/localize/ensure.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AASjD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,UAAU,CAAC;AAGnC;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC,EACvD,IAAI,EAAE,IAAI,EACV,IAAI,GAAE,YAAiB,GACtB,MAAM,CA0BR;AAED,8EAA8E;AAC9E,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,IAAI,GACT,MAAM,CAoBR;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,MAAsB,EAC/B,IAAI,GAAE,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,CAAwB,GACtD;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAC,CAwCpB"}
@@ -12,22 +12,24 @@
12
12
  * replaces.
13
13
  * - **`checkOneCopy(appRoot)`** -- the run-time check. Before `linked start`,
14
14
  * `script`, `call` and `build-all` (a commander `preAction` in cli.ts), and
15
- * as `linked localize --ensure` for an app's npm `pre*` scripts. Stat-only:
16
- * for every recorded checkout and every name the app provides, does
17
- * `<checkout>/node_modules/<name>` exist with a real path other than the
18
- * app's copy? Only then does it prune -- through prune's guarded path, so a
19
- * copy whose ranges the app does not satisfy stays -- and it says what it
20
- * removed in one line. It never runs npm, prints nothing when there is
21
- * nothing to do (or no manifest), and never throws: a run command must not
22
- * fail over a developer's private checkout state.
15
+ * as `linked localize --ensure` for an app's npm `pre*` scripts. It plans
16
+ * the prune (prune.ts `planPrune`) without touching anything -- per-owner
17
+ * candidates, the same range guard, the same "would its dependencies
18
+ * resolve elsewhere" check -- and only when that plan removes something does
19
+ * it prune, and say so in one line on stderr. A copy prune would keep costs
20
+ * a stat and, at most, one requirement index per `node_modules` (read from
21
+ * npm's hidden lockfile), so a tree full of kept copies stays cheap. It
22
+ * never runs npm, prints nothing when there is nothing to do (or no
23
+ * manifest), skips a checkout recorded with `prune: false`, and never
24
+ * throws: a run command must not fail over a developer's private checkout
25
+ * state.
23
26
  */
24
27
  import fs from 'node:fs';
25
28
  import path from 'node:path';
26
29
  import { EXIT_INSTALL_FAILED, EXIT_REFUSED, EXIT_WARNED, LocalizeError, } from './errors.js';
27
30
  import { manifestPath, readManifest } from './manifest.js';
28
31
  import { readJson } from './fsops.js';
29
- import { nodeModulesRoots, pruneProvided, realOrSelf, shouldPrune, } from './prune.js';
30
- import { providedPackages } from './provided.js';
32
+ import { newPruneCache, planPrune, pruneProvided, prunesEntry, shouldPrune, } from './prune.js';
31
33
  import { defaultDeps } from './run.js';
32
34
  import { reportError } from './localize.js';
33
35
  /**
@@ -50,7 +52,7 @@ export function ensure(entry, deps, opts = {}) {
50
52
  if (install.status !== 0) {
51
53
  throw new LocalizeError(`npm install failed in ${entry.path}:\n${(install.stderr || install.stdout).trim()}`, EXIT_INSTALL_FAILED);
52
54
  }
53
- if (!shouldPrune(opts))
55
+ if (!shouldPrune(opts) || !prunesEntry(entry))
54
56
  return 0;
55
57
  const name = (_a = readJson(path.join(pkgDir, 'package.json'))) === null || _a === void 0 ? void 0 : _a.name;
56
58
  if (typeof name !== 'string')
@@ -84,7 +86,9 @@ export function reinstall(name, opts, deps) {
84
86
  }
85
87
  /**
86
88
  * The run-time check: remove every recorded checkout's own copy of what the
87
- * app provides. Stat-only until there is something to remove.
89
+ * app provides -- exactly what `pruneProvided` would remove, decided first
90
+ * without it, so the common case (nothing to remove, some copies kept) never
91
+ * reaches the prune.
88
92
  *
89
93
  * @returns what was removed, as `<checkout>/node_modules/<name>@<version>`.
90
94
  */
@@ -97,41 +101,22 @@ export function checkOneCopy(appRoot = process.cwd(), deps = defaultDeps(appRoot
97
101
  const owners = Object.keys(entries);
98
102
  if (!owners.length)
99
103
  return { pruned: [] };
100
- // The app's copy of each provided name, by real path.
101
- const appReal = new Map();
102
- for (const name of providedPackages(appRoot, owners).names) {
103
- const dir = path.join(appRoot, 'node_modules', name);
104
- if (fs.existsSync(dir))
105
- appReal.set(name, realOrSelf(dir));
106
- }
107
- const hitOwners = new Set();
108
- const hitNames = new Set();
109
- for (const [owner, entry] of Object.entries(entries)) {
110
- const pkgDir = path.join(appRoot, entry.path);
111
- for (const nm of nodeModulesRoots(pkgDir, entry)) {
112
- for (const [name, real] of appReal) {
113
- if (name === owner)
114
- continue;
115
- const copy = path.join(nm, name);
116
- if (fs.existsSync(copy) && realOrSelf(copy) !== real) {
117
- hitOwners.add(owner);
118
- hitNames.add(name);
119
- }
120
- }
121
- }
122
- }
123
- if (!hitOwners.size)
104
+ if (!Object.values(entries).some(prunesEntry))
105
+ return { pruned: [] };
106
+ const cache = newPruneCache();
107
+ const plan = planPrune(entries, { appRoot }, {}, cache);
108
+ if (!plan.remove.length)
124
109
  return { pruned: [] };
125
110
  // Prune's own report is per checkout and also speaks of what it keeps;
126
111
  // here only what went is worth a line, on every run command.
127
112
  const quiet = { appRoot, log: () => { }, warn: () => { } };
128
113
  const { removed } = pruneProvided(entries, {}, quiet, {
129
- owners: [...hitOwners],
130
- deps: [...hitNames],
131
- });
132
- const pruned = removed.map((r) => `${r.owner}/node_modules/${r.dep}@${r.version}`);
114
+ owners: [...new Set(plan.remove.map((d) => d.ownerName))],
115
+ deps: [...new Set(plan.remove.map((d) => d.dep))],
116
+ }, cache);
117
+ const pruned = removed.map((r) => `${r.where}@${r.version}`);
133
118
  if (pruned.length) {
134
- deps.log(`[localize] one copy: removed ${pruned.join(', ')} — the app provides ` +
119
+ deps.warn(`[localize] one copy: removed ${pruned.join(', ')} — the app provides ` +
135
120
  `${pruned.length === 1 ? 'it' : 'them'}.`);
136
121
  }
137
122
  return { pruned };