Skip to content

Commit 21fcc79

Browse files
authored
Sets the default compression to 0 (#5526)
**What's the problem this PR addresses?** Cache compression doesn't seem the best option nowadays: - It adds significant time to installs - It adds a non-negligible runtime overhead (partially related, #1817) - It prevents Git from diffing archives when they're modified Its main advantage is for some amazingly large packages, where storing them inside a Git repository would be impossible (GitHub has a 600MB file limit). But since we changed the cache default to `enableGlobalCache: true`, this isn't relevant by default, so the cache compression should be set to zero. One potential issue is how it may give the impression that Yarn became worse for global cache users. We don't believe it's the case (Git can delta uncompressed archives in some measure, making it less expensive to upgrade from one package version to another), but to the average eye it may not look as such. **How did you fix it?** This diff sets the new default compression setting to 0. To avoid breaking projects' (or at least not making the migration more difficult), I added a rule to automatically set `compressionLevel` (and `enableGlobalCache`) to their 3.x default values when running `yarn install` in a 3.x project. When users are ready they can remove these settings and re-run the install. I kept the current compression level on our repository to avoid changing all archives again. I think we'll have to think of purging the repository in some form to migrate it to `compressionLevel: 0`. **Checklist** <!--- Don't worry if you miss something, chores are automatically tested. --> <!--- This checklist exists to help you remember doing the chores when you submit a PR. --> <!--- Put an `x` in all the boxes that apply. --> - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). <!-- See https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released for more details. --> <!-- Check with `yarn version check` and fix with `yarn version check -i` --> - [x] I have set the packages that need to be released for my changes to be effective. <!-- The "Testing chores" workflow validates that your PR follows our guidelines. --> <!-- If it doesn't pass, click on it to see details as to what your PR might be missing. --> - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent 4e6f983 commit 21fcc79

File tree

20 files changed

+457
-585
lines changed

20 files changed

+457
-585
lines changed

.yarn/versions/6c7747db.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
releases:
2+
"@yarnpkg/cli": major
3+
"@yarnpkg/core": major
4+
"@yarnpkg/plugin-essentials": major
5+
6+
declined:
7+
- "@yarnpkg/plugin-compat"
8+
- "@yarnpkg/plugin-constraints"
9+
- "@yarnpkg/plugin-dlx"
10+
- "@yarnpkg/plugin-exec"
11+
- "@yarnpkg/plugin-file"
12+
- "@yarnpkg/plugin-git"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-nm"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-pnpm"
25+
- "@yarnpkg/plugin-stage"
26+
- "@yarnpkg/plugin-typescript"
27+
- "@yarnpkg/plugin-version"
28+
- "@yarnpkg/plugin-workspace-tools"
29+
- "@yarnpkg/builder"
30+
- "@yarnpkg/doctor"
31+
- "@yarnpkg/extensions"
32+
- "@yarnpkg/nm"
33+
- "@yarnpkg/pnpify"
34+
- "@yarnpkg/sdks"

.yarnrc.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
changesetIgnorePatterns:
2-
- ".github/**"
3-
- ".yarn/cache/**"
2+
- .github/**
3+
- .yarn/cache/**
44
- "**/*.test.{js,ts}"
5-
- "packages/*/tests/**"
6-
- "packages/plugin-compat/extra/**"
7-
- "packages/gatsby/**"
5+
- packages/*/tests/**
6+
- packages/plugin-compat/extra/**
7+
- packages/gatsby/**
88

9-
enableGlobalCache: false
9+
compressionLevel: mixed
1010

11-
pnpEnableEsmLoader: true
11+
enableGlobalCache: false
1212

1313
immutablePatterns:
1414
- .pnp.*
1515

16-
supportedArchitectures:
17-
os: [darwin, linux, win32]
18-
cpu: [x64, arm64]
19-
2016
initScope: yarnpkg
2117

2218
npmPublishAccess: public
@@ -73,8 +69,19 @@ packageExtensions:
7369
typedoc-plugin-yarn:
7470
optional: true
7571

72+
pnpEnableEsmLoader: true
73+
7674
preferInteractive: true
7775

76+
supportedArchitectures:
77+
cpu:
78+
- x64
79+
- arm64
80+
os:
81+
- darwin
82+
- linux
83+
- win32
84+
7885
telemetryUserId: yarnpkg/berry
7986

8087
yarnPath: scripts/run-yarn.js

packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/add.test.ts.snap

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/acceptance-tests/pkg-tests-specs/sources/commands/__snapshots__/install.test.js.snap

Lines changed: 0 additions & 112 deletions
This file was deleted.

packages/acceptance-tests/pkg-tests-specs/sources/commands/add.test.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import {Filename, PortablePath, ppath, xfs} from '@yarnpkg/fslib';
2-
3-
const {
4-
tests: {getPackageDirectoryPath},
5-
} = require(`pkg-tests-core`);
6-
const {parseSyml} = require(`@yarnpkg/parsers`);
2+
import {parseSyml} from '@yarnpkg/parsers';
3+
import {tests} from 'pkg-tests-core';
74

85
describe(`Commands`, () => {
96
describe(`add`, () => {
@@ -104,7 +101,7 @@ describe(`Commands`, () => {
104101
test(
105102
`it should add a new regular dependency to the current project (unnamed path)`,
106103
makeTemporaryEnv({}, async ({path, run, source}) => {
107-
const packagePath = await getPackageDirectoryPath(`no-deps`, `1.0.0`);
104+
const packagePath = await tests.getPackageDirectoryPath(`no-deps`, `1.0.0`);
108105

109106
await run(`add`, packagePath);
110107

@@ -570,9 +567,7 @@ describe(`Commands`, () => {
570567

571568
expect(preUpgradeCache.find(entry => entry.includes(`no-deps-npm-1.0.0`))).toBeDefined();
572569

573-
const {code, stdout, stderr} = await run(`add`, `[email protected]`);
574-
575-
await expect({code, stdout, stderr}).toMatchSnapshot();
570+
await run(`add`, `[email protected]`);
576571

577572
const postUpgradeCache = await xfs.readdirPromise(`${path}/.yarn/cache` as PortablePath);
578573

@@ -589,15 +584,14 @@ describe(`Commands`, () => {
589584
YARN_ENABLE_GLOBAL_CACHE: `true`,
590585
YARN_GLOBAL_FOLDER: `${path}/global`,
591586
};
587+
592588
await run(`install`, {env});
593589

594590
const preUpgradeCache = await xfs.readdirPromise(`${path}/global/cache` as PortablePath);
595591

596592
expect(preUpgradeCache.find(entry => entry.includes(`no-deps-npm-1.0.0`))).toBeDefined();
597593

598-
const {code, stdout, stderr} = await run(`add`, `[email protected]`, {env});
599-
600-
await expect({code, stdout, stderr}).toMatchSnapshot();
594+
await run(`add`, `[email protected]`, {env});
601595

602596
const postUpgradeCache = await xfs.readdirPromise(`${path}/global/cache` as PortablePath);
603597

0 commit comments

Comments
 (0)