Skip to content

Conversation

@Timeless0911
Copy link
Contributor

@Timeless0911 Timeless0911 commented Nov 27, 2025

Summary

when redirect.js.extension set to false

source

export * from './bar.node';
export * from './bar.node.js';
export * from './bar.node.ts';
export * from './bar';
export * from './baz-folder';
export * from './foo.js';
export * from './foo.ts';

before

export * from "./bar.node.ts";
export * from "./bar.node.ts";
export * from "./bar.node.ts";
export * from "./baz.ts";
export * from "./baz-folder/index.ts";
export * from "./foo.ts";
export * from "./foo.ts";

now

export * from "./bar.node";
export * from "./bar.node.js";
export * from "./bar.node.ts";
export * from "./baz";
export * from "./baz-folder/index";
export * from "./foo.js";
export * from "./foo.ts";

Related Links

close: #1368

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 27, 2025 10:02
@netlify
Copy link

netlify bot commented Nov 27, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 8b45115
🔍 Latest deploy log https://app.netlify.com/projects/rslib/deploys/6928402b524f5300088e4042
😎 Deploy Preview https://deploy-preview-1369--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot finished reviewing on behalf of Timeless0911 November 27, 2025 10:05
Copy link
Contributor

Copilot AI left a 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.ts extensions

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants