@@ -29,17 +29,17 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
29
29
30
30
function isLarge ( code : string | Uint8Array ) : boolean {
31
31
// bail out on particularly large chunks
32
- return code . length / 1024 > chunkLimit
32
+ return code . length / 1000 > chunkLimit
33
33
}
34
34
35
35
async function getCompressedSize ( code : string | Uint8Array ) : Promise < string > {
36
36
if ( config . build . ssr || ! config . build . reportCompressedSize ) {
37
37
return ''
38
38
}
39
- return ` / gzip: ${ (
39
+ return ` / gzip: ${ displaySize (
40
40
( await compress ( typeof code === 'string' ? code : Buffer . from ( code ) ) )
41
- . length / 1024
42
- ) . toFixed ( 2 ) } KiB `
41
+ . length / 1000
42
+ ) } `
43
43
}
44
44
45
45
function printFileInfo (
@@ -54,12 +54,12 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
54
54
normalizePath (
55
55
path . relative ( config . root , path . resolve ( config . root , outDir ) )
56
56
) + '/'
57
- const kibs = content . length / 1024
58
- const sizeColor = kibs > chunkLimit ? colors . yellow : colors . dim
57
+ const kB = content . length / 1000
58
+ const sizeColor = kB > chunkLimit ? colors . yellow : colors . dim
59
59
config . logger . info (
60
60
`${ colors . gray ( colors . white ( colors . dim ( outDir ) ) ) } ${ writeColors [ type ] (
61
61
filePath . padEnd ( maxLength + 2 )
62
- ) } ${ sizeColor ( `${ kibs . toFixed ( 2 ) } KiB ${ compressedSize } ` ) } `
62
+ ) } ${ sizeColor ( `${ displaySize ( kB ) } ${ compressedSize } ` ) } `
63
63
)
64
64
}
65
65
@@ -201,7 +201,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
201
201
} else {
202
202
hasLargeChunks = Object . keys ( output ) . some ( ( file ) => {
203
203
const chunk = output [ file ]
204
- return chunk . type === 'chunk' && chunk . code . length / 1024 > chunkLimit
204
+ return chunk . type === 'chunk' && chunk . code . length / 1000 > chunkLimit
205
205
} )
206
206
}
207
207
@@ -213,7 +213,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
213
213
) {
214
214
config . logger . warn (
215
215
colors . yellow (
216
- `\n(!) Some chunks are larger than ${ chunkLimit } KiB after minification. Consider:\n` +
216
+ `\n(!) Some chunks are larger than ${ chunkLimit } kBs after minification. Consider:\n` +
217
217
`- Using dynamic import() to code-split the application\n` +
218
218
`- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks\n` +
219
219
`- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.`
@@ -244,3 +244,10 @@ function throttle(fn: Function) {
244
244
} , 100 )
245
245
}
246
246
}
247
+
248
+ function displaySize ( kB : number ) {
249
+ return `${ kB . toLocaleString ( 'en' , {
250
+ maximumFractionDigits : 2 ,
251
+ minimumFractionDigits : 2
252
+ } ) } kB`
253
+ }
0 commit comments