Remove Unused Exports from Browser Bundles with Rollup
Configure Rollup tree-shaking to remove unused ES module exports from browser bundles, with a worked example and verification steps.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Configure Rollup tree-shaking to remove unused ES module exports from browser bundles, with a worked example and verification steps.
Learn how to link two Notion databases using Relation and Rollup properties to create a single source of truth, with verification steps and recovery options.
Learn how to enable Rollup’s tree shaking to drop unused ES‑module exports, verify the size reduction, and handle common pitfalls like side‑effects and dynamic imports.
Learn how Rollup's manualChunks option separates vendor libraries from application code, improving browser cache reuse and reducing re-downloads on every deploy.
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.
Stop shipping unused code. Learn how Rollup's tree shaking uses ESM static analysis to prune dead code and how to avoid the common 'side effect' pitfalls that break production apps.
Tree-shaking in Rollup depends on a precise sideEffects contract. Learn how ESM boundaries, named exports, and visualizer audits keep library bundles lean.
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.
Use Vite build.lib to bundle a library entry point, externalize dependencies, and wire up package.json exports for npm consumers.