Skip to content

fix(vite): count transforms without results in module timings - #599

Draft
SaKaNa-Y wants to merge 1 commit into
vitejs:mainfrom
SaKaNa-Y:fix/vite-no-result-transform-timing
Draft

SaKaNa-Y wants to merge 1 commit into
vitejs:mainfrom
SaKaNa-Y:fix/vite-no-result-transform-timing

Conversation

@SaKaNa-Y

@SaKaNa-Y SaKaNa-Y commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Important

Please take a moment to read this. Thank you!

I should include a brief explanation of the problem in my own words in every PR. If that explanation is missing, please @mention me and do not merge this PR until I have added it. You may also leave this PR unaddressed (because this means I have not fulfilled my responsibilities as the author).

If my explanation is unclear or difficult to follow, please ask me to clarify or provide reproduction steps or supporting evidence.

I welcome suggestions and counterarguments, especially questions about anything I may have overlooked. (Your feedback helps me learn and improve. 🙏)

I hold myself to this standard for every PR, regardless of its size.

Summary

A Vite transform hook can spend time on a module and return undefined or null. The inspector records that time, but the module summary excludes transforms that return no code. The hook's duration appears in plugin details but is missing from the module's transform and total times. This makes the module appear faster than it is.

This change includes every recorded transform when it adds up module timings. The tests cover undefined, null, unchanged code, changed code, and empty code. They also check the stored results and module sizes.

 module timing aggregation
-  include transforms with a code result
+  include all recorded transforms

Evidence

Results from the implementation checks:

  • Before: The undefined and null cases reported 5ms instead of 1205ms and omitted the slow plugin. The three cases that returned code passed.
    After: All five cases passed.
  • Tested the built package with actual Vite dev transform requests and a 1.2-second hook. All five return cases reported 1199–1201ms for that plugin, and each module total included that time.
  • pnpm lint, pnpm test --run (356 passed, 2 skipped), pnpm typecheck, and pnpm build passed.

Merge Danger

Door: Two-way.

Blast Radius: Module-metrics.

Module timing totals and plugin entries now include hooks that ran without returning code.

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@599

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@599

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@599

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@599

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@599

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@599

commit: 406dc44

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.

1 participant