From 72ac711cc2eecdc301ba3dabd91646ded8fe62c6 Mon Sep 17 00:00:00 2001 From: Ilya Golovin Date: Tue, 6 Jun 2023 02:02:08 +0300 Subject: [PATCH 1/5] docs(chunking strategy): add warning block --- docs/guide/build.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/guide/build.md b/docs/guide/build.md index 7b711fe03a0bea..d62706d12b329b 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -60,6 +60,9 @@ export default defineConfig({ This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkCache })` factory, in case composition with custom logic is needed. `cache.reset()` needs to be called at `buildStart` for build watch mode to work correctly in this case. +::: warning +You should use `build.rollupOptions.output.manualChunks` function form when using this plugin for correct work +::: ## Rebuild on files changes You can enable rollup watcher with `vite build --watch`. Or, you can directly adjust the underlying [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch) via `build.watch`: From fd7d07bcc444a41dba9cc8e17152e702884e46ac Mon Sep 17 00:00:00 2001 From: Ilya Golovin Date: Tue, 6 Jun 2023 03:33:19 +0300 Subject: [PATCH 2/5] chore: add manual chunks object form usage warning --- packages/vite/src/node/plugins/splitVendorChunk.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/vite/src/node/plugins/splitVendorChunk.ts b/packages/vite/src/node/plugins/splitVendorChunk.ts index efe0a18a2c9440..e5407cd9e6fb4a 100644 --- a/packages/vite/src/node/plugins/splitVendorChunk.ts +++ b/packages/vite/src/node/plugins/splitVendorChunk.ts @@ -116,6 +116,10 @@ export function splitVendorChunkPlugin(): Plugin { } // else, leave the object form of manualChunks untouched, as // we can't safely replicate rollup handling. + // eslint-disable-next-line no-console + console.warn( + '(!) `build.rollupOptions.manualChunks` object form is ignored when used with the `splitVendorChunk` plugin. Consider using the function form instead.', + ) } else { output.manualChunks = viteManualChunks } From b871e7d622e10707473c2da6d3cabb962fd5caf7 Mon Sep 17 00:00:00 2001 From: Ilya Golovin Date: Tue, 6 Jun 2023 11:46:40 +0300 Subject: [PATCH 3/5] fix: prettier --- docs/guide/build.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/guide/build.md b/docs/guide/build.md index d62706d12b329b..ec3a305f481c8e 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -63,6 +63,7 @@ This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkC ::: warning You should use `build.rollupOptions.output.manualChunks` function form when using this plugin for correct work ::: + ## Rebuild on files changes You can enable rollup watcher with `vite build --watch`. Or, you can directly adjust the underlying [`WatcherOptions`](https://rollupjs.org/configuration-options/#watch) via `build.watch`: From 0738dd0dff8ca63d24e52271d1010e0f6ef49088 Mon Sep 17 00:00:00 2001 From: Ilya Golovin <74474615+maIIady@users.noreply.github.com> Date: Tue, 6 Jun 2023 12:40:35 +0300 Subject: [PATCH 4/5] fix: update messages Co-authored-by: patak --- docs/guide/build.md | 2 +- packages/vite/src/node/plugins/splitVendorChunk.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/build.md b/docs/guide/build.md index ec3a305f481c8e..d95e23520805df 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -61,7 +61,7 @@ export default defineConfig({ This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkCache })` factory, in case composition with custom logic is needed. `cache.reset()` needs to be called at `buildStart` for build watch mode to work correctly in this case. ::: warning -You should use `build.rollupOptions.output.manualChunks` function form when using this plugin for correct work +You should use `build.rollupOptions.output.manualChunks` function form when using this plugin. If the object form is used, the plugin won't have any effect. ::: ## Rebuild on files changes diff --git a/packages/vite/src/node/plugins/splitVendorChunk.ts b/packages/vite/src/node/plugins/splitVendorChunk.ts index e5407cd9e6fb4a..05d5235a5b7f22 100644 --- a/packages/vite/src/node/plugins/splitVendorChunk.ts +++ b/packages/vite/src/node/plugins/splitVendorChunk.ts @@ -118,7 +118,7 @@ export function splitVendorChunkPlugin(): Plugin { // we can't safely replicate rollup handling. // eslint-disable-next-line no-console console.warn( - '(!) `build.rollupOptions.manualChunks` object form is ignored when used with the `splitVendorChunk` plugin. Consider using the function form instead.', + '(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.manualChunks`. Consider using the function form instead.', ) } else { output.manualChunks = viteManualChunks From 8af9e9dc59efb3e906c9735bba5cc9bfa9f8a8a1 Mon Sep 17 00:00:00 2001 From: Ilya Golovin Date: Tue, 6 Jun 2023 12:46:45 +0300 Subject: [PATCH 5/5] fix: prettier --- docs/guide/build.md | 2 +- packages/vite/src/node/plugins/splitVendorChunk.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/build.md b/docs/guide/build.md index d95e23520805df..f817afaa6614bc 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -61,7 +61,7 @@ export default defineConfig({ This strategy is also provided as a `splitVendorChunk({ cache: SplitVendorChunkCache })` factory, in case composition with custom logic is needed. `cache.reset()` needs to be called at `buildStart` for build watch mode to work correctly in this case. ::: warning -You should use `build.rollupOptions.output.manualChunks` function form when using this plugin. If the object form is used, the plugin won't have any effect. +You should use `build.rollupOptions.output.manualChunks` function form when using this plugin. If the object form is used, the plugin won't have any effect. ::: ## Rebuild on files changes diff --git a/packages/vite/src/node/plugins/splitVendorChunk.ts b/packages/vite/src/node/plugins/splitVendorChunk.ts index 05d5235a5b7f22..b8c5d2ca855b61 100644 --- a/packages/vite/src/node/plugins/splitVendorChunk.ts +++ b/packages/vite/src/node/plugins/splitVendorChunk.ts @@ -118,7 +118,7 @@ export function splitVendorChunkPlugin(): Plugin { // we can't safely replicate rollup handling. // eslint-disable-next-line no-console console.warn( - '(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.manualChunks`. Consider using the function form instead.', + "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.manualChunks`. Consider using the function form instead.", ) } else { output.manualChunks = viteManualChunks