-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(build): exclude config files from production DTS rollup #10358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TkDodo
merged 9 commits into
TanStack:main
from
ma-cote:fix/exclude-config-files-from-prod-dts
Apr 1, 2026
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2983d9f
fix(build): exclude config files from production DTS rollup
ma-cote 58feb9e
chore: add changeset for DTS type pollution fix
ma-cote caad915
test(build): add regression test for build tool type leaks in .d.ts f…
ma-cote 84b16af
fix(build): fail fast when no .d.ts files found in verify-dts-imports
ma-cote d564c9f
chore: add exclude for consistency in react-query-next-experimental
ma-cote 3f0e4a5
chore: fix log message to mention both .d.ts and .d.cts files
ma-cote 1996cc9
ci: apply automated fixes
autofix-ci[bot] 668d758
chore: remove verify-dts-imports script and related package.json changes
ma-cote 29b8de7
Merge branch 'main' into fix/exclude-config-files-from-prod-dts
TkDodo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/react-query-devtools': patch | ||
| --- | ||
|
|
||
| fix(build): exclude config files from production DTS rollup to prevent `@types/node` type pollution |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { readFileSync } from 'node:fs' | ||
| import { glob } from 'tinyglobby' | ||
|
|
||
| const FORBIDDEN_PATTERNS = [ | ||
| /\bfrom\s+['"]vite['"]/, | ||
| /\bfrom\s+['"]tsup['"]/, | ||
| /\bfrom\s+['"]vitest/, | ||
| /\/\/\/\s*<reference\s+types=["']node["']\s*\/>/, | ||
| ] | ||
|
|
||
| const errors: Array<{ file: string; line: number; text: string }> = [] | ||
|
|
||
| const files = await glob(['packages/*/build/**/*.d.ts', 'packages/*/build/**/*.d.cts']) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| if (files.length === 0) { | ||
| console.error( | ||
| 'ERROR: No declaration files found under packages/*/build. Ensure the build step produced .d.ts outputs before verification.', | ||
| ) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| for (const file of files) { | ||
| const content = readFileSync(file, 'utf-8') | ||
| const lines = content.split('\n') | ||
| for (let i = 0; i < lines.length; i++) { | ||
| const line = lines[i]! | ||
| for (const pattern of FORBIDDEN_PATTERNS) { | ||
| if (pattern.test(line)) { | ||
| errors.push({ file, line: i + 1, text: line.trim() }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (errors.length > 0) { | ||
| console.error( | ||
| 'ERROR: Build tool types leaked into published .d.ts files:\n', | ||
| ) | ||
| for (const error of errors) { | ||
| console.error(` ${error.file}:${error.line}`) | ||
| console.error(` ${error.text}\n`) | ||
| } | ||
| console.error( | ||
| 'This usually means a tsconfig.prod.json is missing "include": ["src"].', | ||
| ) | ||
| console.error( | ||
| 'See https://github.com/TanStack/query/issues/10294 for details.', | ||
| ) | ||
| process.exit(1) | ||
| } else { | ||
| console.log( | ||
| `Verified ${files.length} declaration files (.d.ts/.d.cts) — no build tool type leaks found.`, | ||
| ) | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.