Skip to content

chore: selectively import required semver functions - #511

Merged
aduh95 merged 1 commit into
nodejs:mainfrom
wojtekmaj:selective-semver-import
Jul 12, 2024
Merged

aduh95 merged 1 commit into
nodejs:mainfrom
wojtekmaj:selective-semver-import

Conversation

@wojtekmaj

@wojtekmaj wojtekmaj commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

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
@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