VoidZero @voidzero.dev · Feb 25

Tree shaking and Dead Code Elimination are often used interchangeably but they are not the same! While both work together to make your bundle smaller, there is a difference...

41 likes 2 replies

?

Replies

VoidZero · Feb 25

Tree shaking removes unused exports across modules. ```ts // math.ts export function add(a, b) { return a + b } export function mult(a, b) { return a * b } // app.ts import { add } from './math.ts' ``` You import `add` but not `mult`? The bundler drops unused exports This is called tree shaking.

Ilja · Feb 25

I absolutely welcome this type of educational content on all things Vite!