Unverified Commit df613d39 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

fix some labels for middleware stuff (#30241)

* show `(client only)` for _middleware files

* show f symbol for _middleware files in summary tree

add explanation
show only used symbols
parent 3bb098f8
...@@ -150,6 +150,8 @@ export async function printTreeView( ...@@ -150,6 +150,8 @@ export async function printTreeView(
pageInfos pageInfos
) )
const usedSymbols = new Set()
const pageList = list const pageList = list
.slice() .slice()
.filter( .filter(
...@@ -163,7 +165,7 @@ export async function printTreeView( ...@@ -163,7 +165,7 @@ export async function printTreeView(
.sort((a, b) => a.localeCompare(b)) .sort((a, b) => a.localeCompare(b))
pageList.forEach((item, i, arr) => { pageList.forEach((item, i, arr) => {
const symbol = const border =
i === 0 i === 0
? arr.length === 1 ? arr.length === 1
? '─' ? '─'
...@@ -179,16 +181,22 @@ export async function printTreeView( ...@@ -179,16 +181,22 @@ export async function printTreeView(
(pageInfo?.pageDuration || 0) + (pageInfo?.pageDuration || 0) +
(pageInfo?.ssgPageDurations?.reduce((a, b) => a + (b || 0), 0) || 0) (pageInfo?.ssgPageDurations?.reduce((a, b) => a + (b || 0), 0) || 0)
const symbol =
item === '/_app'
? ' '
: item.endsWith('/_middleware')
? 'ƒ'
: pageInfo?.static
? '○'
: pageInfo?.isSsg
? '●'
: 'λ'
usedSymbols.add(symbol)
if (pageInfo?.initialRevalidateSeconds) usedSymbols.add('ISR')
messages.push([ messages.push([
`${symbol} ${ `${border} ${symbol} ${
item === '/_app'
? ' '
: pageInfo?.static
? '○'
: pageInfo?.isSsg
? '●'
: 'λ'
} ${
pageInfo?.initialRevalidateSeconds pageInfo?.initialRevalidateSeconds
? `${item} (ISR: ${pageInfo?.initialRevalidateSeconds} Seconds)` ? `${item} (ISR: ${pageInfo?.initialRevalidateSeconds} Seconds)`
: item : item
...@@ -341,33 +349,38 @@ export async function printTreeView( ...@@ -341,33 +349,38 @@ export async function printTreeView(
console.log( console.log(
textTable( textTable(
[ [
[ usedSymbols.has('ƒ') && [
'ƒ',
'(Middleware)',
`intercepts requests (uses ${chalk.cyan('_middleware')})`,
],
usedSymbols.has('λ') && [
'λ', 'λ',
serverless ? '(Lambda)' : '(Server)', serverless ? '(Lambda)' : '(Server)',
`server-side renders at runtime (uses ${chalk.cyan( `server-side renders at runtime (uses ${chalk.cyan(
'getInitialProps' 'getInitialProps'
)} or ${chalk.cyan('getServerSideProps')})`, )} or ${chalk.cyan('getServerSideProps')})`,
], ],
[ usedSymbols.has('○') && [
'○', '○',
'(Static)', '(Static)',
'automatically rendered as static HTML (uses no initial props)', 'automatically rendered as static HTML (uses no initial props)',
], ],
[ usedSymbols.has('●') && [
'●', '●',
'(SSG)', '(SSG)',
`automatically generated as static HTML + JSON (uses ${chalk.cyan( `automatically generated as static HTML + JSON (uses ${chalk.cyan(
'getStaticProps' 'getStaticProps'
)})`, )})`,
], ],
[ usedSymbols.has('ISR') && [
'', '',
'(ISR)', '(ISR)',
`incremental static regeneration (uses revalidate in ${chalk.cyan( `incremental static regeneration (uses revalidate in ${chalk.cyan(
'getStaticProps' 'getStaticProps'
)})`, )})`,
], ],
] as [string, string, string][], ].filter((x) => x) as [string, string, string][],
{ {
align: ['l', 'l', 'l'], align: ['l', 'l', 'l'],
stringLength: (str) => stripAnsi(str).length, stringLength: (str) => stripAnsi(str).length,
......
...@@ -239,9 +239,9 @@ export default function onDemandEntryHandler( ...@@ -239,9 +239,9 @@ export default function onDemandEntryHandler(
if (entriesChanged) { if (entriesChanged) {
reportTrigger( reportTrigger(
isApiRoute || isMiddleware isApiRoute
? `${normalizedPage} (server only)` ? `${normalizedPage} (server only)`
: clientOnly : clientOnly || isMiddleware
? `${normalizedPage} (client only)` ? `${normalizedPage} (client only)`
: normalizedPage : normalizedPage
) )
......
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