Unverified Commit 8f5ed83b authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Build: Highlight TypeScript and ESLint being run clearer (#84606)

## What?

Follow-up to #84602.

- Renamed `Linting and checking validity of types` to `Running ESLint
and TypeScript concurrently`
- When `Running ESLint and TypeScript concurrently` finishes it logs the
individual times for `TypeScript` and `ESLint` separately

Previous PR only showed the time for TypeScript, hiding the time it took
to run ESlint.

The reason for renaming it to `Running ESLint and TypeScript` is that it
does not hide what is happening under the hood. Someone might assume
Next.js is doing extra work here, but it is calling the underlying tools
in the application to check linting and types. We've seen cases where
running TypeScript here is 1 minute or more, that would previously be
hidden or hard to investigate for the developer as they didn't know what
"linting and type checking" entails in this context.

```
   Creating an optimized production build ...
 ✓ Compiled successfully in 764ms
 ✓ Finished TypeScript in 968ms    
 ✓ Finished ESLint in 824ms    
 ✓ Collecting page data in 203ms    
 ✓ Generating static pages (4/4) in 318ms
 ✓ Collecting build traces in 3.3s    
 ✓ Finalizing page optimization in 3.3s    
```

---------
Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
parent f69066fb
...@@ -110,11 +110,11 @@ export async function startTypeChecking({ ...@@ -110,11 +110,11 @@ export async function startTypeChecking({
if (!ignoreTypeScriptErrors && shouldLint) { if (!ignoreTypeScriptErrors && shouldLint) {
typeCheckingAndLintingSpinnerPrefixText = typeCheckingAndLintingSpinnerPrefixText =
'Linting and checking validity of types' 'Running ESLint and TypeScript concurrently'
} else if (!ignoreTypeScriptErrors) { } else if (!ignoreTypeScriptErrors) {
typeCheckingAndLintingSpinnerPrefixText = 'Checking validity of types' typeCheckingAndLintingSpinnerPrefixText = 'Running TypeScript'
} else if (shouldLint) { } else if (shouldLint) {
typeCheckingAndLintingSpinnerPrefixText = 'Linting' typeCheckingAndLintingSpinnerPrefixText = 'Running ESLint'
} }
// we will not create a spinner if both ignoreTypeScriptErrors and ignoreESLint are // we will not create a spinner if both ignoreTypeScriptErrors and ignoreESLint are
...@@ -125,10 +125,10 @@ export async function startTypeChecking({ ...@@ -125,10 +125,10 @@ export async function startTypeChecking({
) )
} }
const typeCheckStart = process.hrtime() const typeCheckAndLintStart = process.hrtime()
try { try {
const [[verifyResult, typeCheckEnd]] = await Promise.all([ const [[verifyResult, typeCheckEnd], lintCheckEnd] = await Promise.all([
nextBuildSpan.traceChild('run-typescript').traceAsyncFn(() => nextBuildSpan.traceChild('run-typescript').traceAsyncFn(() =>
verifyTypeScriptSetup( verifyTypeScriptSetup(
dir, dir,
...@@ -142,7 +142,7 @@ export async function startTypeChecking({ ...@@ -142,7 +142,7 @@ export async function startTypeChecking({
!!appDir, !!appDir,
!!pagesDir !!pagesDir
).then((resolved) => { ).then((resolved) => {
const checkEnd = process.hrtime(typeCheckStart) const checkEnd = process.hrtime(typeCheckAndLintStart)
return [resolved, checkEnd] as const return [resolved, checkEnd] as const
}) })
), ),
...@@ -155,14 +155,22 @@ export async function startTypeChecking({ ...@@ -155,14 +155,22 @@ export async function startTypeChecking({
config.experimental.workerThreads, config.experimental.workerThreads,
telemetry telemetry
) )
const checkEnd = process.hrtime(typeCheckAndLintStart)
return checkEnd
}), }),
]) ])
if (typeCheckingAndLintingSpinner) { if (typeCheckingAndLintingSpinner) {
typeCheckingAndLintingSpinner.setText( typeCheckingAndLintingSpinner.stop()
`${typeCheckingAndLintingSpinnerPrefixText} in ${hrtimeDurationToString(typeCheckEnd)}`
) createSpinner(
typeCheckingAndLintingSpinner.stopAndPersist() `Finished TypeScript${ignoreTypeScriptErrors ? ' config validation' : ''} in ${hrtimeDurationToString(typeCheckEnd)}`
)?.stopAndPersist()
if (lintCheckEnd) {
createSpinner(
`Finished ESLint in ${hrtimeDurationToString(lintCheckEnd)}`
)?.stopAndPersist()
}
} }
if (!ignoreTypeScriptErrors && verifyResult) { if (!ignoreTypeScriptErrors && verifyResult) {
......
...@@ -24,7 +24,7 @@ describe('production - app dir - build output', () => { ...@@ -24,7 +24,7 @@ describe('production - app dir - build output', () => {
'Creating an optimized production build' 'Creating an optimized production build'
) )
const indexOfLinting = output.indexOf( const indexOfLinting = output.indexOf(
'Linting and checking validity of types' 'Running ESLint and TypeScript concurrently'
) )
expect(indexOfVersion).toBeLessThan(indexOfLinting) expect(indexOfVersion).toBeLessThan(indexOfLinting)
expect(indexOfStartCompiling).toBeLessThan(indexOfLinting) expect(indexOfStartCompiling).toBeLessThan(indexOfLinting)
......
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