Repository navigation
fix(build): use full relative paths in emitted type declarations - #1327
Merged
XOP merged 3 commits intoNov 27, 2026
Merged
Conversation
The package is "type": "module", so under moduleResolution node16/nodenext TypeScript reads dist/types/**/*.d.ts as ESM and needs explicit file paths. vite-plugin-dts copies the extensionless specifiers from src/, so nearly every export resolved to `any` (or failed with TS2834 when skipLibCheck is off). Rewrite relative specifiers in beforeWriteFile to `.js` or `/index.js`, using the matching src/ path to tell files from directories. Fixes ClickHouse#1310
Vitest's jsdom environment resolved the bare 'path' import to the npm 'path' polyfill, which calls util.isString, removed in Node 24.
🦋 Changeset detectedLatest commit: cdb0789 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Chromatic Storybook
Built from commit: Statuses as of the end of the run. The build link shows the live review state. |
ariser
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
vite-plugin-dtscopies extensionless relative specifiers fromsrc/intodist/types. Because the package is"type": "module", TypeScript treats those.d.tsfiles as ESM undermoduleResolution: "node16"/"nodenext"and can't resolve them, so exports silently becomeany.beforeWriteFilenow rewrites each relative specifier to./Foo.jsor./Foo/index.js. It checks the matchingsrc/path to tell files from directories, and leaves package imports and anything it can't match alone.plugins/dts-import-extensions.test.ts.Links and tickets
Fixes #1310
Good to know
Checked against a small consumer (
"type": "module",module/moduleResolution: "nodenext") that importsButton,ButtonProps,Pagination,useToastfrom/hooksandSelectfrom/Select, with deliberate type errors on each:skipLibCheck: trueany)skipLibCheck: falsedist/typesdist/typesmoduleResolution: "bundler"After the build, no relative specifier in
dist/typesis missing an extension.src/and the JS output are untouched.Checklist
Contribution
buildworks locally (build-storybooknot run: no component or story changes)Note
Low Risk
Build-time
.d.tspost-processing only; runtime JS andbundlerresolution are unchanged, with behavior covered by unit tests.Overview
Emitted
dist/typesdeclarations now get relative specifiers rewritten to full ESM paths (./Foo.js,./Foo/index.js) during thevite-plugin-dtswrite step, fixing TypeScript resolution undermoduleResolution: "node16"/"nodenext"where extensionless paths previously turned exports intoany.Adds
addDtsImportExtensionsinplugins/dts-import-extensions.ts, wired viabeforeWriteFileinvite.config.tsusing the matchingsrc/path to choose file vs directory targets; package imports and already-suffixed specifiers are unchanged. Vitest coverage lives inplugins/dts-import-extensions.test.ts. Patch changeset only—no runtime or visual changes for"bundler"consumers.Reviewed by Cursor Bugbot for commit cdb0789. Bugbot is set up for automated code reviews on this repo. Configure here.