swc-project / swc-node

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

feat: add esm-register for node>20.6 #748

Closed yeliex closed 5 months ago

yeliex commented 5 months ago

According to the node.js release notes for node 20.6 the experimental loaders API was deprecated in favour of the register API. Because of that, we need to use node --import register.js file.ts instead of node --loader @swc-node/register/esm file.ts.

close #743

zckrs commented 5 months ago

Someone can release this fix in new version please ? :pray:

ChALkeR commented 2 days ago
import { register } from 'node:module';
register('@swc-node/register/esm', import.meta.url)

Seems to work better when called from a different cwd (e.g. from cwd of another package)

Assuming you want to resolve to the adjacent esm/esm.js from package exports