deps: Experiments with Corepack
Important note: this PR doesn't replace npm by Yarn! It's isn't our intent! We're experimenting with providing both npm and Yarn (and pnpm), so that users can easily contribute to JS projects regardless of the package manager expected.
Context (note that pmm got renamed as Corepack in order to be an available package name on the npm registry):
- https://github.com/nodejs/node/issues/15244
- https://github.com/nodejs/TSC/issues/904
- In short, the intent is to provide standard shims that allow users to run Yarn and pnpm commands without having to explicitly install them first, and without cluttering the Node distribution. Additionally, it will also allow users to pin their package manager version to their projects, thus preventing issues that could arise due to backward incompatible behaviors (be it new bugs, or on the contrary fixed bugs they relied upon).
This PR adds Corepack into the Node distribution pipeline (only for Linux / OSX - I didn't find how the Windows build works). By itself, it only involves very few changes:
- It adds a new folder to the repository,
deps/corepack
(it only takes 300KB) - Similar to
deps/npm
, this folder is mirrored intolib/node_modules/corepack
- Binaries are also symlinked into
bin
(using the same pipeline as npm) - A script (
make corepack-update
) updates thedeps/corepack
content to match the repository main branch
As a result:
- Once this PR is applied, Yarn and pnpm are applied via the Corepack shims (documentation here)
- Users can still opt-out by running
npm install -g yarn
, which will overwrite the Corepack binary starting from 1.22.10
Questions:
- Should I add Windows support?
- Should I transfer the Corepack repository to the Node org? If so, how?
- What testing strategy do you recommend? Corepack itself is tested on its repository: here
Documentation:
I haven't written them yet, but I suspect I'll need to update the following pages:
-
Dependency list to add a reference to Corepack -
API Index to copy/port the Corepack readme
Do you see additional locations I should be mindful of?
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines