Closed as not planned
Closed as not planned
Description
Describe the bug
In TypeScript code, import statements of other .ts
files are written without the .ts
file extension, but in node (or browser) with ESM, a path including file extension is used. SWC should add a .js
file extension to relative imports from TS.
Input code
// foo.ts
const foo: string = "foo"
export { foo }
// index.ts
import someLib from "somLib"
import { foo } from "./foo"
console.log(foo)
Config
{
"$schema": "https://json.schemastore.org/swcrc",
"module": {
"type": "es6"
},
"jsc": {
"target": "es2022",
"parser": {
"syntax": "typescript"
}
}
}
Playground link
Expected behavior
SWC would transform relative imports without file extension from TypeScript to imports with .js
extension.
Actual behavior
SWC does not transform these import paths, so Node fails when running them.
Version
"@swc/core": "^1.2.220"
Additional context
I have to use ESM with Node because some of my dependencies only work with it.
May be related to #1934, not sure