Skip to content

fix(kit,nuxt): resolve auto-import type paths through shared resolver - #35451

Merged
danielroe merged 4 commits into
mainfrom
fix/autoimport-types
Jun 26, 2026
Merged

danielroe merged 4 commits into
mainfrom
fix/autoimport-types

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

regression from #35333

📚 Description

this creates two three shared utilities we can consume in nuxt (previously we were duplicating this same logic everywhere and it was diverging in unhelpful ways) for consistent type path resolution

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Jun 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35451

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35451

nuxt

npm i https://pkg.pr.new/nuxt@35451

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35451

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35451

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35451

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35451

commit: 8f32aac

@coderabbitai

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/kit/src/types.ts`:
- Around line 57-72: `resolveRoot()` is caching package roots only by `basePkg`,
which can return the wrong result when the same package is resolved from
different `from` locations. Update the cache key in `packages/kit/src/types.ts`
so it also includes the `from` inputs used by `resolveModulePath` inside
`resolveRoot`, and make sure the cache lookup/store in `rootCache` is keyed by
both `basePkg` and the resolved `from` context.
- Around line 85-110: The `resolveTypePaths()` implementation is order-dependent
because each async task mutates `results` with `push`, so the final array can
differ from the input `packages` order. Update `resolveTypePaths` to have each
`Promise.allSettled` task return its `[pkg, path]` pair (or nothing for
unresolved packages), then build the final array by flattening the settled
outcomes in the original `packages` iteration order. Keep the existing
`resolveModulePath`, `resolveDeclarationPath`, and `resolveRoot` logic intact
while removing shared mutation of `results`.

In `@packages/nuxt/src/imports/module.ts`:
- Line 2: The absolute alias target handling in the imports module is still only
stripping extensions, so declaration-only `.d.mts`/`.d.cts` neighbors can be
missed for `.mjs`/`.cjs` runtime files. Update the alias resolution path in
`module.ts` to reuse the shared declaration resolution logic used by
`resolveTypePaths()` (rather than just stripping extensions), and apply it
wherever absolute alias targets are normalized so the declaration file is chosen
when present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0aaa4e6c-6b7c-4244-817a-020c40dea971

📥 Commits

Reviewing files that changed from the base of the PR and between 7b7595b and 16f4c74.

📒 Files selected for processing (10)
  • packages/kit/src/index.ts
  • packages/kit/src/template.ts
  • packages/kit/src/types.ts
  • packages/kit/test/types.spec.ts
  • packages/nuxt/src/core/nuxt.ts
  • packages/nuxt/src/core/templates.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/test/resolve-type-paths.test.ts
💤 Files with no reviewable changes (3)
  • packages/nuxt/src/core/utils/types.ts
  • packages/nuxt/src/core/templates.ts
  • packages/nuxt/test/resolve-type-paths.test.ts

Comment thread packages/kit/src/types.ts Resolved
Comment thread packages/kit/src/types.ts Resolved
Comment thread packages/nuxt/src/imports/module.ts Resolved
@codspeed

codspeed Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 19 untouched benchmarks
⏩ 3 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ loadNuxt in the basic test fixture (dev) 329 ms 374.4 ms -12.11%
⚡ writeTypes in the basic-types fixture 51.2 ms 44.2 ms +15.77%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/autoimport-types (8f32aac) with main (7b7595b)

Open in CodSpeed

Footnotes

  1. 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. ↩

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

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant