swc-project / swc-node

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

fix: fix import absolute path support #720

Closed yeliex closed 10 months ago

yeliex commented 11 months ago

currently when import with absolute path, error shows:

node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at new URL (node:internal/url:611:13)
    at fileURLToPath (node:internal/url:1399:12)
    at resolve (file:///xxx/node_modules/@swc-node/register/esm/esm.mjs:66:35)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:524:22)
    at importModuleDynamically (node:internal/modules/esm/translators:110:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14) {
  input: '/Volumes/test/10_client.ts',
  code: 'ERR_INVALID_URL'
}
CLAassistant commented 11 months ago

CLA assistant check
All committers have signed the CLA.

yeliex commented 11 months ago

@Brooooooklyn please review again, type bug fixed

yeliex commented 10 months ago

@Brooooooklyn any feedback please it is two weeks since pr create

if anything need improvement, leave your feedback