Skip to content

🛠️ Repo: Convert lib/nodejs/ worker pool files to ESM #5969

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions