Skip to content

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Nov 8, 2023

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 the loadUserConfig 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 the makeTemporaryEnv subprocesses.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis merged commit f5b7abd into master Nov 13, 2023
@arcanis arcanis deleted the mael/yarnpkg-types-constraints branch November 13, 2023 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: Cannot require @yarnpkg/types to use TS in yarn.config.cjs
1 participant