Skip to content

feat!: use fetch#365

Merged
aduh95 merged 38 commits intonodejs:mainfrom
merceyz:merceyz/refactor/fetch
Feb 11, 2024
Merged

feat!: use fetch#365
aduh95 merged 38 commits intonodejs:mainfrom
merceyz:merceyz/refactor/fetch

Conversation

@merceyz
Copy link
Member

@merceyz merceyz commented Jan 28, 2024

Changes Corepack to use the built-in fetch and the ProxyAgent from Undici.

Since fetch supports compressed responses by default the bandwidth used when fetching from https://repo.yarnpkg.com/tags is also reduced (Transferred 1.71 kB (5.46 kB size).

Closes #361
FIxes #293

$ du dist/lib/corepack*
956     dist/lib/corepack-new.cjs
2272    dist/lib/corepack-old.cjs
$ node -v
v20.11.0
$ hyperfine -w 5 "node ./dist/lib/corepack-new.cjs --version" "node ./dist/lib/corepack-old.cjs --version"
Benchmark 1: node ./dist/lib/corepack-new.cjs --version
  Time (mean ± σ):      47.6 ms ±   0.9 ms    [User: 43.6 ms, System: 6.4 ms]
  Range (min … max):    46.0 ms …  50.7 ms    63 runs

Benchmark 2: node ./dist/lib/corepack-old.cjs --version
  Time (mean ± σ):      61.1 ms ±   1.2 ms    [User: 53.6 ms, System: 10.0 ms]
  Range (min … max):    59.5 ms …  64.7 ms    50 runs

Summary
  node ./dist/lib/corepack-new.cjs --version ran
    1.28 ± 0.03 times faster than node ./dist/lib/corepack-old.cjs --version

BREAKING CHANGE:
Corepack is now using the built-in fetch method and the ProxyAgent from Undici to perform requests, setups using custom registries and/or proxies might be affected.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] support fetch COREPACK_NPM_REGISTRY from http protocol REGISTRY

5 participants