fix(metro-config): Pass absolute default worker path to metro
Summary
If we pass an unresolved path to metro, metro's worker pool, jest-worker, will need to resolve the worker path itself. This relies on jest-worker being able to resolve metro, even though it doesn't explicitly depend on metro (doing so would result in a nice cyclic dependency).
In package managers that eliminate phantom dependencies, like Yarn PnP or pnpm, this resolution just fails.
To avoid relying on a phantom dependency, we need to resolve the absolute path of the worker before handing it off to jest-worker. Since we depend on metro, this is fine, and jest-worker can consume the absolute path.
Test plan
This is based on the assumption that jest-worker's BaseWorkerPool accepts a resolved worker path: https://github.com/facebook/jest/blob/e0b33b74b5afd738edc183858b5c34053cfc26dd/packages/jest-worker/src/base/BaseWorkerPool.ts#L35.
Hi @asmundg!
Thank you for your pull request and welcome to our community.
Action Required
In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.
Process
In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.
Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.
If you have received this in error or have any questions, please contact us at [email protected]. Thanks!
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!
@motiz88, Done!
@motiz88 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This was implemented (a little differently, but fixing the same issue) in https://github.com/facebook/metro/commit/6d46078e74ae9a43aa90bed46dbd6610e2696cd0