127
tree shaking
Dead exports are dropped from the bundle. A side-effect import keeps the whole module.
What is tree shaking?
Tree shaking removes unused exports when the bundler can see that they are pure. `import _ from "lodash"` drags the library. `import { debounce } from "lodash-es"` can leave the rest behind. A module that runs code on import is not shakeable.
Why does tree shaking matter when vibe coding?
Models install a utility kitchen sink and import the default. The bundle grows and they blame the framework. Name the import style.
How do you do tree shaking?
Import the function you call. Avoid import-for-side-effect except polyfills you mean. Check the bundle for libraries you only used once.
How do you ask a model for tree shaking?
Import only (function) from (package). Do not import the default barrel if it pulls the whole library. Do not add a side-effect import “just in case.”
What goes wrong with tree shaking?
A barrel file that re-exports everything and is imported by the app root. Shaking stops at that barrel.