synckit icon indicating copy to clipboard operation
synckit copied to clipboard

fix: fix PnP ESM loader integration

Open clemyan opened this issue 2 months ago • 4 comments

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:

  1. The worker path is resolved without the PnP loader. So the worker will fail if the worker path is only resolvable under PnP.
  2. The worker thread always fails because there is a chicken-and-egg problem -- the worker thread can't resolve synckit without the PnP loader, but the PnP loader is only loaded in runAsWorker which needs synckit to 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

clemyan avatar Oct 28 '25 14:10 clemyan