File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
packages/vite/src/node/plugins Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -25,10 +25,18 @@ const writeColors = {
25
25
export function buildReporterPlugin ( config : ResolvedConfig ) : Plugin {
26
26
const chunkLimit = config . build . chunkSizeWarningLimit
27
27
28
+ function isLarge ( code : string | Uint8Array ) : boolean {
29
+ // bail out on particularly large chunks
30
+ return code . length / 1024 > chunkLimit
31
+ }
32
+
28
33
async function getCompressedSize ( code : string | Uint8Array ) : Promise < string > {
29
34
if ( config . build . ssr || ! config . build . brotliSize ) {
30
35
return ''
31
36
}
37
+ if ( isLarge ( code ) ) {
38
+ return ' / brotli: skipped (large chunk)'
39
+ }
32
40
return ` / brotli: ${ (
33
41
( await size ( typeof code === 'string' ? code : Buffer . from ( code ) ) ) / 1024
34
42
) . toFixed ( 2 ) } kb`
@@ -147,17 +155,13 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
147
155
Object . keys ( output ) . map ( async ( file ) => {
148
156
const chunk = output [ file ]
149
157
if ( chunk . type === 'chunk' ) {
150
- // bail out on particularly large chunks
151
- const isLarge = chunk . code . length / 1024 > chunkLimit
152
158
const log = async ( ) => {
153
159
printFileInfo (
154
160
chunk . fileName ,
155
161
chunk . code ,
156
162
WriteType . JS ,
157
163
longest ,
158
- isLarge
159
- ? ' / brotli: skipped (large chunk)'
160
- : await getCompressedSize ( chunk . code )
164
+ await getCompressedSize ( chunk . code )
161
165
)
162
166
if ( chunk . map ) {
163
167
printFileInfo (
@@ -168,7 +172,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
168
172
)
169
173
}
170
174
}
171
- if ( isLarge ) {
175
+ if ( isLarge ( chunk . code ) ) {
172
176
hasLargeChunks = true
173
177
deferredLogs . push ( log )
174
178
} else {
You can’t perform that action at this time.
0 commit comments