Skip to content

Commit 45a06da

Browse files
authored
chore: deprecate splitVendorChunkPlugin (#16274)
1 parent ffedc06 commit 45a06da

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

docs/guide/build.md

+1-15
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,7 @@ For example, you can specify multiple Rollup outputs with plugins that are only
4747

4848
## Chunking Strategy
4949

50-
You can configure how chunks are split using `build.rollupOptions.output.manualChunks` (see [Rollup docs](https://rollupjs.org/configuration-options/#output-manualchunks)). Until Vite 2.8, the default chunking strategy divided the chunks into `index` and `vendor`. It is a good strategy for some SPAs, but it is hard to provide a general solution for every Vite target use case. From Vite 2.9, `manualChunks` is no longer modified by default. You can continue to use the Split Vendor Chunk strategy by adding the `splitVendorChunkPlugin` in your config file:
51-
52-
```js
53-
// vite.config.js
54-
import { splitVendorChunkPlugin } from 'vite'
55-
export default defineConfig({
56-
plugins: [splitVendorChunkPlugin()],
57-
})
58-
```
59-
60-
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.
61-
62-
::: warning
63-
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.
64-
:::
50+
You can configure how chunks are split using `build.rollupOptions.output.manualChunks` (see [Rollup docs](https://rollupjs.org/configuration-options/#output-manualchunks)). If you use a framework, refer to their documentation for configuring how chunks are splitted.
6551

6652
## Load Error Handling
6753

packages/vite/src/node/plugins/splitVendorChunk.ts

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export const isCSSRequest = (request: string): boolean =>
2626
// The cache needs to be reset on buildStart for watch mode to work correctly
2727
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
2828

29+
/**
30+
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
31+
*/
2932
export class SplitVendorChunkCache {
3033
cache: Map<string, boolean>
3134
constructor() {
@@ -36,6 +39,9 @@ export class SplitVendorChunkCache {
3639
}
3740
}
3841

42+
/**
43+
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
44+
*/
3945
export function splitVendorChunk(
4046
options: { cache?: SplitVendorChunkCache } = {},
4147
): GetManualChunk {
@@ -87,6 +93,9 @@ function staticImportedByEntry(
8793
return someImporterIs
8894
}
8995

96+
/**
97+
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
98+
*/
9099
export function splitVendorChunkPlugin(): Plugin {
91100
const caches: SplitVendorChunkCache[] = []
92101
function createSplitVendorChunk(output: OutputOptions, config: UserConfig) {

0 commit comments

Comments
 (0)