Skip to content

Commit

Permalink
docs(prebundling): update latest options and behaviour (#12179)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Feb 24, 2023
1 parent 8f57a18 commit 3d3788d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/config/dep-optimization-options.md
Expand Up @@ -54,6 +54,7 @@ Set to `true` to force dependency pre-bundling, ignoring previously cached optim

## optimizeDeps.disabled

- **Experimental**
- **Type:** `boolean | 'build' | 'dev'`
- **Default:** `'build'`

Expand Down
13 changes: 4 additions & 9 deletions docs/guide/dep-pre-bundling.md
@@ -1,13 +1,6 @@
# Dependency Pre-Bundling

When you run `vite` for the first time, you may notice this message:

```
Pre-bundling dependencies:
react
react-dom
(this will be run only when your dependencies or config have changed)
```
When you run `vite` for the first time, Vite prebundles your project dependencies before loading your site locally. It is done automatically and transparently by default.

## The Why

Expand Down Expand Up @@ -36,7 +29,7 @@ Dependency pre-bundling only applies in development mode, and uses `esbuild` to

If an existing cache is not found, Vite will crawl your source code and automatically discover dependency imports (i.e. "bare imports" that expect to be resolved from `node_modules`) and use these found imports as entry points for the pre-bundle. The pre-bundling is performed with `esbuild` so it's typically very fast.

After the server has already started, if a new dependency import is encountered that isn't already in the cache, Vite will re-run the dep bundling process and reload the page.
After the server has already started, if a new dependency import is encountered that isn't already in the cache, Vite will re-run the dep bundling process and reload the page if needed.

## Monorepos and Linked Dependencies

Expand Down Expand Up @@ -71,6 +64,8 @@ A typical use case for `optimizeDeps.include` or `optimizeDeps.exclude` is when

Both `include` and `exclude` can be used to deal with this. If the dependency is large (with many internal modules) or is CommonJS, then you should include it; If the dependency is small and is already valid ESM, you can exclude it and let the browser load it directly.

You can further customize esbuild too with the [`optimizeDeps.esbuildOptions` option](/config/dep-optimization-options.md#optimizedeps-esbuildoptions). For example, adding an esbuild plugin to handle special files in dependencies.

## Caching

### File System Cache
Expand Down

0 comments on commit 3d3788d

Please sign in to comment.