Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Jan 7, 2026

Description

(Largely 🤖 Generated with Claude Code)

Addresses the data size concern from #9141 and #9262. The importDurations metadata scales by O(test files × source files) but reporting only shows top N imports.

Summary

  • Add experimental.printImportBreakdown: { enabled?: boolean, limit?: number } config

    • enabled (default: false): Enable import breakdown display in CLI
    • limit (default: 10): Number of imports to show in CLI output.
      • this also affect the heuristics to truncate importDurations
      • limit = 0: Opt-out from importDurations collection entirely
  • Trim importDurations at worker level in getImportDurations():

TBD?

  • This changes default importDurations collection available to be 50, which affects existing usage outside of base reporter. I think collecting all imports by default is largely unnecessary, so I think it's fine default.
  • VSCode extension's collectModuleDurationsDiagnostic() accumulates times across test files. Trimmed long-tail modules may show incomplete totals. To preserve the previous behavior, extension can overwrite limit to Infinity?

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@hi-ogawa hi-ogawa changed the title feat: add printImportBreakdown.limit and trim importDurations data feat: add printImportBreakdown.limit + fix: trim importDurations data Jan 7, 2026
@hi-ogawa hi-ogawa marked this pull request as ready for review January 7, 2026 07:20
@hi-ogawa hi-ogawa changed the title feat: add printImportBreakdown.limit + fix: trim importDurations data feat(experimental): add printImportBreakdown.limit (fix: trim importDurations data) Jan 8, 2026
for (const [filepath, { duration, selfTime, external, importer }] of entries) {
// Trim to top N by duration to reduce IPC payload
// Keep enough entries for UI "show more" and aggregation
const retention = Math.max(50, limit * 5)
Copy link
Member

@sheremet-va sheremet-va Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this makes sense, to be honest. If there is a limit, then there is a limit. Maybe remove "show more" in UI

}
resolved.experimental.printImportBreakdown ??= {} as any
resolved.experimental.printImportBreakdown.enabled ??= false
resolved.experimental.printImportBreakdown.limit ??= 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be 0 by default then

I think we can just say "enable this option to see import breakdown" in the current popup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that works too. It looks like I was just over-complicating things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reporters data is bloated compared to v3.1.x

2 participants