Skip to content

Commit

Permalink
Merge branch 'canary' into bugfix/avoid-absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 11, 2021
2 parents ad41ad1 + 77b6532 commit 9deeb61
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
18 changes: 17 additions & 1 deletion packages/next/build/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ export function formatAmpMessages(amp: AmpPageStatus) {
}

const buildStore = createStore<BuildStatusStore>()
let buildWasDone = false
let clientWasLoading = true
let serverWasLoading = true

buildStore.subscribe((state) => {
const { amp, client, server, trigger } = state
Expand All @@ -115,15 +118,28 @@ buildStore.subscribe((state) => {
} as OutputState,
true
)
clientWasLoading = (!buildWasDone && clientWasLoading) || client.loading
serverWasLoading = (!buildWasDone && serverWasLoading) || server.loading
buildWasDone = false
return
}

buildWasDone = true

let partialState: Partial<OutputState> = {
bootstrap: false,
appUrl: appUrl!,
loading: false,
typeChecking: false,
modules: client.modules + server.modules,
partial:
clientWasLoading && !serverWasLoading
? 'client'
: serverWasLoading && !clientWasLoading
? 'server'
: undefined,
modules:
(clientWasLoading ? client.modules : 0) +
(serverWasLoading ? server.modules : 0),
}
if (client.errors) {
// Show only client errors
Expand Down
14 changes: 11 additions & 3 deletions packages/next/build/output/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type OutputState =
| {
loading: false
typeChecking: boolean
partial: 'client' | 'server' | undefined
modules: number
errors: string[] | null
warnings: string[] | null
Expand Down Expand Up @@ -95,14 +96,19 @@ store.subscribe((state) => {
startTime = 0

timeMessage =
time > 2000 ? ` in ${Math.round(time / 100) / 10} s` : ` in ${time} ms`
time > 2000 ? ` in ${Math.round(time / 100) / 10}s` : ` in ${time} ms`
}

let modulesMessage = ''
if (state.modules) {
modulesMessage = ` (${state.modules} modules)`
}

let partialMessage = ''
if (state.partial) {
partialMessage = ` ${state.partial}`
}

if (state.warnings) {
Log.warn(state.warnings.join('\n\n'))
// Ensure traces are flushed after each compile in development mode
Expand All @@ -112,12 +118,14 @@ store.subscribe((state) => {

if (state.typeChecking) {
Log.info(
`bundled successfully${timeMessage}${modulesMessage}, waiting for typecheck results...`
`bundled${partialMessage} successfully${timeMessage}${modulesMessage}, waiting for typecheck results...`
)
return
}

Log.event(`compiled successfully${timeMessage}${modulesMessage}`)
Log.event(
`compiled${partialMessage} successfully${timeMessage}${modulesMessage}`
)
// Ensure traces are flushed after each compile in development mode
flushAllTraces()
})

0 comments on commit 9deeb61

Please sign in to comment.