synckit
synckit copied to clipboard
fix: fix PnP ESM loader integration
When running in PnP context, setupTsRunner detects whether the runtime support module.register, and uses module.register in the worker thread to load the PnP loader in the worker thread during runAsWoker. If it is not supported, --loader </path/to/.pnp.loader.mjs> is added to the worker's execArgv.
This is problematic for two reasons:
- The worker path is resolved without the PnP loader. So the worker will fail if the worker path is only resolvable under PnP.
- The worker thread always fails because there is a chicken-and-egg problem -- the worker thread can't resolve
synckitwithout the PnP loader, but the PnP loader is only loaded inrunAsWorkerwhich needssynckitto be resolvable.
This PR makes it so that the execArgv --loader method is always used
Fixes #254
Summary by CodeRabbit
- Bug Fixes
- Fixed PnP ESM support handling in synckit