Skip to content

Commit

Permalink
Improves boot time (#4261)
Browse files Browse the repository at this point in the history
* Implements code splitting

* Trims some fat

* Reverts the parser changes

* Reverts logs

* Removes webpack from the dependencies

* Libzip sync/async

* Versions

* Reverts --split

* Reverts libzip changes

* Reverts clipanion compat changes

* Reverts unneeded changes

* chore: versions

* chore: lint

* chore: remove `yup` dependency

Co-authored-by: merceyz <[email protected]>
  • Loading branch information
arcanis and merceyz authored Mar 26, 2022
1 parent fde9dfa commit b730176
Show file tree
Hide file tree
Showing 20 changed files with 88 additions and 246 deletions.
148 changes: 17 additions & 131 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37 changes: 37 additions & 0 deletions .yarn/versions/78804c3b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
releases:
"@yarnpkg/cli": major
"@yarnpkg/core": major
"@yarnpkg/libzip": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- vscode-zipfs
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/fslib"
- "@yarnpkg/nm"
- "@yarnpkg/pnp"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ describe(`Commands`, () => {
const content = await xfs.readFilePromise(`${path}/yarn.lock` as PortablePath, `utf8`);
const lock = parseSyml(content);

await expect(lock).toMatchObject({
expect(lock).toMatchObject({
[`inject-node-gyp@npm:^1.0.0`]: {
dependencies: {
[`node-gyp`]: `latest`,
Expand Down
4 changes: 1 addition & 3 deletions packages/yarnpkg-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
"clipanion": "^3.2.0-rc.4",
"semver": "^7.1.2",
"tslib": "^1.13.0",
"typanion": "^3.3.0",
"yup": "^0.32.9"
"typanion": "^3.3.0"
},
"devDependencies": {
"@types/semver": "^7.1.0",
"@types/yup": "^0",
"@yarnpkg/builder": "workspace:^",
"@yarnpkg/monorepo": "workspace:^",
"@yarnpkg/pnpify": "workspace:^",
Expand Down
3 changes: 0 additions & 3 deletions packages/yarnpkg-cli/sources/tools/getDynamicLibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as shell from '@yarnpkg/shell';
import * as clipanion from 'clipanion';
import * as semver from 'semver';
import * as typanion from 'typanion';
import * as yup from 'yup';

export const getDynamicLibs = () => new Map<string, any>([
[`@yarnpkg/cli`, cli],
Expand All @@ -21,6 +20,4 @@ export const getDynamicLibs = () => new Map<string, any>([
[`clipanion`, clipanion],
[`semver`, semver],
[`typanion`, typanion],
// TODO: remove in next major
[`yup`, yup],
]);
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"semver": "^7.1.2",
"strip-ansi": "^6.0.0",
"tar": "^6.0.5",
"tinylogic": "^1.0.3",
"tinylogic": "^2.0.0",
"treeify": "^1.1.0",
"tslib": "^1.13.0",
"tunnel": "^0.0.6"
Expand Down
36 changes: 18 additions & 18 deletions packages/yarnpkg-core/sources/httpUtils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {PortablePath, xfs} from '@yarnpkg/fslib';
import {ExtendOptions, RequestError, Response, TimeoutError} from 'got';
import {Agent as HttpsAgent} from 'https';
import {Agent as HttpAgent} from 'http';
import micromatch from 'micromatch';
import tunnel, {ProxyOptions} from 'tunnel';
import {URL} from 'url';

import {ConfigurationValueMap, Configuration} from './Configuration';
import {MessageName} from './MessageName';
import {ReportError} from './Report';
import * as formatUtils from './formatUtils';
import {MapValue, MapValueToObjectValue} from './miscUtils';
import * as miscUtils from './miscUtils';

export {RequestError} from 'got';
import {PortablePath, xfs} from '@yarnpkg/fslib';
import type {ExtendOptions, RequestError, Response} from 'got';
import {Agent as HttpsAgent} from 'https';
import {Agent as HttpAgent} from 'http';
import micromatch from 'micromatch';
import tunnel, {ProxyOptions} from 'tunnel';
import {URL} from 'url';

import {ConfigurationValueMap, Configuration} from './Configuration';
import {MessageName} from './MessageName';
import {ReportError} from './Report';
import * as formatUtils from './formatUtils';
import {MapValue, MapValueToObjectValue} from './miscUtils';
import * as miscUtils from './miscUtils';

export type {RequestError} from 'got';

const cache = new Map<string, Promise<Buffer> | Buffer>();
const fileCache = new Map<PortablePath, Promise<Buffer> | Buffer>();
Expand Down Expand Up @@ -64,8 +64,8 @@ async function prettyNetworkError(response: Promise<Response<any>>, {configurati
}
}

if (err instanceof TimeoutError && err.event === `socket`)
message += ` (can be increased via ${formatUtils.pretty(configuration, `httpTimeout`, formatUtils.Type.SETTING)})`;
if (err.code === `ETIMEDOUT` && err.event === `socket`)
message += `(can be increased via ${formatUtils.pretty(configuration, `httpTimeout`, formatUtils.Type.SETTING)})`;

const networkError = new ReportError(MessageName.NETWORK_ERROR, message, report => {
if (err.response) {
Expand Down
9 changes: 6 additions & 3 deletions packages/yarnpkg-libzip/sources/async.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import createModule from './libzipAsync';
import {Libzip, makeInterface} from './makeInterface';

let promise: Promise<Libzip> | null = null;
Expand All @@ -8,8 +7,12 @@ export function getLibzipSync() {
}

export async function getLibzipPromise() {
if (promise === null)
promise = createModule().then(libzip => makeInterface(libzip));
if (promise === null) {
promise = import(`./libzipAsync`).then(async ({default: createModule}) => {
const libzip = await createModule();
return makeInterface(libzip);
});
}

return promise;
}
Expand Down
93 changes: 7 additions & 86 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.0, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.10.5, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.0, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.3.4, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.7, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7":
"@babel/runtime@npm:^7.0.0, @babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.0, @babel/runtime@npm:^7.10.2, @babel/runtime@npm:^7.11.2, @babel/runtime@npm:^7.13.10, @babel/runtime@npm:^7.14.0, @babel/runtime@npm:^7.15.4, @babel/runtime@npm:^7.3.4, @babel/runtime@npm:^7.4.4, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.7.2, @babel/runtime@npm:^7.7.7, @babel/runtime@npm:^7.8.4, @babel/runtime@npm:^7.8.7":
version: 7.15.4
resolution: "@babel/runtime@npm:7.15.4"
dependencies:
Expand Down Expand Up @@ -1777,20 +1777,6 @@ __metadata:
languageName: node
linkType: hard

"@chevrotain/types@npm:^9.1.0":
version: 9.1.0
resolution: "@chevrotain/types@npm:9.1.0"
checksum: 95621f85dde7afbc3298440407814a04857f45fa0deefed0006441d1bdd1e09ae2243e141753ca2d1b08845f3c391dd03532f219e12be8c5e1d12b0b12ad342a
languageName: node
linkType: hard

"@chevrotain/utils@npm:^9.1.0":
version: 9.1.0
resolution: "@chevrotain/utils@npm:9.1.0"
checksum: 3bf20cd22e2f5d64f9cfd968c6355e440abb833b8283a37ff67d1ba56a219f2c9f93a194f2c51befb9932475c6d1fa98376f2ace248c2e391639931e0305a783
languageName: node
linkType: hard

"@cnakazawa/watch@npm:^1.0.3":
version: 1.0.3
resolution: "@cnakazawa/watch@npm:1.0.3"
Expand Down Expand Up @@ -4351,7 +4337,7 @@ __metadata:
languageName: node
linkType: hard

"@types/lodash@npm:*, @types/lodash@npm:^4.14.136, @types/lodash@npm:^4.14.165, @types/lodash@npm:^4.14.92":
"@types/lodash@npm:*, @types/lodash@npm:^4.14.136, @types/lodash@npm:^4.14.92":
version: 4.14.172
resolution: "@types/lodash@npm:4.14.172"
checksum: e93b14543aa7c9f14bd8f1fdd5e309927d00e13ad3a91f16be167ea0f36ad412901d648dd16dd6df68973c02b899c354a28c3b5f76ec881d6bc2e8a8ef1e3a41
Expand Down Expand Up @@ -4822,13 +4808,6 @@ __metadata:
languageName: node
linkType: hard

"@types/yup@npm:^0":
version: 0.29.11
resolution: "@types/yup@npm:0.29.11"
checksum: d33af937ef241499ee22e7a819c8fe8b07403c6aaaa750567a8daf79982df58a599f5c16fe405eb139fed49553731586620e04d4d0a21b7010597d8d643946b5
languageName: node
linkType: hard

"@typescript-eslint/eslint-plugin@npm:^4.29.3":
version: 4.31.2
resolution: "@typescript-eslint/eslint-plugin@npm:4.31.2"
Expand Down Expand Up @@ -5407,7 +5386,6 @@ __metadata:
resolution: "@yarnpkg/cli@workspace:packages/yarnpkg-cli"
dependencies:
"@types/semver": ^7.1.0
"@types/yup": ^0
"@yarnpkg/builder": "workspace:^"
"@yarnpkg/core": "workspace:^"
"@yarnpkg/fslib": "workspace:^"
Expand Down Expand Up @@ -5438,7 +5416,6 @@ __metadata:
semver: ^7.1.2
tslib: ^1.13.0
typanion: ^3.3.0
yup: ^0.32.9
peerDependencies:
"@yarnpkg/core": "workspace:^"
languageName: unknown
Expand Down Expand Up @@ -5486,7 +5463,7 @@ __metadata:
semver: ^7.1.2
strip-ansi: ^6.0.0
tar: ^6.0.5
tinylogic: ^1.0.3
tinylogic: ^2.0.0
treeify: ^1.1.0
tslib: ^1.13.0
tunnel: ^0.0.6
Expand Down Expand Up @@ -8373,17 +8350,6 @@ __metadata:
languageName: node
linkType: hard

"chevrotain@npm:^9.1.0":
version: 9.1.0
resolution: "chevrotain@npm:9.1.0"
dependencies:
"@chevrotain/types": ^9.1.0
"@chevrotain/utils": ^9.1.0
regexp-to-ast: 0.5.0
checksum: d8e5cd89c0baa0b227ed39eb425cc8a1ffe533fe9993850f130bd7771963f30bb6095624e58c2acd0dc933b622834f17df0e5100f63d1008d64967a135f6e229
languageName: node
linkType: hard

"chokidar@npm:^2.1.8":
version: 2.1.8
resolution: "chokidar@npm:2.1.8"
Expand Down Expand Up @@ -17102,13 +17068,6 @@ __metadata:
languageName: node
linkType: hard

"lodash-es@npm:^4.17.15":
version: 4.17.21
resolution: "lodash-es@npm:4.17.21"
checksum: d1c3ee94118daeeee47c630ab5f91e94cc4e41ebe2452d837edbe599e853eb2d4be7edf82b4fe62f9fc74f27a8ed7f82fdbd9d301d0acef88f00941db64c4843
languageName: node
linkType: hard

"lodash._reinterpolate@npm:~3.0.0":
version: 3.0.0
resolution: "lodash._reinterpolate@npm:3.0.0"
Expand Down Expand Up @@ -18695,13 +18654,6 @@ __metadata:
languageName: node
linkType: hard

"nanoclone@npm:^0.2.1":
version: 0.2.1
resolution: "nanoclone@npm:0.2.1"
checksum: 24a9268a93d4e40f5bda016777ebbc4bdf878ec92c062070fee95d0d77ae22869da6589eb1037116c9d59ded61fd30f8c4418bff24bec9d49f4c65ea7f0c4746
languageName: node
linkType: hard

"nanocolors@npm:^0.1.5":
version: 0.1.6
resolution: "nanocolors@npm:0.1.6"
Expand Down Expand Up @@ -21077,13 +21029,6 @@ __metadata:
languageName: node
linkType: hard

"property-expr@npm:^2.0.4":
version: 2.0.4
resolution: "property-expr@npm:2.0.4"
checksum: 5c68f0d092c0962469749a7913d11e43d43ae970cdd2dce80b653bdf53170625d41142d7f787d45d2d36633c82c2fee4221176aa3b87d3cdda438defb7206afa
languageName: node
linkType: hard

"property-information@npm:^5.0.0, property-information@npm:^5.3.0":
version: 5.6.0
resolution: "property-information@npm:5.6.0"
Expand Down Expand Up @@ -22084,13 +22029,6 @@ __metadata:
languageName: node
linkType: hard

"regexp-to-ast@npm:0.5.0":
version: 0.5.0
resolution: "regexp-to-ast@npm:0.5.0"
checksum: 7f03ab05187a8e2bece21ef75ea844cf280202fc011e91408d109ea02f324d1662757f5a746ab68716606bb582e9490af4bf9ebece5f3200737fb99ac3132efc
languageName: node
linkType: hard

"regexp.prototype.flags@npm:^1.3.1":
version: 1.3.1
resolution: "regexp.prototype.flags@npm:1.3.1"
Expand Down Expand Up @@ -24917,12 +24855,10 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"tinylogic@npm:^1.0.3":
version: 1.0.3
resolution: "tinylogic@npm:1.0.3"
dependencies:
chevrotain: ^9.1.0
checksum: c2df54738430317f7900bb50502ee74ea57ccd31ce49bd42b51f05be7ef4460240ac18304a014ac51dd2457a873200114b424ee371a89f5bd017db47854fb936
"tinylogic@npm:^2.0.0":
version: 2.0.0
resolution: "tinylogic@npm:2.0.0"
checksum: 8c97825b2916ace0cee7dbd9f39762c063ca7cf27f5f0c3f0c16bab2de8580b07a8bb123ebcd52767ff5923919eb70f241ccc4f7d1889ad0c07aa77d88dcb409
languageName: node
linkType: hard

Expand Down Expand Up @@ -27430,21 +27366,6 @@ [email protected]:
languageName: node
linkType: hard

"yup@npm:^0.32.9":
version: 0.32.9
resolution: "yup@npm:0.32.9"
dependencies:
"@babel/runtime": ^7.10.5
"@types/lodash": ^4.14.165
lodash: ^4.17.20
lodash-es: ^4.17.15
nanoclone: ^0.2.1
property-expr: ^2.0.4
toposort: ^2.0.2
checksum: 37ba8d0c0de093b212ba0a7839dc385df914b60aff4c0e32af5173e7d54fad30d021c77ed7833c6283dbade9101c029357eb37c664e55c7216141e3c76720dd2
languageName: node
linkType: hard

"yurnalist@npm:^2.1.0":
version: 2.1.0
resolution: "yurnalist@npm:2.1.0"
Expand Down

0 comments on commit b730176

Please sign in to comment.