You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a problem where js files are not properly processed by the register if they are ESM modules. More specifically path aliases are not being replaced. In ts files this seems to be working, however in js files they are not being picked up.
You can find a reproducible example here. I am locking the core version to 1.3.105 in the example because of this issue, however I don't think they are related.
When building through swc into dist and then running the project, everything is working and js files are being picked up and the path aliases are being replaced, but not through node register.
-- works
npx swc -d ./dist -D --delete-dir-on-start --only="**/*.js,**/*.ts,**/*.cjs,**/*.mjs" --ignore ./node_modules,./dist .
node dist/projects/api/main.js
-- doesn't work
SWCRC=true node --import=@swc-node/register/esm-register projects/api/main.ts
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@foo/common' imported from workspaces/libs/math/src/foo.js
The latest version of swc-node seems to be ignoring the paths and baseUrl on purpose here. Previous versions don't seem to pick up js files anyway.
A potential fix is the following load function implementation:
Hi everyone,
I have encountered a problem where
js
files are not properly processed by theregister
if they are ESM modules. More specifically path aliases are not being replaced. Ints
files this seems to be working, however injs
files they are not being picked up.You can find a reproducible example here. I am locking the core version to 1.3.105 in the example because of this issue, however I don't think they are related.
When building through swc into dist and then running the project, everything is working and
js
files are being picked up and the path aliases are being replaced, but not through node register.The latest version of
swc-node
seems to be ignoring thepaths
andbaseUrl
on purpose here. Previous versions don't seem to pick upjs
files anyway.A potential fix is the following load function implementation:
Is this a valid solution and if so, can we get it merged?
The text was updated successfully, but these errors were encountered: