egoist / esbuild-register

Transpile JSX, TypeScript and esnext features on the fly with esbuild
MIT License
990 stars 52 forks source link

es module: Dynamic require of "esbuild-register/dist/node" is not supported #86

Open wighawag opened 1 year ago

wighawag commented 1 year ago

I am building a command line tool that load ts files and I make use of esbuild-register to make it work

It work fine when the tool is compiled to a cjs file but if I generate a es module instead, I get the following error when executing it :

Error: Dynamic require of "esbuild-register/dist/node" is not supported

Using tsup to build the cli and I use require to load the ts files

I tried to use import( instead of require but got the error):

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for ...

any idea ?