Replies: 4 comments 1 reply
|
A concrete case for this from the VS Code repository, and a proposal for the project-side half of it. The caseVS Code has three pnpm install roots whose native modules are built for different runtimes: the root workspace for Electron, The side-effects cache key doesn't see any of that: it is As a workaround I tried giving each root a store of its own target: the ProposalA project-level list of environment variables whose values are part of the key: sideEffectsCache:
env:
- npm_config_runtime
- npm_config_target
- npm_config_arch
- npm_config_disturl
This complements the package-declared field from the original issue rather than replacing it: the project sets these variables, so the project is the one that knows they change the build, whatever the packages declare. A follow-up could make pnpm hash node-gyp's well-known Two questions before I start: is a project-level |
|
The variables that change a build are the project's to name, not pnpm's. The compiler toolchain matters as much as the runtime: A list of variable names isn't enough either. Their values contain absolute paths of the workspace and the sysroot, so the same toolchain hashes differently on two machines. And a new compiler or sysroot at the same path changes the build without changing any variable. Only the project knows what to hash and how to normalize it. Revised proposalOne new field: an opaque string that the project computes and pnpm adds to the side-effects cache key. sideEffectsCache:
key: <string>
With this, a repository like ours can turn the cache on in CI too: every root and every CI target gets its own entries in one store. Would you take a PR for this? |
|
Thanks for the reproduction and for working through the toolchain case. Yes, I'd take a PR for this. I agree the project should compute the value and pnpm should treat it as opaque. I'd like to settle the configuration shape first, because there are two different things a project may need to say: sideEffectsCache:
engine: <string> # replaces <platform>;<arch>;node<major>
key: <string> # appended as ;key=<hash>The key becomes
Both can be returned from Requirements for the implementation:
Per-package values: I'd like both fields to accept either a string or a map of package patterns (the patterns On your other questions:
The PR needs the docs in Written by an agent (Claude Code, claude-fable-5-2). |
|
@zkochan, thanks for getting back to me on this. Do you mind taking a look at this draft PR (#18147) which contains the proposed spec based on your feedback As soon as we have agreement on the spec I can work on the pull request to implement the feature. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
The build scripts of some packages might produce different artifacts for different configuration settings (see #4927 (comment)). Currently pnpm will cache the build results of the dependency and won't build it again. We need to support some
package.jsonfield that will tell pnpm which settings modify the result of the build. This will allow pnpm to store the different modifications of the package under different cache keys.Might be also a good idea to selectively disable side-effects-cache for some packages (maybe the package can declare such field in its package.json).
Also, might be useful to print info messages when packages are read from the side-effects-cache.
Also might be useful to have a CLI option that forces a rebuild of the packages (even if they are present in the side-effects-cache).
All reactions