Repository navigation
fix(nuxt): pass nuxt rootDir to typed-router context - #35565
Merged
Merged
Conversation
… survives cwd !== rootDir
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Anoesj
marked this pull request as ready for review
July 14, 2026 06:43
This comment has been minimized.
This comment has been minimized.
Merging this PR will improve performance by 10.62%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | loadNuxt in the basic test fixture (dev) |
357.2 ms | 322.9 ms | +10.62% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Anoesj:fix/typed-pages-root-cwd (1f9c60c) with main (43a63f0)
Footnotes
-
3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
rootDir for typed-router context so useRoute() typing works even when cwd !== rootDir
danielroe
reviewed
Jul 14, 2026
rootDir for typed-router context so useRoute() typing works even when cwd !== rootDirrootDir to typed-router context
danielroe
added a commit
that referenced
this pull request
Jul 15, 2026
Co-authored-by: Daniel Roe <[email protected]>
Merged
danielroe
added a commit
that referenced
this pull request
Jul 17, 2026
Co-authored-by: Daniel Roe <[email protected]>
Closed
danielroe
added a commit
that referenced
this pull request
Jul 17, 2026
Co-authored-by: Daniel Roe <[email protected]>
danielroe
added a commit
that referenced
this pull request
Jul 17, 2026
Co-authored-by: Daniel Roe <[email protected]>
danielroe
added a commit
that referenced
this pull request
Jul 17, 2026
Co-authored-by: Daniel Roe <[email protected]>
danielroe
added a commit
that referenced
this pull request
Jul 17, 2026
Co-authored-by: Daniel Roe <[email protected]>
Merged
This was referenced Jul 21, 2026
Ibochkarev
pushed a commit
to translation-gang/nuxt
that referenced
this pull request
Jul 24, 2026
Co-authored-by: Daniel Roe <[email protected]>
This was referenced Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
Fixes #35564
📚 Description
With
experimental.typedPages, thesfc-typed-routerVolar plugin rewrites a bareuseRoute()in a page to infer that page's route name. This breaks when Nuxt is prepared withprocess.cwd()different fromnuxt.options.rootDir(e.g.nuxt prepare --cwd <subdir>from a parent directory, common in monorepos):useRoute().namefalls back to the fullkeyof RouteNamedMapunion.Root cause:
packages/nuxt/src/pages/module.tsbuilds the typed-router context without aroot, soresolveOptions(fromvue-router/unplugin) defaults it toprocess.cwd(). The generated_RouteFileInfoMapkeys are thenprocess.cwd()-relative, while the Volar plugin resolves files viarelative(nuxt.options.rootDir, file). When the two differ, no key matches.Fix: pass
root: nuxt.options.rootDirintotypedRouterOptions, so the DTS keys and the plugin both userootDirregardless ofprocess.cwd().Minimal standalone reproduction with 3 demos (same-dir ✅, subdir ❌, subdir + this patch ✅): https://github.com/Anoesj/nuxt-typedpages-cwd-rootdir-bug
🧪 Regression test
test/typed-router.test.tsgains two cases asserting the_RouteFileInfoMapkeys arerootDir-relative:nuxt prepare <rootDir>) — the case that regressed (red before this fix, green after)cwd === rootDir— control (green either way)cc @posva: this touches the
sfc-typed-routertyped-router integration you authored. Feedback welcome.