Skip to content

Commit 0eb71b6

Browse files
wyattjohhuozhi
andauthored
Misc Typescript and export updates (#55841)
This refactors a bit of the typescript types around the export and build pipelines. This does not introduce any new functionality. Co-authored-by: Jiachi Liu <[email protected]>
1 parent aa3377e commit 0eb71b6

File tree

18 files changed

+1274
-985
lines changed

18 files changed

+1274
-985
lines changed

packages/next/src/build/index.ts

Lines changed: 94 additions & 79 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Formats the manifest depending on the environment variable
3+
* `NODE_ENV`. If it's set to `development`, it will return a pretty printed
4+
* JSON string, otherwise it will return a minified JSON string.
5+
*/
6+
export function formatManifest<T extends object>(manifest: T): string {
7+
if (process.env.NODE_ENV === 'development') {
8+
return JSON.stringify(manifest, null, 2)
9+
}
10+
11+
return JSON.stringify(manifest)
12+
}

packages/next/src/cli/next-export.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env node
2+
import type { ExportAppOptions } from '../export/types'
3+
24
import { resolve, join } from 'path'
35
import { existsSync } from 'fs'
46
import { cyan } from '../lib/picocolors'
5-
import exportApp, { ExportError, ExportOptions } from '../export'
7+
import exportApp, { ExportError } from '../export'
68
import * as Log from '../build/output/log'
79
import { printAndExit } from '../server/lib/utils'
810
import { CliCommand } from '../lib/commands'
@@ -43,7 +45,7 @@ const nextExport: CliCommand = (args) => {
4345
printAndExit(`> No such directory exists as the project root: ${dir}`)
4446
}
4547

46-
const options: ExportOptions = {
48+
const options: ExportAppOptions = {
4749
silent: args['--silent'] || false,
4850
threads: args['--threads'],
4951
outdir: args['--outdir'] ? resolve(args['--outdir']) : join(dir, 'out'),

0 commit comments

Comments
 (0)