From 3d3788d5518350dd989659548ce0610134781851 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 24 Feb 2023 17:01:16 +0800 Subject: [PATCH] docs(prebundling): update latest options and behaviour (#12179) --- docs/config/dep-optimization-options.md | 1 + docs/guide/dep-pre-bundling.md | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/config/dep-optimization-options.md b/docs/config/dep-optimization-options.md index e6739ed3c6b09c..6c7f372a02109c 100644 --- a/docs/config/dep-optimization-options.md +++ b/docs/config/dep-optimization-options.md @@ -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'` diff --git a/docs/guide/dep-pre-bundling.md b/docs/guide/dep-pre-bundling.md index 5d5d98cac72645..ddfad451322c08 100644 --- a/docs/guide/dep-pre-bundling.md +++ b/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 @@ -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 @@ -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