Building Reusable JavaScript Packages with Vite Library Mode
Learn how to use Vite's library mode to build reusable ES module and UMD packages from a single configuration, with practical guidance on externals, package.json fields, and verification.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how to use Vite's library mode to build reusable ES module and UMD packages from a single configuration, with practical guidance on externals, package.json fields, and verification.
Vite pre-bundles node_modules with esbuild in dev, so a stale optimized bundle is usually a cache and discovery problem — not a broken install.
Vite inlines VITE_-prefixed variables into the browser bundle at build time. This note covers a minimal design that keeps secrets in Node-side config, operational checks to prevent leaks, and failure modes to avoid.
Vite pre-bundles your dependencies with esbuild at dev-server startup, turning hundreds of module requests into one per package. Here's how it works, how to verify it, and when to tune optimizeDeps.
Vite’s Hot Module Replacement uses native ES modules to update only changed parts of an app, preserving state with React Fast Refresh. See a concrete example, how to use <code>import.meta.hot</code>, and common pitfalls.
Learn how to use the import.meta.hot API in Vite to create HMR boundaries, prevent full page reloads, and properly clean up side effects during development.
Learn how Vite automatically treats files ending in .module.css (and variants) as CSS Modules, how to import them, tweak the hash format, and what to watch out for when mixing global and module styles.
Vite's SWC-based React plugin replaces Babel with a Rust compiler for faster JSX transforms. Here's the migration, how to measure the gain on your own codebase, and the Babel-plugin trade-offs that decide whether it's worth it.
Vite serves source as native ES modules, eliminating dev-time bundling. HMR updates only the changed module chain, preserving state. Trade-off: first-run dependency pre-bundling can be slow for large projects.