Skip to content

Feature Request: Bun.build should report list of inputs #25573

@cinderblock

Description

@cinderblock

What is the problem this feature would solve?

When building with the Bun.build(...) API, it's difficult to detect what source files were used in the final bundle.

This is very handy to confirm how module resolution is actually shaking out. For instance, that the wrong node_modules folder is being referenced, or some path rewrites are (or are not) working as expected.

This could also be used to implement a proper "watch mode" that only watches for changes of used sources. #5866

What is the feature you are proposing to solve the problem?

Expand the BuildOutput interface slightly:

interface BuildOutput {
  outputs: BuildArtifact[];
  inputs: BuildInput[]; // New field
  success: boolean;
  logs: Array<BuildMessage | ResolveMessage>;
}

// RFC on how `BuildInput` should be typed...

type BuildInput = string; // Simple filename?
interface BuildInput { // Or some advanced type?
  path: string;
  content: string; // Is this excessive?
  contentHash: string; // Enough?
  entry: string; // Which entry point(s) depend on this input? Or should this be an index into the entries list?
  accessTime: Date; // Maybe large builds take time?
  // ... What else?
}

It might be nice to split the inputs list based on which entrypoint tried to import it.

What alternatives have you considered?

The information I want is available in the source maps, but it's a little convoluted to get to them - especially if you want to also control how your source maps are generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions