swc-project / swc-node

Faster ts-node without typecheck
MIT License
1.69k stars 69 forks source link

fix(register): Fix to resolve adjacent file path #711

Closed chloe463 closed 1 year ago

chloe463 commented 1 year ago

The current register/esm does not resolve relative file path correctly. For example, the following code and command doesn't run properly.

code

// index.mts
import './foo.mjs'

foo()

command node --loader @swc-node/register/esm index.mts

and the error

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/foo.mjs' imported from /path/to/index.mts.mjs

This PR fixes the problem.

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.