swc-project / swc-project/swc-node
swc-node/register make follow-on `--import` resolve to wrong path
Open
@Brooooooklyn is already working on this.
Since Sep 4, 2024.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 95
- Avg merge
- 14d 11h
- Merged PRs (30d)
- 1
Description
Assume I have test.js, I can run node --import ./test1.js well.
But node --import @swc-node/register/esm-register --import ./test1.js fail:
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error: All of the aliased extensions are not found for /hax/test1.js: ./test1.js cannot be resolved in file:///hax/x/
at resolve (file:///hax/x/node_modules/@swc-node/register/esm/esm.mjs:157:15)
at async nextResolve (node:internal/modules/esm/hooks:866:22)
at async Hooks.resolve (node:internal/modules/esm/hooks:304:24)
at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18)
Node.js v20.16.0
I notice the dir seems become parent dir, and found that node --import @swc-node/register/esm-register/esm-register --import ./x/test1.js works.
Note, version 1.10.0 is ok (though not support --import ./test.ts). It seems become broken from 1.10.1 .
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.