- Version: 12.3.1
- Platform: all
- Subsystem: workers
- Tl;dr:
process._preload_modules should be forwarded to the workers
This one is a bit convoluted ... first some context:
- Yarn 2 keeps the vendors within zip archives instead of unpacking them
- To make it work, NODE_OPTIONS contains
--require /path/to/.pnp.js
- This
.pnp.js extends the fs module to add support for in-zip reading
- Parcel 2, a vendor (and thus stored within a zip), uses
worker_threads if possible
It works fine with child_process.fork, because under the regular CLI the --require scripts are executed before the entry point is resolved (except when using --inspect if I remember correctly), so by the time runMain is called the zip archives can be accessed.
However, with worker_threads it seems that the NODE_OPTIONS --require entries are completely ignored and runMain is called directly, causing the script to be executed outside of the PnP context and thus not being able to access its dependencies or even spawn if stored within a zip archive (which is the case by default, although it can be disabled).
process._preload_modulesshould be forwarded to the workersThis one is a bit convoluted ... first some context:
--require /path/to/.pnp.js.pnp.jsextends thefsmodule to add support for in-zip readingworker_threadsif possibleIt works fine with
child_process.fork, because under the regular CLI the--requirescripts are executed before the entry point is resolved (except when using--inspectif I remember correctly), so by the timerunMainis called the zip archives can be accessed.However, with
worker_threadsit seems that the NODE_OPTIONS--requireentries are completely ignored andrunMainis called directly, causing the script to be executed outside of the PnP context and thus not being able to access its dependencies or even spawn if stored within a zip archive (which is the case by default, although it can be disabled).