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

Builds with Warnings Still Complete #10498

Merged
merged 2 commits into from Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/next/build/index.ts
Expand Up @@ -388,17 +388,20 @@ export default async function build(dir: string, conf = null): Promise<void> {
)
}
throw new Error('> Build failed because of webpack errors')
} else if (result.warnings.length > 0) {
console.warn(chalk.yellow('Compiled with warnings.\n'))
console.warn(result.warnings.join('\n\n'))
console.warn()
} else {
console.log(chalk.green('Compiled successfully.\n'))
telemetry.record(
eventBuildCompleted(pagePaths, {
durationInSeconds: webpackBuildEnd[0],
})
)

if (result.warnings.length > 0) {
console.warn(chalk.yellow('Compiled with warnings.\n'))
console.warn(result.warnings.join('\n\n'))
console.warn()
} else {
console.log(chalk.green('Compiled successfully.\n'))
}
}
const postBuildSpinner = createSpinner({
prefixText: 'Automatically optimizing pages',
Expand Down
8 changes: 8 additions & 0 deletions test/integration/telemetry/pages/warning.skip
@@ -0,0 +1,8 @@
function a(v) {
return v
}
;['index.js'].forEach(f => {
require(a('./' + f))
})

export default () => 'Warn'
20 changes: 20 additions & 0 deletions test/integration/telemetry/test/index.test.js
Expand Up @@ -93,6 +93,26 @@ describe('Telemetry CLI', () => {
expect(stderr2).toMatch(/isSrcDir.*?true/)
})

it('logs completed `next build` with warnings', async () => {
await fs.rename(
path.join(appDir, 'pages', 'warning.skip'),
path.join(appDir, 'pages', 'warning.js')
)
const { stderr } = await runNextCommand(['build', appDir], {
stderr: true,
env: {
NEXT_TELEMETRY_DEBUG: 1,
},
})
await fs.rename(
path.join(appDir, 'pages', 'warning.js'),
path.join(appDir, 'pages', 'warning.skip')
)

expect(stderr).toMatch(/Compiled with warnings/)
expect(stderr).toMatch(/NEXT_BUILD_COMPLETED/)
})

it('detects tests correctly for `next build`', async () => {
await fs.rename(
path.join(appDir, 'pages', 'hello.test.skip'),
Expand Down