Unverified Commit 3f6bd47d authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update build output with renamed column (#11401)

* Update build output with renamed column

* Update build output test

* Update naming of column
Co-authored-by: 's avatarTim Neutkens <timneutkens@me.com>
parent 1992e2a9
......@@ -62,7 +62,7 @@ import { isWriteable } from './is-writeable'
import createSpinner from './spinner'
import {
collectPages,
getPageSizeInKb,
getJsPageSizeInKb,
hasCustomGetInitialProps,
isPageStatic,
PageInfo,
......@@ -482,7 +482,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
await Promise.all(
pageKeys.map(async page => {
const actualPage = normalizePagePath(page)
const [selfSize, allSize] = await getPageSizeInKb(
const [selfSize, allSize] = await getJsPageSizeInKb(
actualPage,
distDir,
buildId,
......
......@@ -88,7 +88,7 @@ export async function printTreeView(
.replace(/[.-]([0-9a-z]{6})[0-9a-z]{14}(?=\.)/, '.$1')
const messages: [string, string, string][] = [
['Page', 'Size', 'First Load'].map(entry => chalk.underline(entry)) as [
['Page', 'Size', 'First Load JS'].map(entry => chalk.underline(entry)) as [
string,
string,
string
......@@ -203,7 +203,11 @@ export async function printTreeView(
const sharedFilesSize = sizeData.sizeCommonFiles
const sharedFiles = sizeData.sizeCommonFile
messages.push(['+ shared by all', getPrettySize(sharedFilesSize), ''])
messages.push([
'+ First Load JS shared by all',
getPrettySize(sharedFilesSize),
'',
])
const sharedFileKeys = Object.keys(sharedFiles)
const sharedCssFiles: string[] = []
;[
......@@ -463,7 +467,10 @@ async function computeFromManifest(
(obj, n) => Object.assign(obj, { [n[0]]: n[1] }),
{}
),
sizeCommonFiles: stats.reduce((size, [, stat]) => size + stat, 0),
sizeCommonFiles: stats.reduce((size, [f, stat]) => {
if (f.endsWith('.css')) return size
return size + stat
}, 0),
}
cachedBuildManifest = manifest
......@@ -488,7 +495,7 @@ function sum(a: number[]): number {
return a.reduce((size, stat) => size + stat, 0)
}
export async function getPageSizeInKb(
export async function getJsPageSizeInKb(
page: string,
distPath: string,
buildId: string,
......@@ -503,8 +510,7 @@ export async function getPageSizeInKb(
)
const fnFilterModern = (entry: string) =>
(entry.endsWith('.js') && entry.endsWith('.module.js') === isModern) ||
entry.endsWith('.css')
entry.endsWith('.js') && entry.endsWith('.module.js') === isModern
const pageFiles = (buildManifest.pages[page] || []).filter(fnFilterModern)
const appFiles = (buildManifest.pages['/_app'] || []).filter(fnFilterModern)
......
......@@ -23,7 +23,7 @@ describe('Build Output', () => {
})
expect(stdout).toMatch(/\/ [ ]* \d{1,} B/)
expect(stdout).toMatch(/\+ shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/ runtime\/main\.[0-9a-z]{6}\.js [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/framework\.[0-9a-z]{6}\.js [ 0-9. ]* kB/)
......@@ -50,7 +50,7 @@ describe('Build Output', () => {
expect(stdout).toMatch(/\/ [ ]* \d{1,} B/)
expect(stdout).toMatch(/\/_app [ ]* \d{1,} B/)
expect(stdout).toMatch(/\+ shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/ runtime\/main\.[0-9a-z]{6}\.js [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/framework\.[0-9a-z]{6}\.js [ 0-9. ]* kB/)
......@@ -78,7 +78,7 @@ describe('Build Output', () => {
expect(stdout).toMatch(/\/ [ 0-9.]* B [ 0-9.]* kB/)
expect(stdout).toMatch(/\/amp .* AMP/)
expect(stdout).toMatch(/\/hybrid [ 0-9.]* B/)
expect(stdout).toMatch(/\+ shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/ runtime\/main\.[0-9a-z]{6}\.js [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/framework\.[0-9a-z]{6}\.js [ 0-9. ]* kB/)
......@@ -104,7 +104,7 @@ describe('Build Output', () => {
expect(stdout).toMatch(/\/ [ ]* \d{1,} B/)
expect(stdout).toMatch(/λ \/_error [ ]* \d{1,} B/)
expect(stdout).toMatch(/\+ shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/\+ First Load JS shared by all [ 0-9.]* kB/)
expect(stdout).toMatch(/ runtime\/main\.[0-9a-z]{6}\.js [ 0-9.]* kB/)
expect(stdout).toMatch(/ chunks\/framework\.[0-9a-z]{6}\.js [ 0-9. ]* kB/)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment