TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.86k stars 536 forks source link

Export `ts-node/esm-register` to use with `--import` #2072

Open jlenon7 opened 1 year ago

jlenon7 commented 1 year ago

Desired Behavior

Register the ts-node/esm loader using the register function. Example of use:

node --import=ts-node/esm-register

The content of the file would be something like this:

import { register } from 'node:module'
import { pathToFileURL } from 'node:url'

register('ts-node/esm', pathToFileURL('./'))

Is this request related to a problem?

No.

Alternatives you've considered

.

Additional context

.

AaronNGray commented 8 months ago

For further context and alternative example see :- https://github.com/TypeStrong/ts-node/issues/2100