これなに
Bun 1.0が出たらしい。
Twitter(現X)情報だと、bun install
がとにかく早いらしいので調べてみた。
対象はAWS CDKのリポジトリとする。
調べ方
Bunは公式記載の方法でインストールする。簡単。
curl -fsSL https://bun.sh/install | bash
yarn intall
rm -rf node_modules/ && time yarn install
を5回実行する。
# 1回目
real 0m42.060s
user 0m28.544s
sys 0m27.346s
# 2回目
real 0m37.307s
user 0m27.554s
sys 0m24.019s
# 3回目
real 0m34.631s
user 0m26.526s
sys 0m25.207s
# 4回目
real 0m38.309s
user 0m27.107s
sys 0m24.790s
# 5回目
real 0m36.132s
user 0m26.972s
sys 0m23.865s
bun intall
rm -rf node_modules/ && time bun install
を5回実行する。
# 1回目
real 0m8.246s
user 0m0.195s
sys 0m6.060s
# 2回目
real 0m7.172s
user 0m0.198s
sys 0m6.036s
# 3回目
real 0m9.132s
user 0m0.217s
sys 0m7.234s
# 4回目
real 0m7.112s
user 0m0.179s
sys 0m5.813s
# 5回目
real 0m7.236s
user 0m0.262s
sys 0m5.917s
追記
パッケージinstallの後にlernaでビルドする部分があるが、bun install
した場合はエラーが出てしまった点については触れておく。
# pre-build packages
npx lerna run build --scope=aws-cdk-lib --scope=@aws-cdk-testing/framework-integ --skip-nx-cache
リポジトリのこのへんを読む限りYarnに依存している部分があるのかも。この辺はノウハウ待ちか。
> Lerna (powered by Nx) Running target build for 2 projects and 21 tasks they depend on
→ Executing 1/19 remaining tasks...
⠧ @aws-cdk/yarn-cling:build
✖ @aws-cdk/yarn-cling:build
yarn run v1.22.19
$ tsc
../../../node_modules/@types/glob/index.d.ts(29,42): error TS2694: Namespace '"/workspace/aws-cdk/node_modules/minimatch/dist/cjs/index"' has no exported member 'IOptions'.
../../../node_modules/@types/glob/index.d.ts(74,30): error TS2724: '"/workspace/aws-cdk/node_modules/minimatch/dist/cjs/index"' has no exported member named 'IMinimatch'. Did you mean 'Minimatch'?
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
> Lerna (powered by Nx) Ran target build for 2 projects and 21 tasks they depend on (18s)
✔ 4/5 succeeded [0 read from cache]
✖ 1/5 targets failed, including the following:
- @aws-cdk/yarn-cling:build
まとめ
うーん、早い。ざっくり4~5倍速い。安定したらbuild周りも調べて、良さそうならCIサーバなどの置き換えだけでもしたいところ。
こういう使い方もよさそう。