Injects the PnP runtime in the process before requiring the user config #5954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the problem this PR addresses?
We added support for JS constraints thanks to the
yarn.config.cjs
file. However this file is currently executed from within the Yarn process, so it doesn't have access to the dependencies when operating under the PnP installation mode.Fixes #5878
How did you fix it?
I'm still on the fence on the right solution. This PR automatically loads the
.pnp.cjs
file when theloadUserConfig
file is called. An alternative would be a post-install hook to allow each linker to inject their runtime inside the process post-install, but that was more involved and I figured it's worth more consideration.Another alternative was to not do anything and expect users to setup the PnP runtime themselves, but it feels something that Yarn should be able to handle.
A third alternative would be to evaluate this file within a worker thread, which would be started with the proper
execArgv
flags. It's less intrusive than the post-install hook so I kinda like this idea, but again - worth more consideration.I'm working on enabling tests, and to this effect I'm checking whether we can remove the
NODE_OPTIONS
values from themakeTemporaryEnv
subprocesses.Checklist