visgl / loaders.gl

Loaders for big data visualization. Website:
https://loaders.gl
Other
678 stars 187 forks source link

chore: Implement package.json#packageManager field #3036

Open kouak opened 4 weeks ago

kouak commented 4 weeks ago

Corepack appears to be the emerging tool to pin a specific package manager version.

Corepack is now distributed with node, and uses the package.json#packageManager field : https://nodejs.org/api/packages.html#packagemanager

This PR adds the packageManager field, aligned with volta.yarn.

kouak commented 3 weeks ago

corepack replaces the package manager part of volta

If all team members use volta and are fine with it, then this is redundant. This is beneficial to external contributors who might not have volta installed on their system but are more likely to have corepack enabled on their system IMO (since corepack is distributed alongside node).

When enabling corepack on a system (via corepack enable), corepack will create pnpm and yarn binaries and intercept all calls.

When yarn or pnpm is called in a project, corepack will automatically download and cache the proper package manager version :

image

To update to a specific yarn version, maintainers should run corepack use yarn@4.2.2 in the repo.

To update to the latest yarn version : corepack up.

On corepack enabled systems, corepack will try to set the package.json#packageManager field if its not present.

Corepack works fine without the sha :

{
  "packageManager": "yarn@4.2.2"
}

There's an upcoming vote in Node Technical Steering Committee about whether future node versions should enable corepack by default (and thus, install yarn and pnpm binaries, managed by corepack).

We just migrated our team at work from volta to corepack + fnm and we've found the developer experience to be similar or better. We're building a dockerized app though, and because corepack is bundled with node, corepack is also present in official node docker images. In our case, this ensures that our artefacts also use the same package manager version.

This might not be relevant to the vis.gl repos though, so feel free to close this PR in that case.