Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn Plug'n'Play: Implementation #6382

Merged
merged 206 commits into from
Sep 24, 2018
Merged

Yarn Plug'n'Play: Implementation #6382

merged 206 commits into from
Sep 24, 2018

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Sep 13, 2018

Note: This PR's discussions should be focused on the implementation details. A separate PR has been opened on the RFC repository to gather feedback for the high-level design itself.

Hi folks,

This PR implements the Plug'n'Play feature for Yarn (check the link to go to the formal RFC that details the motivations behind this project, and rational behind the design choices). It's a large PR so please bear with me! I preserved the individual commits intact in case you want to see the history of the project.

Without further ado, this PR:

  • Add support for Plug'n'Play, which when enabled will:
    • cause a file named .pnp.js to be generated in place of the node_modules
    • cause a directory named .pnp to be created - the content of this directory is opaque (cf RFC)
  • Add support for {"installConfig": {"pnp": true}}
  • Add support for yarn --pnp and yarn --disable-pnp , which toggle Plug'n'Play permanently for a project
  • Add support for YARN_PLUGNPLAY_OVERRIDE which can override the Plug'n'Play settings without persisting it
  • Add a new command named yarn unplug which copies a specific package from the cache to a temporary folder for debugging purposes - note that this command isn't meant to be used a part of regular installation workflows.
  • Make scripts ran through yarn run to always use the exact same version of both Yarn and Node than the ones Yarn is using itself at the moment (fixes Node executable path always prepended to PATH when running a package.json script #5935 permanently).

Since I can guess you're interested into trying it out now, you can find a build attached to this PR. You also can try out this playground for an easy way to test the feature with all sort of tools (note that we'll gladly accept contributions there to add new ones!).

cc @yarnpkg/maintainers

Maël Nison and others added 30 commits March 1, 2018 16:27
Branch: lifecycle-wrappers-remove-option
…ight binaries

Branch: lifecycle-wrappers-tests
Branch: lifecycle-wrappers-flowlint
… been installed

Branch: lifecycle-wrappers-improve-pnp-error
Branch: lifecycle-wrappers-main
Remove the scriptsPrependNodePath option
Adds .pnp.js files to the gitignore
Fallbacks to the toplevel dependencies when a transitive dependency is missing
Branch: pkg-tests-helper-definition
…nd peer dependencies

Branch: dev-peer-fixtures
…ental`)

Branch: option-plugnplay-experimental
Branch: pnp-peer-dependencies-failing
Fixes an issue inside the pkg-tests helper
Prettifies the generated pnp files
@arcanis
Copy link
Member Author

arcanis commented Sep 24, 2018

So is this a breaking change for yarn? Will we be releasing it as 2.0?

Not yet, I want to release it as 1.11 first (meaning that I won't merge the PR that adds support for PnP to Yarn itself right now). But yeah, it will make the 2.0 release more pressing. I'd have preferred if we could have had more work done on the breaking changes we listed in the 2.0 thread, but we can postpone it to the next major bump.

@@ -219,7 +219,7 @@ describe('with focus', () => {
true,
);
expect(await linkAt(config, 'node_modules', '.bin', 'example-yarn-workspace-2')).toEqual(
'../example-yarn-workspace-2/index.js',
'../../../example-yarn-workspace-2/index.js',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting .. I've simply updated this test, since the new value seems more correct to me. The extra ../.. is required to jump out of node_modules/.bin (the linkAt function just reads the symlink as it is, it doesn't make it relative to anything special).

@arcanis
Copy link
Member Author

arcanis commented Sep 24, 2018

I now remember why the focus tests were skipped - #5967 is blocking them 😞

@pustovalov
Copy link

@arcanis can I use Yarn Plug'n'Play in yarn 1.10.1?

@DanielRuf
Copy link
Contributor

@pustovalov just in nightly afaik

@arcanis
Copy link
Member Author

arcanis commented Sep 28, 2018

The 1.11 branch (currently prerelease) also has PnP enabled! Master (ie nightlies) is slightly more up-to-date though, and contains a few bugfixes for some edge cases.

@DanielRuf
Copy link
Contributor

DanielRuf commented Sep 28, 2018

The 1.11 branch (currently prerelease) also has PnP enabled! Master (ie nightlies) is slightly more up-to-date though, and contains a few bugfixes for some edge cases.

Right, 1.11-nightly already had it. Missed that it is already in the prerelease.

@pustovalov
Copy link

Thx

jasongrout added a commit to jasongrout/yarn that referenced this pull request Feb 22, 2019
jasongrout added a commit to jasongrout/yarn that referenced this pull request Feb 22, 2019
arcanis pushed a commit that referenced this pull request Mar 8, 2019
* Delete unused scriptsPrependNodePath config option.

#6382 (e905f74) made this option obsolete.

* Do not prepend the node exec path.

#6382 (e905f74) made this unnecessary.

* Update CHANGELOG.md

* Clarify in changelog the --scripts-prepend-node-path is removed because it is obsolete

The current behavior after this PR is not to make `--scripts-prepend-node-path` always on, but to have a better default behavior than the option provided.
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.

Node executable path always prepended to PATH when running a package.json script
8 participants