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

build: migrate to esbuild #229

Merged
merged 3 commits into from
Jan 8, 2023
Merged

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented Jan 7, 2023

Migrated from webpack to esbuild which allowed removing the various webpack workarounds in the codebase.

Addresses #227 (comment)

The bundle size is reduced a tiny bit:

$ du -s dist-*
2176    dist-esbuild
2192    dist-webpack

The bundle produced by esbuild is a bit slower, probably because it doesn't code split, but in my opinion it's acceptable:

$ hyperfine -w 1 \
  "node ./dist-esbuild/corepack.js -v" \
  "node ./dist-esbuild/yarn.js -v" \
  "node ./dist-esbuild/npm.js -v" \
  "node ./dist-esbuild/pnpm.js -v" \
  "node ./dist-webpack/corepack.js -v" \
  "node ./dist-webpack/yarn.js -v" \
  "node ./dist-webpack/npm.js -v" \
  "node ./dist-webpack/pnpm.js -v"
Benchmark 1: node ./dist-esbuild/corepack.js -v
  Time (mean ± σ):      61.1 ms ±   0.5 ms    [User: 55.8 ms, System: 6.9 ms]
  Range (min … max):    60.2 ms …  62.3 ms    49 runs

Benchmark 2: node ./dist-esbuild/yarn.js -v
  Time (mean ± σ):     226.7 ms ±   2.6 ms    [User: 237.0 ms, System: 25.6 ms]
  Range (min … max):   221.9 ms … 230.5 ms    13 runs

Benchmark 3: node ./dist-esbuild/npm.js -v
  Time (mean ± σ):     226.1 ms ±   1.4 ms    [User: 240.6 ms, System: 36.1 ms]
  Range (min … max):   223.3 ms … 227.7 ms    13 runs

Benchmark 4: node ./dist-esbuild/pnpm.js -v
  Time (mean ± σ):     102.8 ms ±   1.2 ms    [User: 89.5 ms, System: 16.1 ms]
  Range (min … max):   101.5 ms … 108.0 ms    29 runs

Benchmark 5: node ./dist-webpack/corepack.js -v
  Time (mean ± σ):      47.1 ms ±   0.6 ms    [User: 41.1 ms, System: 7.0 ms]
  Range (min … max):    46.2 ms …  49.6 ms    63 runs

Benchmark 6: node ./dist-webpack/yarn.js -v
  Time (mean ± σ):     210.8 ms ±   1.0 ms    [User: 223.8 ms, System: 20.5 ms]
  Range (min … max):   209.4 ms … 212.4 ms    14 runs

Benchmark 7: node ./dist-webpack/npm.js -v
  Time (mean ± σ):     213.3 ms ±   1.9 ms    [User: 245.7 ms, System: 18.0 ms]
  Range (min … max):   210.4 ms … 216.7 ms    14 runs

Benchmark 8: node ./dist-webpack/pnpm.js -v
  Time (mean ± σ):      90.6 ms ±   1.3 ms    [User: 76.0 ms, System: 16.5 ms]
  Range (min … max):    88.9 ms …  96.4 ms    33 runs

Summary
  'node ./dist-webpack/corepack.js -v' ran
    1.30 ± 0.02 times faster than 'node ./dist-esbuild/corepack.js -v'
    1.92 ± 0.04 times faster than 'node ./dist-webpack/pnpm.js -v'
    2.18 ± 0.04 times faster than 'node ./dist-esbuild/pnpm.js -v'
    4.47 ± 0.06 times faster than 'node ./dist-webpack/yarn.js -v'
    4.53 ± 0.07 times faster than 'node ./dist-webpack/npm.js -v'
    4.80 ± 0.07 times faster than 'node ./dist-esbuild/npm.js -v'
    4.81 ± 0.08 times faster than 'node ./dist-esbuild/yarn.js -v'

And as a bonus the build time is reduced quite a bit:

$ hyperfine "yarn webpack"
Benchmark 1: yarn webpack
  Time (mean ± σ):      4.832 s ±  0.055 s    [User: 0.003 s, System: 0.003 s]
  Range (min … max):    4.770 s …  4.960 s    10 runs

$ hyperfine "yarn build:bundle"
Benchmark 1: yarn build:bundle
  Time (mean ± σ):     826.1 ms ±  21.6 ms    [User: 0.0 ms, System: 2.6 ms]
  Range (min … max):   804.6 ms … 873.8 ms    10 runs

package.json Show resolved Hide resolved
@aduh95 aduh95 merged commit 15ceb83 into nodejs:main Jan 8, 2023
@merceyz merceyz deleted the merceyz/build/esbuild branch January 8, 2023 14:22
@melvin54241

This comment was marked as spam.

@styfle
Copy link
Member

styfle commented Feb 17, 2023

Confirmed, the published size is a bit smaller 👍

  • 0.15.3: corepack@0.15.3
  • 0.16.0: corepack@0.16.0

@merceyz merceyz mentioned this pull request Jan 5, 2024
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.

4 participants