@_linked/cli 1.31.0 → 1.33.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 (35) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +15 -0
  3. package/defaults/app-react-native/packages/app-shapes/src/index.ts +2 -0
  4. package/defaults/app-react-native/packages/app-shapes/src/shapes/index.ts +5 -0
  5. package/defaults/package/src/shapes/index.ts +3 -1
  6. package/lib/esm/cli-methods.d.ts.map +1 -1
  7. package/lib/esm/cli-methods.js +144 -118
  8. package/lib/esm/cli-methods.js.map +1 -1
  9. package/lib/esm/cli.js +7 -0
  10. package/lib/esm/cli.js.map +1 -1
  11. package/lib/esm/client-dep-includes.d.ts +144 -0
  12. package/lib/esm/client-dep-includes.d.ts.map +1 -0
  13. package/lib/esm/client-dep-includes.js +827 -0
  14. package/lib/esm/client-dep-includes.js.map +1 -0
  15. package/lib/esm/commands/doctor.d.ts +19 -0
  16. package/lib/esm/commands/doctor.d.ts.map +1 -0
  17. package/lib/esm/commands/doctor.js +167 -0
  18. package/lib/esm/commands/doctor.js.map +1 -0
  19. package/lib/esm/installed-packages.d.ts +18 -0
  20. package/lib/esm/installed-packages.d.ts.map +1 -0
  21. package/lib/esm/installed-packages.js +66 -0
  22. package/lib/esm/installed-packages.js.map +1 -0
  23. package/lib/esm/utils/shapeReferences.d.ts +10 -7
  24. package/lib/esm/utils/shapeReferences.d.ts.map +1 -1
  25. package/lib/esm/utils/shapeReferences.js +13 -18
  26. package/lib/esm/utils/shapeReferences.js.map +1 -1
  27. package/lib/esm/utils/shapesIndex.d.ts +21 -0
  28. package/lib/esm/utils/shapesIndex.d.ts.map +1 -0
  29. package/lib/esm/utils/shapesIndex.js +204 -0
  30. package/lib/esm/utils/shapesIndex.js.map +1 -0
  31. package/lib/esm/vite-config.d.ts +37 -0
  32. package/lib/esm/vite-config.d.ts.map +1 -1
  33. package/lib/esm/vite-config.js +70 -51
  34. package/lib/esm/vite-config.js.map +1 -1
  35. package/package.json +5 -2
@@ -0,0 +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,MAAM,mBAAmB,GAAG,gDAAgD,CAAC;AAC7E,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,cAAc;IACd,WAAW;IACX,WAAW;IACX,cA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zD,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 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 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"]}
@@ -0,0 +1,19 @@
1
+ import { type ClientDepScan } from '../client-dep-includes.js';
2
+ export interface DoctorFinding {
3
+ level: 'warn' | 'info';
4
+ message: string;
5
+ }
6
+ export interface DiagnoseInput {
7
+ cwd: string;
8
+ /** The app's own `optimizeDeps.include` (hand-written, before generation). */
9
+ appInclude: string[];
10
+ scan: ClientDepScan;
11
+ }
12
+ /** Split a Vite include entry (`a > b > c/sub`) and resolve it hop by hop, like Vite's nested-dep syntax. */
13
+ export declare function resolveIncludeEntry(cwd: string, entry: string): Promise<string | null>;
14
+ export declare function diagnose({ cwd, appInclude, scan, }: DiagnoseInput): Promise<DoctorFinding[]>;
15
+ export interface DoctorOptions {
16
+ cwd?: string;
17
+ }
18
+ export declare function runDoctor(options?: DoctorOptions): Promise<void>;
19
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor.ts"],"names":[],"mappings":"AAsBA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,6GAA6G;AAC7G,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBxB;AAKD,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,UAAU,EACV,IAAI,GACL,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA2E1C;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA8BD,wBAAsB,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB1E"}
@@ -0,0 +1,167 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ /**
11
+ * `linked doctor` — check an app's dev dependency setup for the problems that
12
+ * otherwise only show up in the browser.
13
+ *
14
+ * It loads the app's Vite config the way the dev server does, runs the same
15
+ * client-dependency scan `createViteConfig` runs (./client-dep-includes.ts), and
16
+ * warns about:
17
+ *
18
+ * - `optimizeDeps.include` entries that do not resolve. Vite only logs these,
19
+ * and the dependency then reaches the browser unoptimised — a CommonJS one
20
+ * fails on `require`. The usual cause is a package npm installed NESTED under
21
+ * a framework package, which needs the `'<pkg> > <dep>'` form.
22
+ * - a framework package's dependency whose React peer range excludes the app's
23
+ * React. That is why npm nests it (vaul 0.9 under `@_linked/primitives` with
24
+ * React 19); the fix is a newer release of the dependency in that package.
25
+ *
26
+ * Hand-written include entries that the scan now generates are listed too, as
27
+ * safe to delete.
28
+ */
29
+ import path from 'node:path';
30
+ import semver from 'semver';
31
+ import { readInstalledPkg } from '../installed-packages.js';
32
+ import { lastClientDepScan, packageNameOf, resolvePackageFile, scanLinkedClientDeps, } from '../client-dep-includes.js';
33
+ /** Split a Vite include entry (`a > b > c/sub`) and resolve it hop by hop, like Vite's nested-dep syntax. */
34
+ export function resolveIncludeEntry(cwd, entry) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const hops = entry
37
+ .split('>')
38
+ .map((s) => s.trim())
39
+ .filter(Boolean);
40
+ let fromDir = cwd;
41
+ for (let i = 0; i < hops.length; i++) {
42
+ const name = packageNameOf(hops[i]);
43
+ const installed = yield readInstalledPkg(name, fromDir);
44
+ if (!installed)
45
+ return null;
46
+ if (i === hops.length - 1) {
47
+ const subpath = hops[i] === name ? '.' : `.${hops[i].slice(name.length)}`;
48
+ return resolvePackageFile(installed.root, installed.json, subpath);
49
+ }
50
+ fromDir = installed.root;
51
+ }
52
+ return null;
53
+ });
54
+ }
55
+ /** The peer names whose ranges must admit the app's copy. */
56
+ const CHECKED_PEERS = ['react', 'react-dom'];
57
+ export function diagnose(_a) {
58
+ return __awaiter(this, arguments, void 0, function* ({ cwd, appInclude, scan, }) {
59
+ var _b, _c, _d;
60
+ const findings = [];
61
+ const generated = new Map(scan.entries.map((e) => [e.entry, e]));
62
+ // 1. Include entries that do not resolve.
63
+ yield Promise.all(appInclude.map((entry) => __awaiter(this, void 0, void 0, function* () {
64
+ if (yield resolveIncludeEntry(cwd, entry))
65
+ return;
66
+ const nestedForm = scan.entries.find((e) => e.nested && (e.specifier === entry || e.depName === entry));
67
+ findings.push({
68
+ level: 'warn',
69
+ message: `optimizeDeps.include entry '${entry}' does not resolve from ${cwd}` +
70
+ (nestedForm
71
+ ? ` — it is installed under ${nestedForm.from}; use '${nestedForm.entry}' (generated automatically, so the entry can simply be removed)`
72
+ : ' — remove it from vite.config, or install the package'),
73
+ });
74
+ })));
75
+ // 2. Dependencies of framework packages whose React peer range excludes the app's React.
76
+ const appVersions = new Map();
77
+ for (const peer of CHECKED_PEERS) {
78
+ const installed = yield readInstalledPkg(peer, cwd);
79
+ if ((_b = installed === null || installed === void 0 ? void 0 : installed.json) === null || _b === void 0 ? void 0 : _b.version)
80
+ appVersions.set(peer, installed.json.version);
81
+ }
82
+ const seen = new Set();
83
+ for (const pkg of scan.frameworkPackages) {
84
+ for (const dep of Object.keys((_d = (_c = pkg.json) === null || _c === void 0 ? void 0 : _c.dependencies) !== null && _d !== void 0 ? _d : {})) {
85
+ const installed = yield readInstalledPkg(dep, pkg.root);
86
+ if (!installed || seen.has(`${pkg.name}\0${dep}`))
87
+ continue;
88
+ const excluded = [...appVersions].filter(([peer, version]) => {
89
+ var _a;
90
+ const range = (_a = installed.json.peerDependencies) === null || _a === void 0 ? void 0 : _a[peer];
91
+ return (range && !semver.satisfies(version, range, { includePrerelease: true }));
92
+ });
93
+ if (!excluded.length)
94
+ continue;
95
+ seen.add(`${pkg.name}\0${dep}`);
96
+ const [firstPeer, appVersion] = excluded[0];
97
+ const nested = path
98
+ .relative(cwd, installed.root)
99
+ .split(path.sep)
100
+ .filter((s) => s === 'node_modules').length > 1;
101
+ findings.push({
102
+ level: 'warn',
103
+ message: `${pkg.name} depends on ${dep}@${installed.json.version}, whose peer range ` +
104
+ excluded
105
+ .map(([peer]) => `${peer} '${installed.json.peerDependencies[peer]}'`)
106
+ .join(', ') +
107
+ ` excludes the app's ${excluded.map(([peer, v]) => `${peer} ${v}`).join(', ')}` +
108
+ (nested ? `, so npm installed it nested under ${pkg.name}` : '') +
109
+ `. Bump ${dep} in ${pkg.name} to a release that supports ${firstPeer} ${semver.major(appVersion)}.`,
110
+ });
111
+ }
112
+ }
113
+ // 3. Hand-written entries the scan generates anyway.
114
+ const redundant = appInclude.filter((e) => generated.has(e));
115
+ if (redundant.length) {
116
+ findings.push({
117
+ level: 'info',
118
+ message: `${redundant.length} optimizeDeps.include entr${redundant.length === 1 ? 'y is' : 'ies are'} generated ` +
119
+ `automatically and can be removed from vite.config:\n` +
120
+ redundant.map((e) => ` ${e}`).join('\n'),
121
+ });
122
+ }
123
+ return findings;
124
+ });
125
+ }
126
+ /** Load the app's dev config and return what the plugin scanned, running the scan itself if the plugin did not. */
127
+ function loadAppScan(cwd) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ var _a, _b, _c;
130
+ const { resolveConfig } = yield import('vite');
131
+ lastClientDepScan.current = null;
132
+ const config = yield resolveConfig({ root: cwd, mode: 'development', logLevel: 'error' }, 'serve');
133
+ const recorded = lastClientDepScan.current;
134
+ if (recorded && path.resolve(recorded.cwd) === path.resolve(cwd)) {
135
+ return { appInclude: recorded.appInclude, scan: recorded.scan };
136
+ }
137
+ // The app does not use createViteConfig (or turned the generation off): scan
138
+ // what it excludes, with the workspaces the helper would have discovered.
139
+ const { discoverWorkspaces } = yield import('../vite-config.js');
140
+ const optimizeDeps = (_a = config.optimizeDeps) !== null && _a !== void 0 ? _a : {};
141
+ return {
142
+ appInclude: (_b = optimizeDeps.include) !== null && _b !== void 0 ? _b : [],
143
+ scan: yield scanLinkedClientDeps((_c = optimizeDeps.exclude) !== null && _c !== void 0 ? _c : [], {
144
+ cwd,
145
+ sourceWorkspaces: yield discoverWorkspaces([], cwd),
146
+ }),
147
+ };
148
+ });
149
+ }
150
+ export function runDoctor() {
151
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
152
+ var _a;
153
+ const cwd = path.resolve((_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd());
154
+ const started = performance.now();
155
+ const { appInclude, scan } = yield loadAppScan(cwd);
156
+ const findings = yield diagnose({ cwd, appInclude, scan });
157
+ for (const f of findings) {
158
+ (f.level === 'warn' ? console.warn : console.log)(`${f.level === 'warn' ? 'warning' : 'note'}: ${f.message}`);
159
+ }
160
+ const warnings = findings.filter((f) => f.level === 'warn').length;
161
+ console.log(`linked doctor: ${warnings} warning${warnings === 1 ? '' : 's'}; ` +
162
+ `${scan.entries.length} client dependencies of ${scan.frameworkPackages.length} linked packages ` +
163
+ `generated for optimizeDeps.include (${Math.round(performance.now() - started)}ms)`);
164
+ process.exitCode = warnings ? 1 : 0;
165
+ });
166
+ }
167
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../src/commands/doctor.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,2BAA2B,CAAC;AAcnC,6GAA6G;AAC7G,MAAM,UAAgB,mBAAmB,CACvC,GAAW,EACX,KAAa;;QAEb,MAAM,IAAI,GAAG,KAAK;aACf,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC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AAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,EAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAC,CAAC,CAAC;QACzD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAC/C,GAAG,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,EAAE,CAC3D,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,MAAM,CAAC;QACnE,OAAO,CAAC,GAAG,CACT,kBAAkB,QAAQ,WAAW,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI;YAChE,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,2BAA2B,IAAI,CAAC,iBAAiB,CAAC,MAAM,mBAAmB;YACjG,uCAAuC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,CACtF,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;CAAA","sourcesContent":["/**\n * `linked doctor` — check an app's dev dependency setup for the problems that\n * otherwise only show up in the browser.\n *\n * It loads the app's Vite config the way the dev server does, runs the same\n * client-dependency scan `createViteConfig` runs (./client-dep-includes.ts), and\n * warns about:\n *\n * - `optimizeDeps.include` entries that do not resolve. Vite only logs these,\n * and the dependency then reaches the browser unoptimised — a CommonJS one\n * fails on `require`. The usual cause is a package npm installed NESTED under\n * a framework package, which needs the `'<pkg> > <dep>'` form.\n * - a framework package's dependency whose React peer range excludes the app's\n * React. That is why npm nests it (vaul 0.9 under `@_linked/primitives` with\n * React 19); the fix is a newer release of the dependency in that package.\n *\n * Hand-written include entries that the scan now generates are listed too, as\n * safe to delete.\n */\nimport path from 'node:path';\nimport semver from 'semver';\nimport {readInstalledPkg} from '../installed-packages.js';\nimport {\n lastClientDepScan,\n packageNameOf,\n resolvePackageFile,\n scanLinkedClientDeps,\n type ClientDepScan,\n} from '../client-dep-includes.js';\n\nexport interface DoctorFinding {\n level: 'warn' | 'info';\n message: string;\n}\n\nexport interface DiagnoseInput {\n cwd: string;\n /** The app's own `optimizeDeps.include` (hand-written, before generation). */\n appInclude: string[];\n scan: ClientDepScan;\n}\n\n/** Split a Vite include entry (`a > b > c/sub`) and resolve it hop by hop, like Vite's nested-dep syntax. */\nexport async function resolveIncludeEntry(\n cwd: string,\n entry: string,\n): Promise<string | null> {\n const hops = entry\n .split('>')\n .map((s) => s.trim())\n .filter(Boolean);\n let fromDir = cwd;\n for (let i = 0; i < hops.length; i++) {\n const name = packageNameOf(hops[i]);\n const installed = await readInstalledPkg(name, fromDir);\n if (!installed) return null;\n if (i === hops.length - 1) {\n const subpath = hops[i] === name ? '.' : `.${hops[i].slice(name.length)}`;\n return resolvePackageFile(installed.root, installed.json, subpath);\n }\n fromDir = installed.root;\n }\n return null;\n}\n\n/** The peer names whose ranges must admit the app's copy. */\nconst CHECKED_PEERS = ['react', 'react-dom'];\n\nexport async function diagnose({\n cwd,\n appInclude,\n scan,\n}: DiagnoseInput): Promise<DoctorFinding[]> {\n const findings: DoctorFinding[] = [];\n const generated = new Map(scan.entries.map((e) => [e.entry, e]));\n\n // 1. Include entries that do not resolve.\n await Promise.all(\n appInclude.map(async (entry) => {\n if (await resolveIncludeEntry(cwd, entry)) return;\n const nestedForm = scan.entries.find(\n (e) => e.nested && (e.specifier === entry || e.depName === entry),\n );\n findings.push({\n level: 'warn',\n message:\n `optimizeDeps.include entry '${entry}' does not resolve from ${cwd}` +\n (nestedForm\n ? ` — it is installed under ${nestedForm.from}; use '${nestedForm.entry}' (generated automatically, so the entry can simply be removed)`\n : ' — remove it from vite.config, or install the package'),\n });\n }),\n );\n\n // 2. Dependencies of framework packages whose React peer range excludes the app's React.\n const appVersions = new Map<string, string>();\n for (const peer of CHECKED_PEERS) {\n const installed = await readInstalledPkg(peer, cwd);\n if (installed?.json?.version) appVersions.set(peer, installed.json.version);\n }\n const seen = new Set<string>();\n for (const pkg of scan.frameworkPackages) {\n for (const dep of Object.keys(pkg.json?.dependencies ?? {})) {\n const installed = await readInstalledPkg(dep, pkg.root);\n if (!installed || seen.has(`${pkg.name}\\0${dep}`)) continue;\n const excluded = [...appVersions].filter(([peer, version]) => {\n const range = installed.json.peerDependencies?.[peer];\n return (\n range && !semver.satisfies(version, range, {includePrerelease: true})\n );\n });\n if (!excluded.length) continue;\n seen.add(`${pkg.name}\\0${dep}`);\n const [firstPeer, appVersion] = excluded[0];\n const nested =\n path\n .relative(cwd, installed.root)\n .split(path.sep)\n .filter((s) => s === 'node_modules').length > 1;\n findings.push({\n level: 'warn',\n message:\n `${pkg.name} depends on ${dep}@${installed.json.version}, whose peer range ` +\n excluded\n .map(\n ([peer]) => `${peer} '${installed.json.peerDependencies[peer]}'`,\n )\n .join(', ') +\n ` excludes the app's ${excluded.map(([peer, v]) => `${peer} ${v}`).join(', ')}` +\n (nested ? `, so npm installed it nested under ${pkg.name}` : '') +\n `. Bump ${dep} in ${pkg.name} to a release that supports ${firstPeer} ${semver.major(appVersion)}.`,\n });\n }\n }\n\n // 3. Hand-written entries the scan generates anyway.\n const redundant = appInclude.filter((e) => generated.has(e));\n if (redundant.length) {\n findings.push({\n level: 'info',\n message:\n `${redundant.length} optimizeDeps.include entr${redundant.length === 1 ? 'y is' : 'ies are'} generated ` +\n `automatically and can be removed from vite.config:\\n` +\n redundant.map((e) => ` ${e}`).join('\\n'),\n });\n }\n return findings;\n}\n\nexport interface DoctorOptions {\n cwd?: string;\n}\n\n/** Load the app's dev config and return what the plugin scanned, running the scan itself if the plugin did not. */\nasync function loadAppScan(\n cwd: string,\n): Promise<{appInclude: string[]; scan: ClientDepScan}> {\n const {resolveConfig} = await import('vite');\n lastClientDepScan.current = null;\n const config = await resolveConfig(\n {root: cwd, mode: 'development', logLevel: 'error'},\n 'serve',\n );\n const recorded = lastClientDepScan.current as\n import('../client-dep-includes.js').RecordedClientDepScan | null;\n if (recorded && path.resolve(recorded.cwd) === path.resolve(cwd)) {\n return {appInclude: recorded.appInclude, scan: recorded.scan};\n }\n // The app does not use createViteConfig (or turned the generation off): scan\n // what it excludes, with the workspaces the helper would have discovered.\n const {discoverWorkspaces} = await import('../vite-config.js');\n const optimizeDeps = config.optimizeDeps ?? {};\n return {\n appInclude: optimizeDeps.include ?? [],\n scan: await scanLinkedClientDeps(optimizeDeps.exclude ?? [], {\n cwd,\n sourceWorkspaces: await discoverWorkspaces([], cwd),\n }),\n };\n}\n\nexport async function runDoctor(options: DoctorOptions = {}): Promise<void> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const started = performance.now();\n const {appInclude, scan} = await loadAppScan(cwd);\n const findings = await diagnose({cwd, appInclude, scan});\n for (const f of findings) {\n (f.level === 'warn' ? console.warn : console.log)(\n `${f.level === 'warn' ? 'warning' : 'note'}: ${f.message}`,\n );\n }\n const warnings = findings.filter((f) => f.level === 'warn').length;\n console.log(\n `linked doctor: ${warnings} warning${warnings === 1 ? '' : 's'}; ` +\n `${scan.entries.length} client dependencies of ${scan.frameworkPackages.length} linked packages ` +\n `generated for optimizeDeps.include (${Math.round(performance.now() - started)}ms)`,\n );\n process.exitCode = warnings ? 1 : 0;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Framework packages that MUST be single-instance per runtime — they hold
3
+ * module-level state (`@_linked/core`'s shape registry, `LinkedStorage`, the query
4
+ * context) or register shapes into it. Two copies in one runtime split that state
5
+ * and mangle shape identity (`Person`→`Person2`). This ONE list is the single source
6
+ * of truth for the standalone `optimizeDeps.exclude` (`linkedDeps`). In workspace mode
7
+ * `ssr.noExternal` is keyed on the discovered source workspaces instead (see
8
+ * `ssrNoExternal`), so published framework packages stay external and single-instance
9
+ * under Node.
10
+ */
11
+ export declare const FRAMEWORK_PKG_PATTERNS: RegExp[];
12
+ export declare const isFrameworkPkg: (name: string) => boolean;
13
+ export declare function isWorkspaceRoot(dir: string): Promise<boolean>;
14
+ export declare function readInstalledPkg(name: string, fromDir: string): Promise<{
15
+ root: string;
16
+ json: any;
17
+ } | null>;
18
+ //# sourceMappingURL=installed-packages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installed-packages.d.ts","sourceRoot":"","sources":["../../src/installed-packages.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAA+B,CAAC;AAC3E,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,OACM,CAAC;AAUrD,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAC,GAAG,IAAI,CAAC,CAgB3C"}
@@ -0,0 +1,66 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ // Locating installed packages the way Node does, shared by the Vite config
11
+ // helper and `linked doctor`.
12
+ import fsExtra from 'fs-extra';
13
+ import path from 'node:path';
14
+ /**
15
+ * Framework packages that MUST be single-instance per runtime — they hold
16
+ * module-level state (`@_linked/core`'s shape registry, `LinkedStorage`, the query
17
+ * context) or register shapes into it. Two copies in one runtime split that state
18
+ * and mangle shape identity (`Person`→`Person2`). This ONE list is the single source
19
+ * of truth for the standalone `optimizeDeps.exclude` (`linkedDeps`). In workspace mode
20
+ * `ssr.noExternal` is keyed on the discovered source workspaces instead (see
21
+ * `ssrNoExternal`), so published framework packages stay external and single-instance
22
+ * under Node.
23
+ */
24
+ export const FRAMEWORK_PKG_PATTERNS = [/^@_linked\//, /^lincd-/];
25
+ export const isFrameworkPkg = (name) => FRAMEWORK_PKG_PATTERNS.some((re) => re.test(name));
26
+ // Resolve a dependency name to its installed package.json the way Node does:
27
+ // look in `<dir>/node_modules/<name>`, then each parent directory's
28
+ // node_modules, starting from the requiring package's directory. This finds
29
+ // deps that npm/yarn workspaces HOISTED to the monorepo root (an app under
30
+ // `services/api` whose dep lives in `<root>/node_modules`). The walk stops
31
+ // after the nearest directory whose package.json declares `workspaces` (the
32
+ // workspace root), or at the filesystem root. Returns null when the package
33
+ // isn't installed (e.g. an optional dep) — we skip rather than throw.
34
+ export function isWorkspaceRoot(dir) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ try {
37
+ const json = yield fsExtra.readJson(path.join(dir, 'package.json'));
38
+ return !!json.workspaces;
39
+ }
40
+ catch (_a) {
41
+ return false;
42
+ }
43
+ });
44
+ }
45
+ export function readInstalledPkg(name, fromDir) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ let dir = path.resolve(fromDir);
48
+ while (true) {
49
+ const root = path.join(dir, 'node_modules', name);
50
+ const pkgJson = path.join(root, 'package.json');
51
+ if (yield fsExtra.pathExists(pkgJson)) {
52
+ try {
53
+ return { root, json: yield fsExtra.readJson(pkgJson) };
54
+ }
55
+ catch (_a) {
56
+ return null;
57
+ }
58
+ }
59
+ const parent = path.dirname(dir);
60
+ if (parent === dir || (yield isWorkspaceRoot(dir)))
61
+ return null;
62
+ dir = parent;
63
+ }
64
+ });
65
+ }
66
+ //# sourceMappingURL=installed-packages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installed-packages.js","sourceRoot":"","sources":["../../src/installed-packages.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2EAA2E;AAC3E,8BAA8B;AAC9B,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAa,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAW,EAAE,CACtD,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAErD,6EAA6E;AAC7E,oEAAoE;AACpE,4EAA4E;AAC5E,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,sEAAsE;AACtE,MAAM,UAAgB,eAAe,CAAC,GAAW;;QAC/C,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC;YACpE,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CAAA;AAED,MAAM,UAAgB,gBAAgB,CACpC,IAAY,EACZ,OAAe;;QAEf,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YAChD,IAAI,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC;oBACH,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAC,CAAC;gBACvD,CAAC;gBAAC,WAAM,CAAC;oBACP,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACjC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,eAAe,CAAC,GAAG,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAC;YAChE,GAAG,GAAG,MAAM,CAAC;QACf,CAAC;IACH,CAAC;CAAA","sourcesContent":["// Locating installed packages the way Node does, shared by the Vite config\n// helper and `linked doctor`.\nimport fsExtra from 'fs-extra';\nimport path from 'node:path';\n\n/**\n * Framework packages that MUST be single-instance per runtime — they hold\n * module-level state (`@_linked/core`'s shape registry, `LinkedStorage`, the query\n * context) or register shapes into it. Two copies in one runtime split that state\n * and mangle shape identity (`Person`→`Person2`). This ONE list is the single source\n * of truth for the standalone `optimizeDeps.exclude` (`linkedDeps`). In workspace mode\n * `ssr.noExternal` is keyed on the discovered source workspaces instead (see\n * `ssrNoExternal`), so published framework packages stay external and single-instance\n * under Node.\n */\nexport const FRAMEWORK_PKG_PATTERNS: RegExp[] = [/^@_linked\\//, /^lincd-/];\nexport const isFrameworkPkg = (name: string): boolean =>\n FRAMEWORK_PKG_PATTERNS.some((re) => re.test(name));\n\n// Resolve a dependency name to its installed package.json the way Node does:\n// look in `<dir>/node_modules/<name>`, then each parent directory's\n// node_modules, starting from the requiring package's directory. This finds\n// deps that npm/yarn workspaces HOISTED to the monorepo root (an app under\n// `services/api` whose dep lives in `<root>/node_modules`). The walk stops\n// after the nearest directory whose package.json declares `workspaces` (the\n// workspace root), or at the filesystem root. Returns null when the package\n// isn't installed (e.g. an optional dep) — we skip rather than throw.\nexport async function isWorkspaceRoot(dir: string): Promise<boolean> {\n try {\n const json = await fsExtra.readJson(path.join(dir, 'package.json'));\n return !!json.workspaces;\n } catch {\n return false;\n }\n}\n\nexport async function readInstalledPkg(\n name: string,\n fromDir: string,\n): Promise<{root: string; json: any} | null> {\n let dir = path.resolve(fromDir);\n while (true) {\n const root = path.join(dir, 'node_modules', name);\n const pkgJson = path.join(root, 'package.json');\n if (await fsExtra.pathExists(pkgJson)) {\n try {\n return {root, json: await fsExtra.readJson(pkgJson)};\n } catch {\n return null;\n }\n }\n const parent = path.dirname(dir);\n if (parent === dir || (await isWorkspaceRoot(dir))) return null;\n dir = parent;\n }\n}\n"]}
@@ -50,6 +50,13 @@ export interface ShapeReferenceReport {
50
50
  unresolved: UnresolvedShapeReference[];
51
51
  /** Unresolved references that match {@link KNOWN_UNRESOLVED}. */
52
52
  known: UnresolvedShapeReference[];
53
+ /**
54
+ * The package's own shapes (by IRI) registered after loading each module on
55
+ * its own, keyed like {@link modules}. Read before the probe loads any entry
56
+ * for its second look, so it is exactly what that one module registers.
57
+ * Modules that threw are absent.
58
+ */
59
+ registered: Record<string, string[]>;
53
60
  /** Set when the registry could not be inspected, so nothing was checked. */
54
61
  skipped?: string;
55
62
  }
@@ -61,12 +68,8 @@ export interface ShapeReferenceReport {
61
68
  * accepted design. No package was found with a legitimate reason to leave a
62
69
  * reference unresolved; add an opt-out mechanism when one turns up.
63
70
  *
64
- * - `@_linked/core`: `PropertyShape.in` names `List` by `[package, name]`
65
- * because `List`'s module depends on the SHACL shapes. Only core's entry
66
- * loads `List`, so a process that deep-imports core without its entry cannot
67
- * traverse `sh:in`. Tracked as core's backlog-045; core builds with `linked
68
- * build-all`, which must not fail on it meanwhile. Remove this entry once
69
- * core registers `List` wherever `PropertyShape` is registered.
71
+ * Empty: `@_linked/core`'s `PropertyShape.in -> List`, the one entry this held,
72
+ * is fixed in core (List is registered wherever PropertyShape is).
70
73
  */
71
74
  export declare const KNOWN_UNRESOLVED: {
72
75
  package: string;
@@ -91,7 +94,7 @@ export declare const inspectShapeReferences: (packagePath: string, { concurrency
91
94
  * bug the package would ship, and it only surfaces in a consumer's bundle. The
92
95
  * references in {@link KNOWN_UNRESOLVED} warn instead.
93
96
  */
94
- export declare const checkShapeReferences: (packagePath: string, options?: Parameters<typeof inspectShapeReferences>[1]) => Promise<true | string | {
97
+ export declare const checkShapeReferences: (packagePath: string, options?: Parameters<typeof inspectShapeReferences>[1], inspection?: Promise<ShapeReferenceReport>) => Promise<true | string | {
95
98
  error: string;
96
99
  }>;
97
100
  //# sourceMappingURL=shapeReferences.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"shapeReferences.d.ts","sourceRoot":"","sources":["../../../src/utils/shapeReferences.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAAC;IAClE,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,oBAAoB,EAAE,C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resShape } from './shapeNames.js';
20
20
  * accepted design. No package was found with a legitimate reason to leave a
21
21
  * reference unresolved; add an opt-out mechanism when one turns up.
22
22
  *
23
- * - `@_linked/core`: `PropertyShape.in` names `List` by `[package, name]`
24
- * because `List`'s module depends on the SHACL shapes. Only core's entry
25
- * loads `List`, so a process that deep-imports core without its entry cannot
26
- * traverse `sh:in`. Tracked as core's backlog-045; core builds with `linked
27
- * build-all`, which must not fail on it meanwhile. Remove this entry once
28
- * core registers `List` wherever `PropertyShape` is registered.
23
+ * Empty: `@_linked/core`'s `PropertyShape.in -> List`, the one entry this held,
24
+ * is fixed in core (List is registered wherever PropertyShape is).
29
25
  */
30
- export const KNOWN_UNRESOLVED = [
31
- {
32
- package: '@_linked/core',
33
- shape: '/shape/core/PropertyShape',
34
- property: 'in',
35
- valueShape: '/shape/core/List',
36
- },
37
- ];
26
+ export const KNOWN_UNRESOLVED = [];
38
27
  /** arch-02: the `{slug}` in `{baseUri}shape/{slug}/{Name}`. Mirrors core's `packageNameToSlug`. */
39
28
  export const packageNameToSlug = (packageName) => packageName
40
29
  .replace(/^@[^/]+\//, '')
@@ -72,7 +61,7 @@ const PROBE = `
72
61
  import {register} from 'node:module';
73
62
  register('data:text/javascript,' + encodeURIComponent(${JSON.stringify(ASSET_HOOK)}));
74
63
  const MARK = '__LINKED_SHAPE_REFERENCES__';
75
- const out = {error: null, unresolved: [], registry: true};
64
+ const out = {error: null, unresolved: [], registry: true, registered: []};
76
65
  const reg = () => globalThis.__linkedShapeRegistry;
77
66
  const ownSlug = process.env.LINKED_PROBE_SLUG;
78
67
  const report = () => {
@@ -84,6 +73,10 @@ try {
84
73
  if (!r || !r.nodeShapeRegistry) {
85
74
  out.registry = false;
86
75
  } else {
76
+ // Before the second look below: that loads whole entries and would add theirs.
77
+ for (const id of r.nodeShapeRegistry.keys()) {
78
+ if (id.includes('/shape/' + ownSlug + '/')) out.registered.push(id);
79
+ }
87
80
  for (const [id, ns] of r.nodeShapeRegistry) {
88
81
  if (!id.includes('/shape/' + ownSlug + '/')) continue;
89
82
  for (const ps of ns.propertyShapes || []) {
@@ -135,7 +128,7 @@ const runProbe = (modulePath, packagePath, env, timeoutMs) => new Promise((resol
135
128
  ? `did not finish loading within ${timeoutMs}ms`
136
129
  : String(stderr).trim().split('\n').slice(-4).join('\n') ||
137
130
  String(err || 'exited without reporting');
138
- resolve({ error: why, registry: true, unresolved: [] });
131
+ resolve({ error: why, registry: true, registered: [], unresolved: [] });
139
132
  });
140
133
  });
141
134
  /** Every compiled module that declares a shape: all of `shapes/`, plus decorated classes elsewhere. */
@@ -191,6 +184,7 @@ export const inspectShapeReferences = (packagePath_1, ...args_1) => __awaiter(vo
191
184
  loadErrors: [],
192
185
  unresolved: [],
193
186
  known: [],
187
+ registered: {},
194
188
  };
195
189
  if (modules.length === 0)
196
190
  return report;
@@ -242,6 +236,7 @@ export const inspectShapeReferences = (packagePath_1, ...args_1) => __awaiter(vo
242
236
  report.loadErrors.push({ module, error: r.error });
243
237
  return;
244
238
  }
239
+ report.registered[module] = r.registered;
245
240
  for (const u of r.unresolved) {
246
241
  const key = `${u.shape}\u0000${u.property}\u0000${u.valueShape}`;
247
242
  const existing = byReference.get(key);
@@ -280,8 +275,8 @@ const describeReference = (ref) => {
280
275
  * bug the package would ship, and it only surfaces in a consumer's bundle. The
281
276
  * references in {@link KNOWN_UNRESOLVED} warn instead.
282
277
  */
283
- export const checkShapeReferences = (packagePath, options) => __awaiter(void 0, void 0, void 0, function* () {
284
- const report = yield inspectShapeReferences(packagePath, options);
278
+ export const checkShapeReferences = (packagePath, options, inspection) => __awaiter(void 0, void 0, void 0, function* () {
279
+ const report = yield (inspection !== null && inspection !== void 0 ? inspection : inspectShapeReferences(packagePath, options));
285
280
  if (report.skipped)
286
281
  return `skipped: ${report.skipped}`;
287
282
  const problems = [];