Pmetafile
Bun

property

CompileBuildConfig.metafile

metafile?: boolean

Generate a JSON file containing metadata about the build.

The metafile contains information about inputs, outputs, imports, and exports which can be used for bundle analysis, visualization, or integration with other tools.

When true, the metafile JSON string is included in the BuildOutput.metafile property.

const result = await Bun.build({
  entrypoints: ['./src/index.ts'],
  outdir: './dist',
  metafile: true,
});

// Write metafile to disk for analysis
if (result.metafile) {
  await Bun.write('./dist/meta.json', result.metafile);
}

// Parse and analyze the metafile
const meta = JSON.parse(result.metafile!);
console.log('Input files:', Object.keys(meta.inputs));
console.log('Output files:', Object.keys(meta.outputs));