fix(cli): generate proxy .d.ts files for TypeScript compilerOptions.types resolution#1165
fix(cli): generate proxy .d.ts files for TypeScript compilerOptions.types resolution#1165ryoppippi wants to merge 1 commit intovoidzero-dev:mainfrom
Conversation
…ypes resolution
TypeScript's compilerOptions.types field resolves package subpaths via the
filesystem directly, without consulting package.json exports. This means
"types": ["vite-plus/test/globals"] looks for node_modules/vite-plus/test/globals.d.ts
on disk, but that file didn't exist — the actual shim was at dist/test/globals.d.ts,
only reachable via the exports map.
vitest works because it places globals.d.ts at the package root, matching the
filesystem path TypeScript expects.
Fix: syncTestPackageExports() now also generates proxy .d.ts files at test/{name}.d.ts
for type-only exports (those with only a "types" field and no runtime JS). Each proxy
contains a triple-slash reference directive:
/// <reference types="@voidzero-dev/vite-plus-test/globals" />
Triple-slash reference types directives DO go through the exports field, so this
correctly delegates to the underlying package while being discoverable at the path
TypeScript expects for compilerOptions.types.
The generated test/ directory is gitignored and added to package.json files at
build time, so it is included in published packages.
✅ Deploy Preview for viteplus-preview canceled.
|
|
oh! how can i fix ci? i have no idea |
|
@ryoppippi |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex fix ci errror |
|
To use Codex here, create an environment for this repo. |
|
wtf!? |
|
@ryoppippi Do you have a code repository that can reproduce this issue? Could you provide it? I can add it to the ecosystem-ci as a continuous e2e test case. |
|
@fengmk2 hey! here is the repro! |
|
@ryoppippi Let me follow up on this issue, I need to make some changes to the current packages/test/BUNDLING.md. |
|
move to #1177 |
|
thank you |
Problem
TypeScript's
compilerOptions.typesfield resolves package subpaths via the filesystem directly, without consultingpackage.jsonexports. This means:...causes TypeScript to look for
node_modules/vite-plus/test/globals.d.tson disk. That file didn't exist — the actual shim was atdist/test/globals.d.ts, only reachable via theexportsmap.This is why
vitest/globalsworks: vitest placesglobals.d.tsat the package root, matching exactly what TypeScript expects.Fix
syncTestPackageExports()now also generates proxy.d.tsfiles attest/{name}.d.tsfor type-only exports (those with only atypesfield and no runtime JS). Each proxy contains a triple-slash reference:/// <reference types="@voidzero-dev/vite-plus-test/globals" />Triple-slash
reference typesdirectives do go through theexportsfield, so this correctly delegates to the underlying package while being discoverable at the filesystem path TypeScript expects forcompilerOptions.types.The generated
test/directory is gitignored and added topackage.jsonfilesat build time so it is included in published packages.