Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: selectively import required semver functions #511

Merged
merged 1 commit into from
Jul 12, 2024
Merged

chore: selectively import required semver functions #511

merged 1 commit into from
Jul 12, 2024

Conversation

wojtekmaj
Copy link
Contributor

@wojtekmaj wojtekmaj commented Jul 11, 2024

By selectively importing only the functions we want, we avoid bundling in the entire semver package, which results in impressive savings of roughly 25 KB.

Before:

wmaj@MacBook-Air corepack % yarn build

  dist/lib/corepack.cjs  949.5kb

After:

wmaj@MacBook-Air corepack % yarn build

  dist/lib/corepack.cjs  924.7kb

It also (minimally) reduces execution time:

Benchmark 1: node dist/lib/corepack_before.cjs
  Time (mean ± σ):      43.9 ms ±   5.1 ms    [User: 38.9 ms, System: 4.1 ms]
  Range (min … max):    42.1 ms …  83.5 ms    65 runs
 
Benchmark 2: node dist/lib/corepack_after.cjs
  Time (mean ± σ):      42.8 ms ±   4.7 ms    [User: 37.9 ms, System: 4.1 ms]
  Range (min … max):    40.7 ms …  80.6 ms    67 runs
 
Summary
  node dist/lib/corepack_after.cjs ran
    1.03 ± 0.16 times faster than node dist/lib/corepack_before.cjs

By selectively importing only the functions we want, we avoid bundling in the entire semver package, which brings impressive savings.

Before:
```
wmaj@MacBook-Air corepack % yarn build

  dist/lib/corepack.cjs  949.5kb
```

After:
```
wmaj@MacBook-Air corepack % yarn build

  dist/lib/corepack.cjs  924.7kb
```
@aduh95 aduh95 merged commit e7ad533 into nodejs:main Jul 12, 2024
10 checks passed
@wojtekmaj wojtekmaj deleted the selective-semver-import branch July 12, 2024 10:08
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.

3 participants