fix: preserve original extension when extension redirection is disabled#1369
Merged
Timeless0911 merged 2 commits intomainfrom Dec 1, 2025
Merged
fix: preserve original extension when extension redirection is disabled#1369Timeless0911 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 the handling of import path extensions when extension redirection is disabled in bundleless mode. The fix ensures that when redirect.js.extension is set to false, the original file extensions in import statements are preserved rather than being forcibly replaced or removed.
Key Changes
- Modified extension redirection logic to preserve original JS extensions when redirection is disabled
- Fixed handling of unresolved modules to prevent incorrect extension manipulation
- Added comprehensive test coverage for various edge cases including
.node,.node.js,.node.tsextensions
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/config.ts |
Implements the core fix: preserves original extensions when jsRedirectExtension is false by checking if the original extension matches JS_EXTENSIONS_PATTERN; also fixes handling of unresolved modules to prevent processing |
tests/integration/redirect/js/src/index.ts |
Adds test cases for various extension scenarios including .node, .node.js, .node.ts, .js, and .ts extensions |
tests/integration/redirect/js/src/not-resolved.ts |
New test file with unresolved imports to verify they remain unchanged |
tests/integration/redirect/js/src/bar.node.ts |
New test file to support .node extension test cases |
tests/integration/redirect/js/tsconfig.json |
Adds noEmit and allowImportingTsExtensions to support importing files with .ts extensions in tests |
tests/integration/redirect/js.test.ts |
Adds test expectations verifying that original extensions are preserved when redirection is disabled |
website/docs/en/config/lib/redirect.mdx |
Updates English documentation to clarify extension redirection behavior |
website/docs/zh/config/lib/redirect.mdx |
Updates Chinese documentation to clarify extension redirection behavior |
packages/plugin-dts/README.md |
Updates plugin documentation for consistency with the improved behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ccbc162 to
8b45115
Compare
fi3ework
reviewed
Dec 1, 2025
1af913b to
fb05d47
Compare
fb05d47 to
e08f608
Compare
fi3ework
reviewed
Dec 1, 2025
fi3ework
approved these changes
Dec 1, 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
when
redirect.js.extensionset tofalsesource
before
now
Related Links
close: #1368
Checklist