Unverified Commit 3dec5000 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add debug flag for extra build output (#16399)

This adds a `-d` or `--debug` flag which enables outputting additional build output information like the rewrites, redirects, and headers

Fixes #15281
parent c210154a
...@@ -102,7 +102,8 @@ export type PrerenderManifest = { ...@@ -102,7 +102,8 @@ export type PrerenderManifest = {
export default async function build( export default async function build(
dir: string, dir: string,
conf = null, conf = null,
reactProductionProfiling = false reactProductionProfiling = false,
debugOutput = false
): Promise<void> { ): Promise<void> {
if (!(await isWriteable(dir))) { if (!(await isWriteable(dir))) {
throw new Error( throw new Error(
...@@ -1024,7 +1025,10 @@ export default async function build( ...@@ -1024,7 +1025,10 @@ export default async function build(
isModern: config.experimental.modern, isModern: config.experimental.modern,
} }
) )
printCustomRoutes({ redirects, rewrites, headers })
if (debugOutput) {
printCustomRoutes({ redirects, rewrites, headers })
}
if (tracer) { if (tracer) {
const parsedResults = await tracer.profiler.stopProfiling() const parsedResults = await tracer.profiler.stopProfiling()
......
...@@ -12,8 +12,10 @@ const nextBuild: cliCommand = (argv) => { ...@@ -12,8 +12,10 @@ const nextBuild: cliCommand = (argv) => {
// Types // Types
'--help': Boolean, '--help': Boolean,
'--profile': Boolean, '--profile': Boolean,
'--debug': Boolean,
// Aliases // Aliases
'-h': '--help', '-h': '--help',
'-d': '--debug',
} }
let args: arg.Result<arg.Spec> let args: arg.Result<arg.Spec>
...@@ -53,7 +55,7 @@ const nextBuild: cliCommand = (argv) => { ...@@ -53,7 +55,7 @@ const nextBuild: cliCommand = (argv) => {
printAndExit(`> No such directory exists as the project root: ${dir}`) printAndExit(`> No such directory exists as the project root: ${dir}`)
} }
build(dir, null, args['--profile']) build(dir, null, args['--profile'], args['--debug'])
.then(() => process.exit(0)) .then(() => process.exit(0))
.catch((err) => { .catch((err) => {
console.error('') console.error('')
......
...@@ -988,7 +988,7 @@ const runTests = (isDev = false) => { ...@@ -988,7 +988,7 @@ const runTests = (isDev = false) => {
}) })
}) })
it('should have redirects/rewrites in build output', async () => { it('should have redirects/rewrites in build output with debug flag', async () => {
const manifest = await fs.readJSON( const manifest = await fs.readJSON(
join(appDir, '.next/routes-manifest.json') join(appDir, '.next/routes-manifest.json')
) )
...@@ -1073,7 +1073,7 @@ describe('Custom routes', () => { ...@@ -1073,7 +1073,7 @@ describe('Custom routes', () => {
describe('server mode', () => { describe('server mode', () => {
beforeAll(async () => { beforeAll(async () => {
const { stdout: buildStdout } = await nextBuild(appDir, [], { const { stdout: buildStdout } = await nextBuild(appDir, ['-d'], {
stdout: true, stdout: true,
}) })
stdout = buildStdout stdout = buildStdout
...@@ -1093,7 +1093,7 @@ describe('Custom routes', () => { ...@@ -1093,7 +1093,7 @@ describe('Custom routes', () => {
nextConfigContent.replace(/\/\/ target/, 'target'), nextConfigContent.replace(/\/\/ target/, 'target'),
'utf8' 'utf8'
) )
const { stdout: buildStdout } = await nextBuild(appDir, [], { const { stdout: buildStdout } = await nextBuild(appDir, ['-d'], {
stdout: true, stdout: true,
}) })
stdout = buildStdout stdout = buildStdout
......
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