Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some labels for middleware stuff #30241

Merged
merged 5 commits into from
Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions packages/next/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export async function printTreeView(
pageInfos
)

const usedSymbols = new Set()

const pageList = list
.slice()
.filter(
Expand All @@ -163,7 +165,7 @@ export async function printTreeView(
.sort((a, b) => a.localeCompare(b))

pageList.forEach((item, i, arr) => {
const symbol =
const border =
i === 0
? arr.length === 1
? '─'
Expand All @@ -179,16 +181,22 @@ export async function printTreeView(
(pageInfo?.pageDuration || 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([
`${symbol} ${
item === '/_app'
? ' '
: pageInfo?.static
? '○'
: pageInfo?.isSsg
? '●'
: 'λ'
} ${
`${border} ${symbol} ${
pageInfo?.initialRevalidateSeconds
? `${item} (ISR: ${pageInfo?.initialRevalidateSeconds} Seconds)`
: item
Expand Down Expand Up @@ -341,33 +349,38 @@ export async function printTreeView(
console.log(
textTable(
[
[
usedSymbols.has('ƒ') && [
'ƒ',
'(Middleware)',
`intercepts requests (uses ${chalk.cyan('_middleware')})`,
],
usedSymbols.has('λ') && [
'λ',
serverless ? '(Lambda)' : '(Server)',
`server-side renders at runtime (uses ${chalk.cyan(
'getInitialProps'
)} or ${chalk.cyan('getServerSideProps')})`,
],
[
usedSymbols.has('○') && [
'○',
'(Static)',
'automatically rendered as static HTML (uses no initial props)',
],
[
usedSymbols.has('●') && [
'●',
'(SSG)',
`automatically generated as static HTML + JSON (uses ${chalk.cyan(
'getStaticProps'
)})`,
],
[
usedSymbols.has('ISR') && [
'',
'(ISR)',
`incremental static regeneration (uses revalidate in ${chalk.cyan(
'getStaticProps'
)})`,
],
] as [string, string, string][],
].filter((x) => x) as [string, string, string][],
{
align: ['l', 'l', 'l'],
stringLength: (str) => stripAnsi(str).length,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/server/dev/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ export default function onDemandEntryHandler(

if (entriesChanged) {
reportTrigger(
isApiRoute || isMiddleware
isApiRoute
? `${normalizedPage} (server only)`
: clientOnly
: clientOnly || isMiddleware
? `${normalizedPage} (client only)`
: normalizedPage
)
Expand Down