|
1 | 1 | import type {
|
2 | 2 | GetManualChunk,
|
3 | 3 | GetModuleInfo,
|
4 |
| - ManualChunkMeta, |
5 |
| - OutputOptions, |
| 4 | + // ManualChunkMeta, |
| 5 | + // OutputOptions, |
6 | 6 | } from 'rollup'
|
7 |
| -import { arraify, isInNodeModules } from '../utils' |
8 |
| -import type { UserConfig } from '../../node' |
| 7 | +import { /* arraify, */ isInNodeModules } from '../utils' |
| 8 | +// import type { UserConfig } from '../../node' |
9 | 9 | import type { Plugin } from '../plugin'
|
10 | 10 |
|
11 | 11 | // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
@@ -97,58 +97,58 @@ function staticImportedByEntry(
|
97 | 97 | * @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
98 | 98 | */
|
99 | 99 | export function splitVendorChunkPlugin(): Plugin {
|
100 |
| - const caches: SplitVendorChunkCache[] = [] |
101 |
| - function createSplitVendorChunk(output: OutputOptions, config: UserConfig) { |
102 |
| - const cache = new SplitVendorChunkCache() |
103 |
| - caches.push(cache) |
104 |
| - const build = config.build ?? {} |
105 |
| - const format = output?.format |
106 |
| - if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') { |
107 |
| - return splitVendorChunk({ cache }) |
108 |
| - } |
109 |
| - } |
| 100 | + // const caches: SplitVendorChunkCache[] = [] |
| 101 | + // function createSplitVendorChunk(output: OutputOptions, config: UserConfig) { |
| 102 | + // const cache = new SplitVendorChunkCache() |
| 103 | + // caches.push(cache) |
| 104 | + // const build = config.build ?? {} |
| 105 | + // const format = output?.format |
| 106 | + // if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') { |
| 107 | + // return splitVendorChunk({ cache }) |
| 108 | + // } |
| 109 | + // } |
110 | 110 | return {
|
111 | 111 | name: 'vite:split-vendor-chunk',
|
112 |
| - config(config) { |
113 |
| - let output = config?.build?.rollupOptions?.output |
114 |
| - if (output) { |
115 |
| - // outputs = arraify(outputs) |
116 |
| - // for (const output of outputs) { |
117 |
| - const viteManualChunks = createSplitVendorChunk(output, config) |
118 |
| - if (viteManualChunks) { |
119 |
| - if (output.manualChunks) { |
120 |
| - if (typeof output.manualChunks === 'function') { |
121 |
| - const userManualChunks = output.manualChunks |
122 |
| - output.manualChunks = (id: string, api: ManualChunkMeta) => { |
123 |
| - return userManualChunks(id, api) ?? viteManualChunks(id, api) |
124 |
| - } |
125 |
| - } else { |
126 |
| - // else, leave the object form of manualChunks untouched, as |
127 |
| - // we can't safely replicate rollup handling. |
128 |
| - // eslint-disable-next-line no-console |
129 |
| - console.warn( |
130 |
| - "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead.", |
131 |
| - ) |
132 |
| - } |
133 |
| - } else { |
134 |
| - output.manualChunks = viteManualChunks |
135 |
| - } |
136 |
| - } |
137 |
| - // } |
138 |
| - } else { |
139 |
| - return { |
140 |
| - build: { |
141 |
| - rollupOptions: { |
142 |
| - output: { |
143 |
| - manualChunks: createSplitVendorChunk({}, config), |
144 |
| - }, |
145 |
| - }, |
146 |
| - }, |
147 |
| - } |
148 |
| - } |
149 |
| - }, |
150 |
| - buildStart() { |
151 |
| - caches.forEach((cache) => cache.reset()) |
152 |
| - }, |
| 112 | + // config(config) { |
| 113 | + // let output = config?.build?.rollupOptions?.output |
| 114 | + // if (output) { |
| 115 | + // // outputs = arraify(outputs) |
| 116 | + // // for (const output of outputs) { |
| 117 | + // const viteManualChunks = createSplitVendorChunk(output, config) |
| 118 | + // if (viteManualChunks) { |
| 119 | + // if (output.manualChunks) { |
| 120 | + // if (typeof output.manualChunks === 'function') { |
| 121 | + // const userManualChunks = output.manualChunks |
| 122 | + // output.manualChunks = (id: string, api: ManualChunkMeta) => { |
| 123 | + // return userManualChunks(id, api) ?? viteManualChunks(id, api) |
| 124 | + // } |
| 125 | + // } else { |
| 126 | + // // else, leave the object form of manualChunks untouched, as |
| 127 | + // // we can't safely replicate rollup handling. |
| 128 | + // // eslint-disable-next-line no-console |
| 129 | + // console.warn( |
| 130 | + // "(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead.", |
| 131 | + // ) |
| 132 | + // } |
| 133 | + // } else { |
| 134 | + // output.manualChunks = viteManualChunks |
| 135 | + // } |
| 136 | + // } |
| 137 | + // // } |
| 138 | + // } else { |
| 139 | + // return { |
| 140 | + // build: { |
| 141 | + // rollupOptions: { |
| 142 | + // output: { |
| 143 | + // manualChunks: createSplitVendorChunk({}, config), |
| 144 | + // }, |
| 145 | + // }, |
| 146 | + // }, |
| 147 | + // } |
| 148 | + // } |
| 149 | + // }, |
| 150 | + // buildStart() { |
| 151 | + // caches.forEach((cache) => cache.reset()) |
| 152 | + // }, |
153 | 153 | }
|
154 | 154 | }
|
0 commit comments