-
-
Notifications
You must be signed in to change notification settings - Fork 58
fix: preserve original extension when extension redirection is disabled #1369
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Summary
when
redirect.js.extensionset tofalsesource
before
now
Related Links
close: #1368
Checklist