Build a distributable Vite library without bundling your dependencies
Use Vite library mode and Rollup externals to ship a component library that consumers can tree-shake, without shipping React or Vue inside your bundle.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use Vite library mode and Rollup externals to ship a component library that consumers can tree-shake, without shipping React or Vue inside your bundle.
Configure Rollup tree-shaking to remove unused ES module exports from browser bundles, with a worked example and verification steps.
Configure Rollup with format es and preserveModules true to emit a directory of ES files that mirrors your source, enabling downstream tree‑shaking without bundling the whole library.
A practical audit for Rollup bundles: identify exports that survive tree shaking, decide between moduleSideEffects and /*@__PURE__*/ annotations, and verify the result without breaking side-effect code.
Decide between Vite's esnext ESM target and legacy fallback bundles. Compare build size, speed, and browser support with a practical configuration and validation checklist.
Learn how Rollup's preserveModules option keeps your ES module file structure intact while allowing tree‑shaking of external dependencies.
Learn how Vite’s native ES module serving eliminates bundling in development, giving near‑instant start and precise Hot Module Replacement, with a concrete setup example and notes on browser support and monorepo considerations.
Rollup's tree shaking uses ES Module static structure to drop unused exports. Learn how the treeshake config tunes aggressiveness, why sideEffects flags matter, and how to verify the output in CI.
How Rollup decides which modules to drop, why package.json sideEffects is a trust boundary, and the checks that catch a wrong declaration before users do.