Skip to content

Commit 79fb13e

Browse files
authored
Builds with Warnings Still Complete (vercel#10498)
1 parent 189fc98 commit 79fb13e

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

packages/next/build/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,20 @@ export default async function build(dir: string, conf = null): Promise<void> {
388388
)
389389
}
390390
throw new Error('> Build failed because of webpack errors')
391-
} else if (result.warnings.length > 0) {
392-
console.warn(chalk.yellow('Compiled with warnings.\n'))
393-
console.warn(result.warnings.join('\n\n'))
394-
console.warn()
395391
} else {
396-
console.log(chalk.green('Compiled successfully.\n'))
397392
telemetry.record(
398393
eventBuildCompleted(pagePaths, {
399394
durationInSeconds: webpackBuildEnd[0],
400395
})
401396
)
397+
398+
if (result.warnings.length > 0) {
399+
console.warn(chalk.yellow('Compiled with warnings.\n'))
400+
console.warn(result.warnings.join('\n\n'))
401+
console.warn()
402+
} else {
403+
console.log(chalk.green('Compiled successfully.\n'))
404+
}
402405
}
403406
const postBuildSpinner = createSpinner({
404407
prefixText: 'Automatically optimizing pages',
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function a(v) {
2+
return v
3+
}
4+
;['index.js'].forEach(f => {
5+
require(a('./' + f))
6+
})
7+
8+
export default () => 'Warn'

test/integration/telemetry/test/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ describe('Telemetry CLI', () => {
9393
expect(stderr2).toMatch(/isSrcDir.*?true/)
9494
})
9595

96+
it('logs completed `next build` with warnings', async () => {
97+
await fs.rename(
98+
path.join(appDir, 'pages', 'warning.skip'),
99+
path.join(appDir, 'pages', 'warning.js')
100+
)
101+
const { stderr } = await runNextCommand(['build', appDir], {
102+
stderr: true,
103+
env: {
104+
NEXT_TELEMETRY_DEBUG: 1,
105+
},
106+
})
107+
await fs.rename(
108+
path.join(appDir, 'pages', 'warning.js'),
109+
path.join(appDir, 'pages', 'warning.skip')
110+
)
111+
112+
expect(stderr).toMatch(/Compiled with warnings/)
113+
expect(stderr).toMatch(/NEXT_BUILD_COMPLETED/)
114+
})
115+
96116
it('detects tests correctly for `next build`', async () => {
97117
await fs.rename(
98118
path.join(appDir, 'pages', 'hello.test.skip'),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy