fix(dts): check for existence of target path when redirect extension#1374
Merged
Timeless0911 merged 2 commits intomainfrom Dec 2, 2025
Merged
fix(dts): check for existence of target path when redirect extension#1374Timeless0911 merged 2 commits intomainfrom
Timeless0911 merged 2 commits intomainfrom
Conversation
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the DTS (TypeScript declaration) redirect functionality by checking for the existence of target paths before adding extensions to import statements. This prevents breaking imports for files that don't exist as TypeScript declarations (e.g., .svg files, type-only packages).
Key changes:
- Refactored the
addExtensionfunction to verify target path existence before adding extensions - Added comprehensive test coverage for edge cases including directory imports and type-only packages
- Updated documentation examples to use
.tsconfig files instead of.js
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/plugin-dts/src/utils.ts |
Refactored addExtension function to check path existence before adding extensions, preventing broken imports |
tests/integration/redirect/dts.test.ts |
Added test expectations for new config module and prebundle-types scenarios |
tests/integration/redirect/dtsTsgo.test.ts |
Added test expectations for new config module and prebundle-types scenarios |
tests/integration/redirect/dts/tsconfig.json |
Added prebundle-types path mapping for test coverage |
tests/integration/redirect/dts/src/index.ts |
Added exports for new test modules (config, prebundle-types) |
tests/integration/redirect/dts/src/config.ts |
New test file that re-exports from subdirectory |
tests/integration/redirect/dts/src/config/load.ts |
New test file with loadConfig function |
tests/integration/redirect/dts/compile/prebundle-types/ |
New test package with type-only declarations |
tests/integration/redirect/dts-tsgo/ |
Similar test additions for tsgo variant |
website/docs/en/config/lib/experiments.mdx |
Updated example config filename from .js to .ts |
website/docs/zh/config/lib/experiments.mdx |
Updated example config filename from .js to .ts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fi3ework
approved these changes
Dec 2, 2025
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.
Summary
Fix edge cases of
redirect.dts.extensionwhen the folder and the file have same name.Now we will check for existence of target path when redirect extension.
Related Links
Checklist