feat: allow to import TS files with js extension#3536
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| if (tsconfigPath) { | ||
| // TypeScript allows importing TS files with `.js` extension | ||
| chain.resolve.extensionAlias.merge({ | ||
| '.js': ['.ts', '.tsx', '.js'], |
There was a problem hiding this comment.
Should we also add '.jsx': ['.jsx', '.tsx'] as the default extensionAlias?
There was a problem hiding this comment.
Agree, we can add '.jsx': ['.tsx', '.jsx'] to align with TypeScript. TS resolves .tsx first.
|
@chenjiahan did you consider NPM repos that are called Interestingly, on our CI, for 1.0.6 we are seeing failures importing Error |
|
Might be a bug of Rspack resolver, @SoonIter can you help to check it? |
|
@joesaunderson This error only appears when |
Hmm not sure, this was working fine on 1.0.5, but for a Dependabot change, where nothing else changes other than 1.0.6, it fails. It was also failing for 'tippy.js" which makes me think it's a bug, not a failure to install? I see an issue has been created, does that mean you can now replicate this? |
|
No, the issue is about improving the error logs. If you can provide a reproduction, that would be very helpful. |
|
I can replicate with just this minimal config: Config: TSConfig: File ( Error: |
|
@SoonIter you can help to check ⬆️ |
This reverts commit 880d337.
|
@chenjiahan I can confirm that on 1.0.7 this is now working, so your changes above (the revert) fixed that. Thanks. |


Summary
Allow to import TS files with
.jsextension, align the default behavior with TypeScript.Related Links
Checklist