-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Describe the bug
Just started playing with SWC and I I'd just like to say this is an amazing tool. Just amazed how it's fast and how much work has been put into it. 🙏🏻
So, in my code, I have ~/........ import statements, but, once the SWC has done its magic, these are replaced with correct paths - only when I set "type": "commonjs" in my .swcrc file. Otherwise, they just stay the same.
Input code
So, this is the resulting code. As we can see, the import paths haven't changed (~ is still here).
But, if I were to use the commonjs module type, then I'd see the path built correctly:
Config
commonjs works (paths are changed correctly):
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2020",
"paths": {
"~/*": ["./src/*"]
},
"baseUrl": "."
},
"module": {
"type": "commonjs"
}
}This one does not work:
{
"jsc": {
"parser": {
"syntax": "typescript"
},
"target": "es2020",
"paths": {
"~/*": ["./src/*"]
},
"baseUrl": "."
}
}Expected behavior
The paths to be correctly replaced.
Version
The version of @swc/core: 1.2.102
Additional context
Checked a couple of issues reported by other users (#2126, #2050), those didn't provide any clues unfortunately.


