---
source: https://iinventedlight.com/library/notes/vite-dep-pre-bundling.md
title: "Vite pre-bundles dependencies in development for ESM and performance"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (vitejs/vite docs and source); prose restates cited source lines in own words"
license_family: vite-mit
attribution: "Summary by iinventedlight (AI-assisted). Sources: Vite docs and Vite source (vitejs/vite), MIT. Notices: Vite documentation and source (vitejs/vite): Copyright (c) 2019-present, VoidZero Inc. and Vite contributors; MIT (https://raw.githubusercontent.com/vitejs/vite/main/LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-11
status: published
approved_by: "Cole Withington, 2026-11-11 09:59 PT, Librarian chat widget t34s5: \"Yes, publish all 25 Angular and Vite drafts\""
checked_on: 2026-11-11
as_of: 2026-11-11
confidence: medium
untested: "No project was run for this note; only the fetched documentation and source files were read."
category: coding-references
topic_area: "code-web: Vite dependency pre-bundling"
tags: [vite, optimize-deps, esm, dependencies]
client: Librarian
sources:
  - id: S1
    title: "Dependency Pre-Bundling"
    publisher: Vite docs
    url: https://vite.dev/guide/dep-pre-bundling
    accessed: 2026-11-11
    license: "MIT"
  - id: S2
    title: "optimizer"
    publisher: Vite source
    url: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/optimizer/index.ts
    accessed: 2026-11-11
    license: "MIT"
---
# Dependency pre-bundling converts deps to ESM and reduces request waterfalls

**Answer:** The first time you run `vite`, Vite pre-bundles project dependencies before loading the site locally. This happens automatically and transparently by default. Dependency pre-bundling applies only in development mode.

This process serves two purposes. First, during development Vite serves all code as native ESM, so dependencies shipped as CommonJS or UMD must be converted to ESM. Vite also converts ESM dependencies with many internal modules into a single module. A package such as `lodash-es` can ship hundreds of internal files; pre-bundling it means the browser makes one request instead of many.

If no cache is found, Vite crawls your source and treats bare imports from `node_modules` as entry points for the pre-bundle.

## In source

The include option forces listed dependencies to be optimized. The exclude option lists dependencies that must not be optimized. Those paths must be resolvable import paths, and exclude cannot be globs.

## See also

- [vite-native-esm](https://iinventedlight.com/library/notes/vite-native-esm/)
- [vite-dev-server-and-build](https://iinventedlight.com/library/notes/vite-dev-server-and-build/)

## Claims

- id: C1
  claim: Vite pre-bundles project dependencies the first time you run vite.
  source: S1
  evidence: "Vite prebundles your project dependencies before loading your site locally."

- id: C2
  claim: Pre-bundling applies only in development mode.
  source: S1
  evidence: "Dependency pre-bundling only applies in development mode."

- id: C3
  claim: include forces listed dependencies to be optimized.
  source: S2
  evidence: "Force optimize listed dependencies (must be resolvable import paths)."

- id: C4
  claim: exclude lists dependencies that must not be optimized.
  source: S2
  evidence: "Do not optimize these dependencies (must be resolvable import paths,"

## Sources

- [S1] Dependency Pre-Bundling. Vite docs. https://vite.dev/guide/dep-pre-bundling . License: MIT. Accessed 2026-11-11.

- [S2] optimizer. Vite source. https://github.com/vitejs/vite/blob/main/packages/vite/src/node/optimizer/index.ts . License: MIT. Accessed 2026-11-11.


License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: Vite documentation and source (vitejs/vite): Copyright (c) 2019-present, VoidZero Inc. and Vite contributors; MIT (https://raw.githubusercontent.com/vitejs/vite/main/LICENSE). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
