Skip to content

perf(nuxt): reuse the composable scan between manifest writes - #308

Merged
vite-hub[bot] merged 2 commits into
mainfrom
perf/nuxt-manifest-scan-once
Oct 31, 2026
Merged

vite-hub[bot] merged 2 commits into
mainfrom
perf/nuxt-manifest-scan-once

Conversation

@onmax

@onmax onmax commented Oct 31, 2026

Copy link
Copy Markdown
Owner

The Nuxt module writes doctor.manifest.json on nitro:init, builder:generateApp, prepare:types, Nitro's rollup:before and compiled, and close. Every write called unimport's scanDirExports over all import dirs again, so each one re-read and re-parsed every composable and util in every layer. A nuxt build scanned six times.

The module now keeps the scan for the current import dirs and drops it whenever imports:extend fires. Nuxt calls that hook right after each of its own rescans, including the ones its watcher triggers in dev, so Doctor rescans only when Nuxt does. A scan that fails is dropped too, so the next write retries. The manifest content doesn't change.

Numbers

Two generated fixtures, Nuxt 4.5.2, driven by loadNuxt + buildNuxt: an app with 6 local layers and 154 composable/util/shared files, and one with 22 layers and 966 files. "Reads" counts readFile calls on those files that came from writeManifest. Start-up stops at build:before and is measured before nuxt.close(). Times are the median of 5 alternating runs on a shared 16-core machine (1-minute load 1.0 to 1.7).

before after
6 layers, start-up reads 483 (3 scans) 322 (2 scans)
6 layers, start-up time 1066 ms 1036 ms
22 layers, start-up reads 2967 (3 scans) 1978 (2 scans)
22 layers, start-up time 1945 ms 1821 ms
6 layers, full build reads 966 (6 scans) 322 (2 scans)
22 layers, full build reads 5934 (6 scans) 1978 (2 scans)

The full build counts include the close write that Nuxt's build fires itself. Nuxt's own reads are the same before and after.

In every run, the manifests from both builds were identical once generatedAt was removed: 109,945 bytes with 6 layers and 518,504 bytes with 22, both at start-up and after close.

Test plan

  • New tests/rule-packs/nuxt/composable-scan-reuse.test.ts. The first case checks that two extra builder:generateApp writes read no composable files and that a composable added through builder:watch still reaches scannedComposableFiles. On main it fails with expected 5 to be 3, and it also fails if the imports:extend reset is removed. The second case fails one scan with EIO and checks that the next write rescans. It fails if the rejected scan stays cached.
  • composable-scan-inventory, extension-hooks, nuxt-manifest-evidence, nuxt-modern-rules-2/-3, keyed-composable-registration, export-name-matches-file, the auto-import tests and e2e-fixtures pass.
  • vp fmt --check and vp lint on the changed files.
  • pnpm test with only the root package installed: 207 of 208 files pass. docs/app/utils/rule-catalog.test.ts needs the docs install (can't find vue); CI covers it.

🤖 Generated with Claude Code

onmax added 2 commits November 1, 2026 00:23
Each manifest write re-ran unimport's scanDirExports over every import dir,
so a nuxt build read and parsed every composable and util six times. Keep the
scan for the current import dirs and drop it on imports:extend, which Nuxt
calls right after each of its own rescans.
Drop a rejected scan from the cache so the next manifest write scans again,
as it did before the scan was reused.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T23:32:56.130447Z 0016649 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@vite-hub

vite-hub Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Waiting 2026-10-31T23:39:56.586Z 1m 49s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Waiting for GitHub merge request 5f3a7c1f-5fec-42e9-807c-50b4cc02a448.

View session

Ready: verified the expected HEAD, complete diff, and supplied reviews. No actionable findings or failing hosted checks remain. Focused composable tests passed 20/20; vp fmt --check, vp lint, and git diff --check passed. Initial pnpm commands hit an automatic-install/no-TTY error; disabling pre-run dependency verification allowed validation with installed dependencies. Working tree is clean; no repair commit needed.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

Session

Waiting for running checks before the next pass.

@pkg-pr-new

pkg-pr-new Bot commented Oct 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm dlx https://pkg.pr.new/vite-doctor@308

commit: 0016649

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes across the complete two-file diff, including the cache lifecycle against Nuxt's import-regeneration ordering and the new regression coverage.

  • Composable scan reuse — caches the unimport directory scan per Nuxt evidence instance and import-directory key, while preserving the existing manifest output.
  • Invalidation and recovery — clears reuse after imports:extend and after a rejected active scan so watcher changes and transient failures are reflected by the next manifest write.
  • Regression coverage — verifies repeated writes avoid extra composable reads, watcher-added files enter scannedComposableFiles, and failed scans retry successfully.

Focused verification passed: 20 tests across composable-scan-reuse.test.ts and composable-scan-inventory.test.ts, plus lint and formatting checks for both changed files.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub
vite-hub Bot merged commit 593f9ae into main Oct 31, 2026
20 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 31, 2026
@onmax
onmax deleted the perf/nuxt-manifest-scan-once branch November 1, 2026 05:46
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