Open wszydlak opened 10 months ago
I have the same problem with 1.6.7 version.
Me too
I did some debugging and found the new baseUrl
variable that was added in 1.6.7 is to blame. If I comment out that line my project builds as normal; it would be nice if you (@wszydlak , @artamonovtech, @MrRefactoring) could try the same to confirm.
I manually tried everything relative and absolute path I could think of and nothing seemed to work, which leads me to believe this is an issue with this library vs. nx.
@kurt-west not helped for me :(
@MrRefactoring interesting... thanks for giving it a try.
I can confirm that removing line: https://github.com/swc-project/swc-node/blob/master/packages/register/read-default-tsconfig.ts#L123 helps.
Also confirm that changing this line also helps for nx
case:
-baseUrl: resolve(options.baseUrl ?? './'),
+baseUrl: options.baseUrl != null ? resolve(options.baseUrl): undefined,
However i think that baseUrl should not be manipulated on swc side, if user needs to have absolute paths, then probably swc
could give an option to register tsconfig transformer, where the user could modify config.
@kurt-west some status? Maybe some plans to restore previous behavior?
@wszydlak - sorry I'm not a maintainer or contributor to this project and know very little about swc in general. I just ran into the issue at it related to nx and did some investigating. My ping to the group was to confirm everyone was seeing similar behavior in the hopes it would be an easy fix for the swc team.
@Brooooooklyn any chances to get this work?
After upgrade version I found similar an issue too:
import fs from 'fs';
const {access} = fs.promises;
in this case fs has the undefined
value and error TypeError: Cannot read properties of undefined
. In my cases option "esModuleInterop": true
missed after upgrade the version.
According to https://github.com/nrwl/nx/issues/18985#issuecomment-1704448088 - last change in
@swc-node/register
which addedbaseUrl
to tsconfig broke nx generators, eg:This throws an error:
Cannot find module './subdir/index.js'
At least such a change should not be added as a bugfix, cause it broke bacward compatibility.
This worked great in
@swc-node/register@1.6.6
and has been broken in1.6.7