Sub-issue of #5400 (Switch from CJS to ESM internally).
These lib/nodejs/ files are the hardest remaining CJS-to-ESM migration targets. They are intentionally left as CJS for now because of a test-isolation blocker described in this comment on #5400.
Files to convert
lib/nodejs/buffered-worker-pool.js
lib/nodejs/parallel-buffered-runner.js
lib/nodejs/reporters/parallel-buffered.js
Blocker: rewiremock / Module._load test isolation
The unit tests for these files use rewiremock.proxy() to replace workerpool with a fake implementation. This works in CJS because rewiremock hooks into Module._load. Once the files become .mjs, ESM imports bypass Module._load and the mock stops applying — causing tests to spawn real worker processes during unit tests.
Options to resolve:
- Replace
rewiremock with esmock for ESM-compatible mocking
- Introduce a workerpool abstraction/factory that can be injected in tests
- Other dependency injection approaches
The simpler lib/nodejs/ files (file-unloader.js, serializer.js, worker.js) do not have this blocker and are tracked in #5968.
Sub-issue of #5400 (Switch from CJS to ESM internally).
These
lib/nodejs/files are the hardest remaining CJS-to-ESM migration targets. They are intentionally left as CJS for now because of a test-isolation blocker described in this comment on #5400.Files to convert
lib/nodejs/buffered-worker-pool.jslib/nodejs/parallel-buffered-runner.jslib/nodejs/reporters/parallel-buffered.jsBlocker:
rewiremock/Module._loadtest isolationThe unit tests for these files use
rewiremock.proxy()to replaceworkerpoolwith a fake implementation. This works in CJS becauserewiremockhooks intoModule._load. Once the files become.mjs, ESM imports bypassModule._loadand the mock stops applying — causing tests to spawn real worker processes during unit tests.Options to resolve:
rewiremockwithesmockfor ESM-compatible mockingThe simpler
lib/nodejs/files (file-unloader.js,serializer.js,worker.js) do not have this blocker and are tracked in #5968.