From 1acf36d489dab75d169883e9d08bcfa1e0f722bf Mon Sep 17 00:00:00 2001 From: patak Date: Tue, 23 May 2023 20:30:57 +0200 Subject: [PATCH 1/3] docs: optimizeDeps.needsInterop --- docs/config/dep-optimization-options.md | 7 +++++++ packages/vite/src/node/optimizer/index.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/config/dep-optimization-options.md b/docs/config/dep-optimization-options.md index 6c7f372a02109c..cbc659e13f718d 100644 --- a/docs/config/dep-optimization-options.md +++ b/docs/config/dep-optimization-options.md @@ -65,3 +65,10 @@ Optimizing dependencies in build mode is **experimental**. If enabled, it remove 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: [] }`. ::: + +## optimizeDeps.needsInterop + +- **Experimental** +- **Type:** `string[]` + +Forces ESM interop when importing these dependencies. Some legacy packages advertise themselves as ESM but use `require` internally. Adding these packages to `needsInterop` can speed up cold start by avoiding full-page reloads. You'll receive a warning if one of your dependencies is triggering a reload, suggesting to add the package name to this array in your config. diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index a1d88a46e90d8c..5947305115c548 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -78,7 +78,7 @@ export interface DepOptimizationConfig { */ exclude?: string[] /** - * Force ESM interop when importing for these dependencies. Some legacy + * Forces ESM interop when importing these dependencies. Some legacy * packages advertise themselves as ESM but use `require` internally * @experimental */ From 57d5a54adcf4c1d28080a57ab894fe257d9ca0c8 Mon Sep 17 00:00:00 2001 From: patak-dev Date: Wed, 24 May 2023 09:42:32 +0200 Subject: [PATCH 2/3] chore: update wording --- docs/config/dep-optimization-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/dep-optimization-options.md b/docs/config/dep-optimization-options.md index cbc659e13f718d..80215391059c7c 100644 --- a/docs/config/dep-optimization-options.md +++ b/docs/config/dep-optimization-options.md @@ -71,4 +71,4 @@ If you want to try this build strategy, you can use `optimizeDeps.disabled: fals - **Experimental** - **Type:** `string[]` -Forces ESM interop when importing these dependencies. Some legacy packages advertise themselves as ESM but use `require` internally. Adding these packages to `needsInterop` can speed up cold start by avoiding full-page reloads. You'll receive a warning if one of your dependencies is triggering a reload, suggesting to add the package name to this array in your config. +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, some legacy packages advertise themselves as ESM but use `require` internally. 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. From 0cf5ceef32f1ee509eebfd27511d7c41b597988f Mon Sep 17 00:00:00 2001 From: patak Date: Wed, 24 May 2023 15:37:16 +0200 Subject: [PATCH 3/3] chore: update wording with Blu's suggestion Co-authored-by: Bjorn Lu <34116392+bluwy@users.noreply.github.com> --- docs/config/dep-optimization-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/dep-optimization-options.md b/docs/config/dep-optimization-options.md index 80215391059c7c..60fb26cf8f4249 100644 --- a/docs/config/dep-optimization-options.md +++ b/docs/config/dep-optimization-options.md @@ -71,4 +71,4 @@ If you want to try this build strategy, you can use `optimizeDeps.disabled: fals - **Experimental** - **Type:** `string[]` -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, some legacy packages advertise themselves as ESM but use `require` internally. 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. +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.