Commit 92c3ce3
committed
fix: Add globalPreload to ts-node/esm for node 20
As of node v20, loader hooks are executed in a separate isolated thread
environment. As a result, they are unable to register the
`require.extensions` hooks in a way that would (in other node versions)
make both CJS and ESM work as expected.
By adding a `globalPreload` method, which *does* execute in the main
script environment (but with very limited capabilities), these hooks can
be attached properly, and `--loader=ts-node/esm` will once again make
both cjs and esm typescript programs work properly.1 parent 71dcfd7 commit 92c3ce3
1 file changed
+10
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments