Closed MarkNjunge closed 1 year ago
It's not a problem with swc. Building via swc directly works. The issue arises when using nestjs.
@MarkNjunge did you tested with @nestjs/cli@10.0.0
or just with the latest version?
@micalevisk I've tested again after ensuring @nestjs/cli@10.0.0 and I'm still experience the same issue.
What if you remove paths from your tsconfig.json
file https://github.com/MarkNjunge/nest-swc-paths-issue/blob/master/tsconfig.json?
I've tried that it's still the same.
Temporarily fix by setting swcOptions to undefine and set paths
and baseUrl
in .swcrc.
Here is a demo.
For Windows users, path mapping (auto-inheriting baseUrl and paths from tsconfig by swc) was turned off in 10.1.16.
What's the correct config to get it to work? I've updated the dependencies and the issue persists.
I've updated the repo to reflect the changes. https://github.com/MarkNjunge/nest-swc-paths-issue
Temporarily fix by setting swcOptions to undefine and set
paths
andbaseUrl
in .swcrc. Here is a demo.
swcOptions
shouldn't be an object when use node to run @swc/cli on Windows.
As @powerfulyang suggested, I was able to get it to work by changing swcOptions
to undefined
.
FWIW I'm seeing absolute paths in *nix builds too after upgrading to the latest @nestjs/cli and @swc/core packages without having an .swrc file in my project. Everything was working great until all the recent movement.
Is there an existing issue for this?
Current behavior
Building using swc leads to imports that use paths to be absolute paths instead of relative ones.
Building using swc directly does not have the same issue
Since using swc directly does not have this issue, it is unlikely that the problem lies there.
The issue likely only affects windows.
Minimum reproduction code
https://github.com/MarkNjunge/nest-swc-paths-issue
Steps to reproduce
No response
Expected behavior
The import paths should be relative
Package version
10.0.0
NestJS version
10.0.0
Node.js version
16.15.1, 18.17.0
In which operating systems have you tested?
Other
No response