lukeed / tsm

TypeScript Module Loader
MIT License
1.18k stars 19 forks source link

[Feature]: support dynamic import by default #27

Closed hardfist closed 1 year ago

hardfist commented 2 years ago

when I use tsm register to transpile module which contains dynamic import, it's broken

It's because esbuild will keep dynamic import for high version of node, even you set format=cjs https://github.com/evanw/esbuild/issues/1636 image

when I set target to node12, it works fine now, because it will transform dynamic import to require

lukeed commented 2 years ago

What versions of Node and esbuild are you using? The support range for import() was fixed here: https://github.com/evanw/esbuild/issues/1772

It's not wise to make node12 the target for all runtimes, because it's untrue for non-12.x runtimes.

hardfist commented 2 years ago

I'm using node@16.8.0