A bundler analyzes how JavaScript modules depend on one another, then combines them into output suited to distribution. This grew from the need to manage larger browser applications: concatenating scripts reduced requests, while module-aware bundlers could also optimize across dependencies. section 13.0 section 13.3
A modern bundler may:
- Analyze the module graph, remove unused code, and split output into logical chunks, such as shared libraries and page-specific content. section 13.3
- Transform and combine modules, including emitting a smaller set of ESM chunks from ESM and CommonJS inputs. section 13.3
- Handle build tasks beyond bundling, such as compiling TypeScript, transpiling newer syntax, processing CSS and images, or serving code during development. section 13.3
A build tool may coordinate these steps without doing the bundling itself. Vite, for example, is described as an orchestrator that delegates bundling to another library; calling every such tool a bundler is common but imprecise. section 13.3
Bundle a Node.js script
When installing npm dependencies is impractical, esbuild can create one JavaScript file containing a script and all its dependencies. section 3.3.2
Bundlers support optimized web delivery, but their ecosystems and configuration vary; detailed tool-specific usage is outside this treatment. section 13.3 section 13.4
