Use pnpm instead of npm for package management#1107
Open
RagingCactus wants to merge 3 commits intographefruit:developfrom
Open
Use pnpm instead of npm for package management#1107RagingCactus wants to merge 3 commits intographefruit:developfrom
RagingCactus wants to merge 3 commits intographefruit:developfrom
Conversation
pnpm is strict about us having to declare all dependencies we use directly, even if they are brought in transitively through other dependencies. All of these dependencies were already in the project, but were erroneously not being declared as being direct dependencies. This is required to make the application build correctly when using pnpm.
npm development is behind most of the JS package manager ecosystem. npm only very recently started introducing a setting to ignore package versions younger than a specified time frame to help defend against supply chain attacks. Furthermore, npm still runs postInstall scripts by default on any package, increasing the risk further. On top of that, we recently had a bunch of problems with npm generating bad lock files, see npm/cli#8669. And last but not least, npm is rather slow and likes to waste disk space on every opportunity. Its lock files are also terrible to diff. pnpm should be an improvement on all of these fronts. It does NOT execute build scripts by default, it has a very easy way to specify a minimum age for new package versions, and its lock files look much better to a human in a diff. This commit removes the old npm package-lock.json, adds the pnpm lock file instead and also adds pnpm settings. It also updates all documentation, comments, and CI scripts to use pnpm.
This prevents confusion when trying to use old versions of node or pnpm. This configuration will also cause accidental invocations of npm to error, which is great to ease the transition to pnpm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale
npmdevelopment is behind most of the JS package manager ecosystem.npmonly very recently started introducing a setting to ignore packageversions younger than a specified time frame to help defend againstsupply chain attacks. Furthermore, npm still runspostInstallscripts by default on any package, increasing the risk further.On top of that, we recently had a bunch of problems with npm generating bad lock files, see npm/cli#8669.
And last but not least,
npmis rather slow and likes to waste disk space on every opportunity. Its lock files are also terrible to diff.pnpmshould be an improvement on all of these fronts. It does NOT execute build scripts by default, it has a very easy way to specify a minimum age for new package versions, and its lock files look much better to a human in a diff.Security
With this PR, the following configuration is being set in
pnpm-workspace.yaml:This means that
pnpmwill only consider versions for dependency resolution that are at least 7 days old. This should improve our resilience against supply chain attacks like the recent attack on axios (see https://www.stepsecurity.io/blog/axios-compromised-on-npm-malicious-versions-drop-remote-access-trojan and axios/axios#10604) because hopefully someone discovers the malicious version in these 7 days.Furthermore,
pnpmby default disallows build scripts in dependencies. Packages that require build scripts must be explicitly whitelisted inpnpm-workspace.yamlas shown here:Notice to developers
Warning: When testing this or after this is merged, developers will need to
rm -r node_modulesonce!After that, just
pnpm installand everything should work. Just remember to always usepnpminstead ofnpmandpnpxinstead ofnpxin Beanconqueror.Testing
This needs a quick test to see if the ios build still works. Android works fine, I tested that.
Discussion
Feel free to discuss this, this is just a proposal. It just stems from the fact that personally I've had it with
npmnow. The weird lock file issues in CI and with PRs, the default of just running anypostInstallscript by default, and now the bad configurability regarding supply chain hardening. I'm not apnpmfanboy or anything, it just looked like a well-known, widely used, and more sane alternative.