zero-install을 통해 배포 시간을 단축시켜 보자!라는 생각에서 출발한 실험.
사용한 프로젝트: 사내 백오피스 레포지토리
node version: v16.18.0
package manager: yarn@1.22.19
node version: v18.12.0
package manager: yarn@4.0.2
yarn set version berry
yarn install
yarn dlx @yarnpkg/sdks vscode
yarn plugin import typescript
Shift + Command(Ctrl) + P > Select Typescript version (workspace 버전으로)
node version: v16.18.0
package manager: pnpm@8.9.0
pnpm import
pnpm i
실험하던 중 동료 분의 추천으로 알게 된 매니어
런타임 및 패키지 매니저여서 node를 대체
install 시간이 빠름.
package manager: bun@1.0.11
bun install
bun run build
yarn classic | yarn berry | pnpm | bun | |
---|---|---|---|---|
install 시간(s) | yarn install 15.70s user 30.72s system 236% cpu 19.641 total CLI 상 기록 19.52s | NaN(zero install) yarn install 1.64s user 1.13s system 179% cpu 1.536 total (non zero-install) | pnpm i 5.79s user 25.23s system 319% cpu 9.715 total CLI 상 기록 9.6s | bun install 0.02s user 1.43s system 58% cpu 2.459 total CLI 상 기록 1389 packages installed [2.44s] |
빌드 시간(s) | yarn build 192.61s user 17.35s system 264% cpu 1:19.29 total CLI 상 기록 78.97s | yarn build 198.72s user 14.63s system 323% cpu 1:05.92 total | pnpm run build 229.94s user 19.31s system 228% cpu 1:48.97 total | bun run build 190.05s user 20.01s system 280% cpu 1:15.00 total |
전체 크기 (MB or GB) | 1.6GB | 980MB | 1.7GB | 1.6GB |
lock 크기 | 484KB yarn.lock | 540KB yarn.lock 1.4MB .pnp.cjs 68KB .pnp.loader.mjs | 428KB pnpm-lock.yaml | 580KB bun.lockb |
node_modules 혹은 .yarn 크기 (MB or GB) | 1.1GB node_modules | 433MB .yarn | 1.1GB node_modules | 1.1GB node_modules |
빌드 결과를 보고 각종 아티클에서는 pnpm이 일반적인 node_modules를 생성하는 package manager보다 더 효율적으로 공간을 관리한다고 들었는데 yarn classic과 큰 차이가 없는 걸 보고 의아해서 다시 한 번 리서치하다가 크나큰 착각을 했다는 것을 알게 됐다.
yarn classic과 npm(≥3.x.x)은 중복해서 설치되는 패키지를 줄이기 위해서 hoisting을 사용한다.
문제는 이렇게 되었을 때 package.json에서 명시하지 않은 package를 사용할 수 있게 된다. 이를 유령 의존성(phantom dependency)라고 한다.
pnpm에서는 중복을 피하기 위해 평탄화 작업(hoisting)을 하지 않고 symbolic link로 관리한다. yarn berry도 .pnp.cjs 파일을 보면 유사한 방식으로 symbolic link를 사용한다
결국 pnpm과 yarn classic 둘 다 중복 최소화에 대한 솔루션이 적용되어 있으므로 용량의 큰 차이는 없다.
yarn berry는 zip으로 압축했기 때문에 용량이 작은 것이다.
https://blog.hwahae.co.kr/all/tech/11962
https://blog.dramancompany.com/2023/02/리멤버-웹-서비스-좌충우돌-yarn-berry-도입기/