@_linked/cli 1.34.0 → 1.36.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 (36) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -2
  3. package/defaults/package/package.json +7 -12
  4. package/defaults/package/src/ontologies/example-ontology.ts +2 -8
  5. package/lib/esm/cli-methods.d.ts.map +1 -1
  6. package/lib/esm/cli-methods.js +0 -1
  7. package/lib/esm/cli-methods.js.map +1 -1
  8. package/lib/esm/cli.js +4 -13
  9. package/lib/esm/cli.js.map +1 -1
  10. package/lib/esm/client-dep-includes.d.ts +1 -1
  11. package/lib/esm/client-dep-includes.js +2 -2
  12. package/lib/esm/client-dep-includes.js.map +1 -1
  13. package/lib/esm/commands/{doctor.d.ts → app-doctor.d.ts} +11 -5
  14. package/lib/esm/commands/app-doctor.d.ts.map +1 -0
  15. package/lib/esm/commands/{doctor.js → app-doctor.js} +26 -4
  16. package/lib/esm/commands/app-doctor.js.map +1 -0
  17. package/lib/esm/index.d.ts +0 -1
  18. package/lib/esm/index.d.ts.map +1 -1
  19. package/lib/esm/index.js +0 -1
  20. package/lib/esm/index.js.map +1 -1
  21. package/lib/esm/installed-packages.js +1 -1
  22. package/lib/esm/installed-packages.js.map +1 -1
  23. package/lib/esm/launch.js +0 -0
  24. package/lib/esm/plugins/colors.d.ts +123 -0
  25. package/lib/esm/vite-config.d.ts +11 -2
  26. package/lib/esm/vite-config.d.ts.map +1 -1
  27. package/lib/esm/vite-config.js +65 -10
  28. package/lib/esm/vite-config.js.map +1 -1
  29. package/package.json +1 -1
  30. package/defaults/package/tsconfig-cjs.json +0 -8
  31. package/lib/esm/commands/doctor.d.ts.map +0 -1
  32. package/lib/esm/commands/doctor.js.map +0 -1
  33. package/lib/esm/commands/safe-yarn.d.ts +0 -13
  34. package/lib/esm/commands/safe-yarn.d.ts.map +0 -1
  35. package/lib/esm/commands/safe-yarn.js +0 -34
  36. package/lib/esm/commands/safe-yarn.js.map +0 -1
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  /**
11
- * `linked doctor` — check an app's dev dependency setup for the problems that
11
+ * `linked app-doctor` — check an app's dev dependency setup for the problems that
12
12
  * otherwise only show up in the browser.
13
13
  *
14
14
  * It loads the app's Vite config the way the dev server does, runs the same
@@ -26,6 +26,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
26
26
  * Hand-written include entries that the scan now generates are listed too, as
27
27
  * safe to delete.
28
28
  */
29
+ import fs from 'node:fs';
29
30
  import path from 'node:path';
30
31
  import semver from 'semver';
31
32
  import { readInstalledPkg } from '../installed-packages.js';
@@ -147,10 +148,31 @@ function loadAppScan(cwd) {
147
148
  };
148
149
  });
149
150
  }
150
- export function runDoctor() {
151
+ /** The config names `linked start` and `linked build-app` accept as "this is an app". */
152
+ const APP_VITE_CONFIGS = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];
153
+ /**
154
+ * Why `cwd` is not an app, or null when it is. Without this, Vite resolves an
155
+ * empty default config, the scan finds nothing, and the report says
156
+ * "0 warnings" — a clean bill of health for a directory that was never checked.
157
+ */
158
+ export function notAnAppReason(cwd) {
159
+ if (APP_VITE_CONFIGS.some((f) => fs.existsSync(path.join(cwd, f)))) {
160
+ return null;
161
+ }
162
+ return (`linked app-doctor: ${cwd} is not an app — no vite.config.{ts,js,mjs} found. ` +
163
+ 'Run it from the root of an app (the directory with its vite.config); ' +
164
+ 'it checks how the app uses linked packages, so there is nothing to check in a package.');
165
+ }
166
+ export function runAppDoctor() {
151
167
  return __awaiter(this, arguments, void 0, function* (options = {}) {
152
168
  var _a;
153
169
  const cwd = path.resolve((_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd());
170
+ const notAnApp = notAnAppReason(cwd);
171
+ if (notAnApp) {
172
+ console.error(notAnApp);
173
+ process.exitCode = 1;
174
+ return;
175
+ }
154
176
  const started = performance.now();
155
177
  const { appInclude, scan } = yield loadAppScan(cwd);
156
178
  const findings = yield diagnose({ cwd, appInclude, scan });
@@ -158,10 +180,10 @@ export function runDoctor() {
158
180
  (f.level === 'warn' ? console.warn : console.log)(`${f.level === 'warn' ? 'warning' : 'note'}: ${f.message}`);
159
181
  }
160
182
  const warnings = findings.filter((f) => f.level === 'warn').length;
161
- console.log(`linked doctor: ${warnings} warning${warnings === 1 ? '' : 's'}; ` +
183
+ console.log(`linked app-doctor: ${warnings} warning${warnings === 1 ? '' : 's'}; ` +
162
184
  `${scan.entries.length} client dependencies of ${scan.frameworkPackages.length} linked packages ` +
163
185
  `generated for optimizeDeps.include (${Math.round(performance.now() - started)}ms)`);
164
186
  process.exitCode = warnings ? 1 : 0;
165
187
  });
166
188
  }
167
- //# sourceMappingURL=doctor.js.map
189
+ //# sourceMappingURL=app-doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-doctor.js","sourceRoot":"","sources":["../../../src/commands/app-doctor.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,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,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,OAAO,CAAC,CAAC;QACnB,IAAI,OAAO,GAAG,GAAG,CAAC;QAClB,KAAK,I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AAI,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 app-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 fs from 'node:fs';\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 AppDoctorFinding {\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<AppDoctorFinding[]> {\n const findings: AppDoctorFinding[] = [];\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 AppDoctorOptions {\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\n/** The config names `linked start` and `linked build-app` accept as \"this is an app\". */\nconst APP_VITE_CONFIGS = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n/**\n * Why `cwd` is not an app, or null when it is. Without this, Vite resolves an\n * empty default config, the scan finds nothing, and the report says\n * \"0 warnings\" — a clean bill of health for a directory that was never checked.\n */\nexport function notAnAppReason(cwd: string): string | null {\n if (APP_VITE_CONFIGS.some((f) => fs.existsSync(path.join(cwd, f)))) {\n return null;\n }\n return (\n `linked app-doctor: ${cwd} is not an app — no vite.config.{ts,js,mjs} found. ` +\n 'Run it from the root of an app (the directory with its vite.config); ' +\n 'it checks how the app uses linked packages, so there is nothing to check in a package.'\n );\n}\n\nexport async function runAppDoctor(options: AppDoctorOptions = {}): Promise<void> {\n const cwd = path.resolve(options.cwd ?? process.cwd());\n const notAnApp = notAnAppReason(cwd);\n if (notAnApp) {\n console.error(notAnApp);\n process.exitCode = 1;\n return;\n }\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 app-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"]}
@@ -3,7 +3,6 @@ export * from './utils.js';
3
3
  export { defineConfig } from './defineConfig.js';
4
4
  export type { LinkedConfig, LinkedServerConfig } from './interfaces.js';
5
5
  export { buildPackageByPath } from './commands/build-package.js';
6
- export { safeYarn } from './commands/safe-yarn.js';
7
6
  export { setupPublish } from './commands/setup-publish.js';
8
7
  export { resolveBuildTarget } from './app-release/resolve-build-target.js';
9
8
  export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAE/D,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAC,YAAY,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAA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tB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,GAChB,MAAM,0CAA0C,CAAC"}
package/lib/esm/index.js CHANGED
@@ -3,7 +3,6 @@ export { default as tailwindConfig } from './tailwind.config.js';
3
3
  export * from './utils.js';
4
4
  export { defineConfig } from './defineConfig.js';
5
5
  export { buildPackageByPath } from './commands/build-package.js';
6
- export { safeYarn } from './commands/safe-yarn.js';
7
6
  export { setupPublish } from './commands/setup-publish.js';
8
7
  export { resolveBuildTarget } from './app-release/resolve-build-target.js';
9
8
  export { buildReleasePrefix, createReleaseManifest, getCacheControl, releaseBaseURL, releaseObjectKey, releaseStaticAccessURL, resolveReleaseIdentity, resolveSourceRevision, serializeReleaseManifest, writeReleaseManifest, DEFAULT_RELEASE_PREFIX, ENTRY_CACHE_CONTROL, IMMUTABLE_CACHE_CONTROL, MANIFEST_SOURCE_PATH, VITE_OUTPUT_DIR, } from './app-release/create-release-manifest.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC/D,+CAA+C;AAC/C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC","sourcesContent":["export {default as tailwindConfig} from './tailwind.config.js';\n// export {buildMetadata} from './metadata.js';\nexport * from './utils.js';\nexport {defineConfig} from './defineConfig.js';\nexport type {LinkedConfig, LinkedServerConfig} from './interfaces.js';\n\nexport {buildPackageByPath} from './commands/build-package.js';\nexport {safeYarn} from './commands/safe-yarn.js';\nexport {setupPublish} from './commands/setup-publish.js';\nexport {resolveBuildTarget} from './app-release/resolve-build-target.js';\nexport {\n buildReleasePrefix,\n createReleaseManifest,\n getCacheControl,\n releaseBaseURL,\n releaseObjectKey,\n releaseStaticAccessURL,\n resolveReleaseIdentity,\n resolveSourceRevision,\n serializeReleaseManifest,\n writeReleaseManifest,\n DEFAULT_RELEASE_PREFIX,\n ENTRY_CACHE_CONTROL,\n IMMUTABLE_CACHE_CONTROL,\n MANIFEST_SOURCE_PATH,\n VITE_OUTPUT_DIR,\n} from './app-release/create-release-manifest.js';\nexport {resolveDeclaredStaticAssets} from './app-release/static-assets.js';\nexport {\n loadReleaseManifest,\n planReleasePublish,\n publishRelease,\n} from './app-release/publisher.js';\nexport {\n normalizeAccessURL,\n resolveAppAssetsStore,\n} from './app-release/app-assets-store.js';\nexport {buildViteApp, hasViteConfig} from './commands/build-app.js';\nexport {publishApp} from './commands/publish-app.js';\nexport {\n serveCompiledApp,\n validateCompiledAppArtifacts,\n} from './commands/serve-app.js';\nexport {\n joinObjectKey,\n joinStaticAssetUrl,\n normalizeReleasePath,\n resolveExistingPathWithinRoot,\n} from './app-release/paths.js';\nexport type {\n AppBuildTarget,\n AppPublishConfig,\n BuildAppOptions,\n LinkedAppReleaseDestination,\n LinkedAppReleaseFile,\n LinkedAppReleaseManifest,\n PublishPlan,\n PublishResult,\n} from './app-release/types.js';\nexport type {\n CreateReleaseManifestOptions,\n ReleaseFileOrigin,\n ReleaseIdentity,\n} from './app-release/create-release-manifest.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC/D,+CAA+C;AAC/C,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uCAAuC,CAAC;AACzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,GAChB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAC,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAC;AACrD,OAAO,EACL,gBAAgB,EAChB,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,wBAAwB,CAAC","sourcesContent":["export {default as tailwindConfig} from './tailwind.config.js';\n// export {buildMetadata} from './metadata.js';\nexport * from './utils.js';\nexport {defineConfig} from './defineConfig.js';\nexport type {LinkedConfig, LinkedServerConfig} from './interfaces.js';\n\nexport {buildPackageByPath} from './commands/build-package.js';\nexport {setupPublish} from './commands/setup-publish.js';\nexport {resolveBuildTarget} from './app-release/resolve-build-target.js';\nexport {\n buildReleasePrefix,\n createReleaseManifest,\n getCacheControl,\n releaseBaseURL,\n releaseObjectKey,\n releaseStaticAccessURL,\n resolveReleaseIdentity,\n resolveSourceRevision,\n serializeReleaseManifest,\n writeReleaseManifest,\n DEFAULT_RELEASE_PREFIX,\n ENTRY_CACHE_CONTROL,\n IMMUTABLE_CACHE_CONTROL,\n MANIFEST_SOURCE_PATH,\n VITE_OUTPUT_DIR,\n} from './app-release/create-release-manifest.js';\nexport {resolveDeclaredStaticAssets} from './app-release/static-assets.js';\nexport {\n loadReleaseManifest,\n planReleasePublish,\n publishRelease,\n} from './app-release/publisher.js';\nexport {\n normalizeAccessURL,\n resolveAppAssetsStore,\n} from './app-release/app-assets-store.js';\nexport {buildViteApp, hasViteConfig} from './commands/build-app.js';\nexport {publishApp} from './commands/publish-app.js';\nexport {\n serveCompiledApp,\n validateCompiledAppArtifacts,\n} from './commands/serve-app.js';\nexport {\n joinObjectKey,\n joinStaticAssetUrl,\n normalizeReleasePath,\n resolveExistingPathWithinRoot,\n} from './app-release/paths.js';\nexport type {\n AppBuildTarget,\n AppPublishConfig,\n BuildAppOptions,\n LinkedAppReleaseDestination,\n LinkedAppReleaseFile,\n LinkedAppReleaseManifest,\n PublishPlan,\n PublishResult,\n} from './app-release/types.js';\nexport type {\n CreateReleaseManifestOptions,\n ReleaseFileOrigin,\n ReleaseIdentity,\n} from './app-release/create-release-manifest.js';\n"]}
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  // Locating installed packages the way Node does, shared by the Vite config
11
- // helper and `linked doctor`.
11
+ // helper and `linked app-doctor`.
12
12
  import fsExtra from 'fs-extra';
13
13
  import path from 'node:path';
14
14
  /**
@@ -1 +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,EAA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I,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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,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 app-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"]}
package/lib/esm/launch.js CHANGED
File without changes
@@ -0,0 +1,123 @@
1
+ // Type definitions for Colors.js 0.6.0-1
2
+ // Project: https://github.com/Marak/colors.js
3
+ // Definitions by: Bart van der Schoor <https://github.com/Bartvds>
4
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+
6
+ declare module 'colors' {
7
+ interface Color {
8
+ black: Color;
9
+ red: Color;
10
+ green: Color;
11
+ yellow: Color;
12
+ blue: Color;
13
+ magenta: Color;
14
+ cyan: Color;
15
+ white: Color;
16
+ gray: Color;
17
+ grey: Color;
18
+ bgBlack: Color;
19
+ bgRed: Color;
20
+ bgGreen: Color;
21
+ bgYellow: Color;
22
+ bgBlue: Color;
23
+ bgMagenta: Color;
24
+ bgCyan: Color;
25
+ bgWhite: Color;
26
+ reset: Color;
27
+ bold: Color;
28
+ dim: Color;
29
+ italic: Color;
30
+ underline: Color;
31
+ inverse: Color;
32
+ hidden: Color;
33
+ strikethrough: Color;
34
+ rainbow: Color;
35
+ zebra: Color;
36
+ america: Color;
37
+ trap: Color;
38
+ random: Color;
39
+ zalgo: Color;
40
+
41
+ (text: string): string;
42
+ }
43
+
44
+ namespace e {
45
+ export function setTheme(theme: any): void;
46
+
47
+ export var black: Color;
48
+ export var red: Color;
49
+ export var green: Color;
50
+ export var yellow: Color;
51
+ export var blue: Color;
52
+ export var magenta: Color;
53
+ export var cyan: Color;
54
+ export var white: Color;
55
+ export var gray: Color;
56
+ export var grey: Color;
57
+
58
+ export var bgBlack: Color;
59
+ export var bgRed: Color;
60
+ export var bgGreen: Color;
61
+ export var bgYellow: Color;
62
+ export var bgBlue: Color;
63
+ export var bgMagenta: Color;
64
+ export var bgCyan: Color;
65
+ export var bgWhite: Color;
66
+
67
+ export var reset: Color;
68
+ export var bold: Color;
69
+ export var dim: Color;
70
+ export var italic: Color;
71
+ export var underline: Color;
72
+ export var inverse: Color;
73
+ export var hidden: Color;
74
+ export var strikethrough: Color;
75
+
76
+ export var rainbow: Color;
77
+ export var zebra: Color;
78
+ export var america: Color;
79
+ export var trap: Color;
80
+ export var random: Color;
81
+ export var zalgo: Color;
82
+ }
83
+
84
+ export = e;
85
+ }
86
+
87
+ interface String {
88
+ black: string;
89
+ red: string;
90
+ green: string;
91
+ yellow: string;
92
+ blue: string;
93
+ magenta: string;
94
+ cyan: string;
95
+ white: string;
96
+ gray: string;
97
+ grey: string;
98
+
99
+ bgBlack: string;
100
+ bgRed: string;
101
+ bgGreen: string;
102
+ bgYellow: string;
103
+ bgBlue: string;
104
+ bgMagenta: string;
105
+ bgCyan: string;
106
+ bgWhite: string;
107
+
108
+ reset: string;
109
+ // bold: string;
110
+ dim: string;
111
+ italic: string;
112
+ underline: string;
113
+ inverse: string;
114
+ hidden: string;
115
+ strikethrough: string;
116
+
117
+ rainbow: string;
118
+ zebra: string;
119
+ america: string;
120
+ trap: string;
121
+ random: string;
122
+ zalgo: string;
123
+ }
@@ -99,7 +99,7 @@ export interface LinkedViteConfigOptions {
99
99
  deny?: (string | RegExp)[];
100
100
  };
101
101
  }
102
- interface WorkspaceEntry {
102
+ export interface WorkspaceEntry {
103
103
  name: string;
104
104
  srcDir: string;
105
105
  }
@@ -163,6 +163,16 @@ export declare function discoverLinkedSourceDependencies(cwd?: string): Promise<
163
163
  * dependencies for.
164
164
  */
165
165
  export declare function discoverWorkspaces(extraGlobs?: string[], cwd?: string): Promise<WorkspaceEntry[]>;
166
+ /**
167
+ * Resolve a bare specifier like `@_linked/foo/bar`, `lincd-rdfs/Foo`, or
168
+ * `pkg/utils/Bar.js` against the workspace lookup. Tries the file name first:
169
+ * .tsx, .ts, then the literal file (for files that already include an
170
+ * extension or for non-TS assets). When the name matches no file, falls back to
171
+ * the workspace's `exports` map (see `resolveViaWorkspaceExports`). Returns null
172
+ * when the specifier doesn't match any workspace package or no candidate exists
173
+ * on disk.
174
+ */
175
+ export declare function resolveWorkspaceSpecifier(specifier: string, workspaces: WorkspaceEntry[]): Promise<string | null>;
166
176
  /**
167
177
  * Packages whose entry `linked start` hands to `vite.ssrLoadModule` by name
168
178
  * (`@_linked/server/shapes/LinkedServer`, see `commands/start.ts`).
@@ -199,5 +209,4 @@ export declare function ssrNoExternal(workspaces: {
199
209
  */
200
210
  export declare function clientDefine(opts?: Pick<LinkedViteConfigOptions, 'define' | 'port'>): Record<string, string>;
201
211
  export declare function createViteConfig(opts?: LinkedViteConfigOptions): ReturnType<typeof defineConfig>;
202
- export {};
203
212
  //# sourceMappingURL=vite-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-config.d.ts","sourceRoot":"","sources":["../../src/vite-config.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,YAAY,EAAC,MAAM,MAAM,CAAC;AAUlC,OAAO,KAAK,EAAC,MAAM,EAAa,MAAM,MAAM,CAAC;AAS7C;;;;;;;;;;;;;;;GAeG;AACH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,KAAG,MAAM,GAAG,SAyDtD,CAAC;AAEF,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAQnD;AAKD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUxE;AAWD,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,UAAU,CAAC,OAAO,YAAY,CAAC,CAmYpG"}
@@ -30,7 +30,7 @@ import { generateScopedNameProduction } from './css-module-names.js';
30
30
  import { parseWorkspacePatterns, isWorkspacePathNegated } from './workspace-globs.js';
31
31
  import { pinCompiledClassNames } from './plugins/pin-compiled-class-names.js';
32
32
  import { isFrameworkPkg, readInstalledPkg } from './installed-packages.js';
33
- import { linkedClientDepIncludesPlugin } from './client-dep-includes.js';
33
+ import { linkedClientDepIncludesPlugin, resolveExportsSubpath, } from './client-dep-includes.js';
34
34
  /** Default dev server port, and Vite's default HMR websocket port. */
35
35
  const DEFAULT_DEV_PORT = 4040;
36
36
  const DEFAULT_HMR_PORT = 24678;
@@ -443,14 +443,68 @@ export function discoverWorkspaces() {
443
443
  return out;
444
444
  });
445
445
  }
446
+ const isFile = (p) => __awaiter(void 0, void 0, void 0, function* () {
447
+ return fsExtra
448
+ .stat(p)
449
+ .then((st) => st.isFile())
450
+ .catch(() => false);
451
+ });
452
+ /**
453
+ * Map a `lib/esm` file back to its source under `srcDir`: `.js`/`.jsx` probe
454
+ * `.tsx` then `.ts`, anything else (css, json, ...) is taken literally.
455
+ */
456
+ function libTargetToSource(srcDir, rel) {
457
+ return __awaiter(this, void 0, void 0, function* () {
458
+ if (/\.jsx?$/.test(rel)) {
459
+ const base = path.join(srcDir, rel.replace(/\.jsx?$/, ''));
460
+ for (const ext of ['.tsx', '.ts']) {
461
+ if (yield isFile(base + ext))
462
+ return base + ext;
463
+ }
464
+ return null;
465
+ }
466
+ const literal = path.join(srcDir, rel);
467
+ return (yield isFile(literal)) ? literal : null;
468
+ });
469
+ }
470
+ /**
471
+ * The name-based lookup's fallback: resolve `subpath` (`.` or `./x/y`) through
472
+ * the workspace's own `exports` under `import`/`default`, and map a
473
+ * `./lib/esm/...` target to the same path under src. This is what reaches
474
+ * source for a subpath whose export key does not match a file name
475
+ * (`@_linked/translation/key-sync/node` -> `lib/esm/key-sync-node.js` ->
476
+ * `src/key-sync-node.ts`), a directory subpath (`./conformance` ->
477
+ * `lib/esm/conformance/index.js`), or a bare name whose src has no index.
478
+ * Without it such a specifier falls through to Vite, which picks the package's
479
+ * `lib/esm` copy while the rest of the package comes from src: two instances of
480
+ * every module-level registry. It must not depend on a `development` -> src
481
+ * condition, because src/ is not published and packages do not declare one.
482
+ */
483
+ function resolveViaWorkspaceExports(ws, subpath) {
484
+ return __awaiter(this, void 0, void 0, function* () {
485
+ let json;
486
+ try {
487
+ json = yield fsExtra.readJson(path.join(path.dirname(ws.srcDir), 'package.json'));
488
+ }
489
+ catch (_a) {
490
+ return null;
491
+ }
492
+ const target = resolveExportsSubpath(json, subpath, ['import', 'default']);
493
+ if (!target || !target.startsWith('./lib/esm/'))
494
+ return null;
495
+ return libTargetToSource(ws.srcDir, target.slice('./lib/esm/'.length));
496
+ });
497
+ }
446
498
  /**
447
499
  * Resolve a bare specifier like `@_linked/foo/bar`, `lincd-rdfs/Foo`, or
448
- * `pkg/utils/Bar.js` against the workspace lookup. Tries extensions in
449
- * order: .ts, .tsx, then the literal id (for files that already include
450
- * an extension or for non-TS assets). Returns null when the specifier
451
- * doesn't match any workspace package or no candidate exists on disk.
500
+ * `pkg/utils/Bar.js` against the workspace lookup. Tries the file name first:
501
+ * .tsx, .ts, then the literal file (for files that already include an
502
+ * extension or for non-TS assets). When the name matches no file, falls back to
503
+ * the workspace's `exports` map (see `resolveViaWorkspaceExports`). Returns null
504
+ * when the specifier doesn't match any workspace package or no candidate exists
505
+ * on disk.
452
506
  */
453
- function resolveWorkspaceSpecifier(specifier, workspaces) {
507
+ export function resolveWorkspaceSpecifier(specifier, workspaces) {
454
508
  return __awaiter(this, void 0, void 0, function* () {
455
509
  for (const ws of workspaces) {
456
510
  if (specifier === ws.name) {
@@ -459,7 +513,7 @@ function resolveWorkspaceSpecifier(specifier, workspaces) {
459
513
  if (yield fsExtra.pathExists(p))
460
514
  return p;
461
515
  }
462
- return null;
516
+ return resolveViaWorkspaceExports(ws, '.');
463
517
  }
464
518
  if (specifier.startsWith(ws.name + '/')) {
465
519
  const subpath = specifier.slice(ws.name.length + 1);
@@ -472,11 +526,12 @@ function resolveWorkspaceSpecifier(specifier, workspaces) {
472
526
  return p;
473
527
  }
474
528
  // Files that already include an extension Vite handles (.css, .json,
475
- // .svg, etc.) — return the literal path under src.
529
+ // .svg, etc.) — return the literal path under src. A FILE only: a
530
+ // directory of the same name is a directory subpath, left to `exports`.
476
531
  const literal = path.join(ws.srcDir, subpath);
477
- if (yield fsExtra.pathExists(literal))
532
+ if (yield isFile(literal))
478
533
  return literal;
479
- return null;
534
+ return resolveViaWorkspaceExports(ws, './' + subpath);
480
535
  }
481
536
  }
482
537
  return null;