{"library":"next-build-parser","title":"Next.js Build Output Parser","description":"next-build-parser is a utility designed to parse the console output of the Next.js `next build` command into a structured, machine-readable JSON format. This allows developers and automated systems to programmatically analyze build artifacts, route sizes, and performance metrics without relying on manual parsing of text output. The package is currently at version 1.3.0, indicating a stable and actively maintained state. It provides both a command-line interface (CLI) for direct use in scripts and a programmatic API for integration into JavaScript/TypeScript applications. Its key differentiator is the ability to break down route-specific `size` versus `firstLoad` metrics, alongside shared chunk information, making it valuable for performance monitoring and build optimization workflows. While no specific release cadence is announced, it appears to be actively developed in response to Next.js updates.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install next-build-parser"],"cli":{"name":"next-build-parser","version":null}},"imports":["import { parse } from 'next-build-parser';","import { parseFile } from 'next-build-parser';","import type { Output } from 'next-build-parser';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parseFile } from 'next-build-parser';\nimport { writeFileSync, existsSync, mkdirSync } from 'node:fs';\nimport { execSync } from 'node:child_process';\nimport { join } from 'node:path';\n\nconst tempDir = join(process.cwd(), 'temp-next-build-output');\nif (!existsSync(tempDir)) {\n  mkdirSync(tempDir);\n}\nconst outputFile = join(tempDir, 'next-build.txt');\n\nconsole.log('Running `next build` and redirecting output...');\ntry {\n  execSync('npm run build > ' + outputFile, { stdio: 'pipe' });\n  console.log(`Build output saved to ${outputFile}`);\n} catch (error) {\n  console.error('Failed to run next build. Ensure you have a Next.js project and `npm run build` works.');\n  console.error(error.message);\n  process.exit(1);\n}\n\nasync function main() {\n  console.log('Parsing next build output...');\n  try {\n    const output = await parseFile(outputFile, {\n      unit: 'KB',\n    });\n    console.log('Parsed output:');\n    console.log(JSON.stringify(output, null, 2));\n    writeFileSync(join(tempDir, 'parsed-output.json'), JSON.stringify(output, null, 2));\n    console.log(`\nFull parsed JSON saved to ${join(tempDir, 'parsed-output.json')}`);\n  } catch (error) {\n    console.error('Error parsing build file:', error.message);\n  }\n}\n\nmain();\n","lang":"typescript","description":"This quickstart demonstrates how to run `next build`, capture its output to a file, and then programmatically parse that file into a structured JSON object using `parseFile` for analysis.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}