Skip to content

fix: allows importing TS files with .js extension#417

Merged
9aoy merged 1 commit intomainfrom
extensionAlias-ts
Jul 24, 2025
Merged

fix: allows importing TS files with .js extension#417
9aoy merged 1 commit intomainfrom
extensionAlias-ts

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Jul 24, 2025

Summary

allows importing TS files with .js extension by default.

Rsbuild allows importing TypeScript files with the .js extension when a tsconfig.path file exists. However, in the Rstest scenario, the workspace root directory may not have a tsconfig.path.

Related Links

https://github.com/web-infra-dev/rsbuild/blob/4fa7e847ec66f6f0c5f5518e46185ee69ad0b819/packages/core/src/plugins/resolve.ts#L132

Checklist

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

Copilot AI review requested due to automatic review settings July 24, 2025 06:55
Copy link
Copy Markdown
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 enables importing TypeScript files using .js extensions by default in Rstest environments. The change addresses a limitation where Rsbuild only allows .js extension imports for TypeScript files when a tsconfig.path file exists, which may not be present in Rstest workspace root directories.

  • Adds extensionAlias configuration to resolve .js imports to .js, .ts, and .tsx files
  • Adds extensionAlias configuration to resolve .jsx imports to .jsx and .tsx files
  • Updates test snapshots to reflect the new resolve configuration

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/core/src/core/plugins/basic.ts Implements the extensionAlias configuration for TypeScript file resolution
packages/core/tests/core/snapshots/rsbuild.test.ts.snap Updates test snapshots to include the new extensionAlias configuration

@netlify
Copy link
Copy Markdown

netlify bot commented Jul 24, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit ed75ae2
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/6881d8e06709490008bd3090
😎 Deploy Preview https://deploy-preview-417--rstest-dev.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.

@9aoy 9aoy merged commit 32d29d6 into main Jul 24, 2025
18 checks passed
@9aoy 9aoy deleted the extensionAlias-ts branch July 24, 2025 07:20
@9aoy 9aoy mentioned this pull request Jul 24, 2025
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