-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
- I’d be willing to implement this feature (contributing guide)
- This feature is important to have in this repository; a contrib plugin wouldn’t do
Describe the user story
I’m using the checkoutable cache feature to make business-critical projects independent from the npm infrastructure.
To make my project work on all platforms I need to support:
- macOS, arm64
- Windows, arm64
- Linux, x64 / arm64
I configure this via:
supportedArchitectures:
cpu:
- arm64
- x64
os:
- darwin
- linux
- win32
libc:
- glibc
This currently results in all possible combinations being fetched, which is excessive (already tracked in #4604).
The bigger issue is that both the cache and the actual node_modules get populated with all these combinations. This becomes especially painful as more native dependencies appear in my node_modules.
Example:
• biomejs: 29.3 MB when installed via npm
• biomejs: 199.7 MB when installed via Yarn with the above configuration
Describe the solution you’d like
Add a setting that changes the behavior of supportedArchitectures
so that .yarn/cache
conforms to the full list, but yarn install
only installs packages for the current architecture.
Example:
supportedArchitecturesBehavior: 'all' # default
supportedArchitecturesBehavior: 'cache-only' # new
This would still allow reproducible, cross-platform offline installs, but without bloating node_modules for the active environment.
Describe the drawbacks of your solution
- Slightly more complexity in install logic
- Unclear how this would behave for other node linkers than node-modules and pnpm; needs to be documented. But is it really a problem in PnP, that modules working on other archs will be available?
Describe alternatives you’ve considered
- Manually pruning node_modules post-install (fragile and error-prone)