Bun
Why Bun exists
Bun's goal is simple: eliminate slowness and complexity without throwing away everything that's great about JavaScript. Your favorite libraries and frameworks should still work, and you shouldn't need to unlearn the conventions you're familiar with.
It all covers Node.js(npx, node, dotenv, nodemon, ws, fetch), Transpiler(tsc, babel, ts-node, tsx), Bundlers(esbuild, webpack, rollup), Package Manager(pnpm, yarn), Testing(jest, vitet)
Speed
Bun is fast, starting up to 4x faster than Node.js with esbuild, 17x faster than PNPM, 29x faster than npm, 33x faster than yarn, Bun is 1.75x faster than esbuild, 150x faster than Parcel 2, 180x times faster than Rollup + Terser, and 220x times faster than Webpack.
TypeScript and JSX support
Bun has a JavaScript transpiler, That means you can run JavaScript, TypeScript, and even JSX/TSX files, no dependencies needed.
ESM & CommonJS compatibility
You can use both import and require()
Web APIs
fetch, request, response, websocket, ReadableStream
Hot reloading, File CRUD, sqlite, password hash
심지어 TurboRepo에서도 Beta로 벌써 제공해준다. (Next13 App dir로 설치됨)
Yarn Berry PNP
- PnP를 지원하지 않는 패키지가 하나라도 존재하면 zero install의 장점을 누릴 수 없음
- PnP 모드는 node_modules 대신 .yarn/cache에 패키지를 압축하여 관리하기 때문에zero install을 할 수 있는건데 git 관리 측면에서 볼 때,이러한 사항은 commit이 많을수록, 그리고 한 commit에 포함되는 파일의 용량과 수가 많을수록영구히 기록되는 부분에 대한 영향이 적지 않다는 것이다.(그렇다고 commit history만 살리고 파일만 지우는 방법은 오버 엔지니어링이기 때문에)
- Ghost dependency 등 dependency 참조 관련 다양한 버그들이 존재
- Yarn PnP가 Git에 지속적으로 주는 부하
1) 커밋에 포함되지 않는 종속성 문제
2) ESLint import/order 관련 이슈
3) yarn berry에서 pre-hook 지원하지 않음
4) yarn berry와 vite를 함께 사용할 때 storybook이 실행되지 않는 문제
https://blog.dramancompany.com/2023/02/리멤버-웹-서비스-좌충우돌-yarn-berry-도입기/
Turbo Repo에서 yarn pnp 모드 지원하지 않음 → 2023년 5월 18일 터보레포 공식 도큐먼트에는 지원 안하다고 적혀있지만 팀원분이 이미 잘 적용해서 사용중 🤔
https://github.com/vercel/turbo/issues/693#issuecomment-1278886166
https://turbo.build/blog/turbo-1-1-0
Storybook에서 pnp 지원하지 않음 (실제로 우리도 기존 서비스 이거때문에 node_modules 사용)
https://github.com/storybookjs/builder-vite/issues/141
PNPM
pnpm 또한 체크섬을 활용하여 패키지의 무결성을 확인한다. pnpm은 **npm과 yarn classic에서 이슈가 되는 패키지 호이스팅**을 하지 않기 때문에 이러한 문제를 피한다. 이 대신, 위험한 dependency 액세스의 위험성을 제거하는 내부에 중첩된 node_modules폴더를 생성한다. 즉, dependency가 package.json 에서 명시적으로 선언된 경우에만 다른 dependency에 액세스 할 수 있다.
성능 비교를 보면 yarn pnp가 좋아, 하지만 cache 파일을 git pull 할 때 받아야하니 그렇게 차이는 안날지도
https://www.youtube.com/watch?v=Ds7EjE8Rhjs&ab_channel=우아한테크
마음은 Bun yarn berry pnp가 git pull 할 때 까지 포함하면 과연 빠른가? 그리고 pnp 를 사용하지 못하게 될 경우 시간적 손실, 사용하게 되더라도 turborepo와의 궁합과 github commit 관련, storybook 등 이유로 현실은 pnpm + SWC로 결정
좋은 글
'software engineering > javascript' 카테고리의 다른 글
using, satisfies in typescript (1) | 2023.10.30 |
---|---|
forEach is BAD! (0) | 2023.10.03 |
void 언제 쓸까? (0) | 2023.08.27 |
What's difference || and ?? in javascript? (0) | 2023.08.27 |
Warning: Received `true` for a non-boolean attribute in styled-components (0) | 2023.08.27 |