Resolving .js paths in TS project #3529
-
// index.ts
import './file.js'; // <-- "wrong" extension // file.ts
console.log('hi') It seems that this basic example works in a new
Why would this be happening? The paths are correct, in fact it works if I replace .js with .tsx, but this shouldn't be necessary. |
Beta Was this translation helpful? Give feedback.
Answered by
chenjiahan
Sep 22, 2024
Replies: 1 comment
-
Rspack provides resolve.extensionAlias as a solution to TS extension alias. Example: export default defineConfig({
tools: {
rspack: {
resolve: {
extensionAlias: {
'.js': ['.ts', '.js'],
'.jsx': ['.tsx', '.jsx'],
},
},
},
},
}); We are considering adding this configuration by default in Rsbuild, until then, you can add it manually to solve this problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
SoonIter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rspack provides resolve.extensionAlias as a solution to TS extension alias.
Example:
We are considering adding this configuration by default in Rsbuild, until then, you can add it manually to solve this problem.