Skip to content

Commit b34e79c

Browse files
patak-devbluwy
andauthored
docs: optimizeDeps.needsInterop (#13323)
Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com>
1 parent 32c5a9a commit b34e79c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/config/dep-optimization-options.md

+7
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ Optimizing dependencies in build mode is **experimental**. If enabled, it remove
6565

6666
If you want to try this build strategy, you can use `optimizeDeps.disabled: false`. `@rollup/plugin-commonjs` can be removed by passing `build.commonjsOptions: { include: [] }`.
6767
:::
68+
69+
## optimizeDeps.needsInterop
70+
71+
- **Experimental**
72+
- **Type:** `string[]`
73+
74+
Forces ESM interop when importing these dependencies. Vite is able to properly detect when a dependency needs interop, so this option isn't generally needed. However, different combinations of dependencies could cause some of them to be prebundled differently. Adding these packages to `needsInterop` can speed up cold start by avoiding full-page reloads. You'll receive a warning if this is the case for one of your dependencies, suggesting to add the package name to this array in your config.

packages/vite/src/node/optimizer/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface DepOptimizationConfig {
7878
*/
7979
exclude?: string[]
8080
/**
81-
* Force ESM interop when importing for these dependencies. Some legacy
81+
* Forces ESM interop when importing these dependencies. Some legacy
8282
* packages advertise themselves as ESM but use `require` internally
8383
* @experimental
8484
*/

0 commit comments

Comments
 (0)