Skip to content

fix(nuxt): emit auto-import paths as files, not directories - #35333

Merged
danielroe merged 1 commit into
mainfrom
fix/deno-auto-import-types
Jun 11, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/deno-auto-import-types

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

nitrojs/nitro#4333
#35248

📚 Description

this pairs with nitrojs/nitro#4333 - we had the same issue elsewhere in nuxt

@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: c4e0705

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR modifies the cacheImportPaths function in the imports module to refine how resolved import paths are constructed from node module subpaths. When the subpath lookup returns './', the code now returns the original resolved module path instead of joining it with the './' fragment. For other non-empty subpaths, path joining continues as before.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: modifying how auto-import paths are emitted (as files rather than directories), which aligns perfectly with the code change in cacheImportPaths.
Description check ✅ Passed The description is related to the changeset, referencing linked issues and explaining this pairs with a Nitro fix addressing the same issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/deno-auto-import-types

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/nuxt/src/imports/module.ts (1)

215-246: ⚠️ Potential issue | 🟡 Minor

Add regression test for the './' subpath case in cacheImportPaths.

A search for cacheImportPaths / lookupNodeModuleSubpath.*\./ across existing *test*/*spec* files found no matching coverage, so the './' branch risks regressions. Add a test asserting the emitted auto-import/type path is handled as a file (not a directory) when lookupNodeModuleSubpath returns './'.

🤖 Prompt for 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.

In `@packages/nuxt/src/imports/module.ts` around lines 215 - 246, Add a regression
test for cacheImportPaths that stubs/mocks lookupNodeModuleSubpath to return
'./' and verifies the resolvedImportPathMap for the module key yields the
resolved file path (i.e. treated as the original resolved module file, not
transformed into a directory join(dir,name,subpath)); exercise cacheImportPaths
with a non-absolute module import so the tryResolveModule branch runs and assert
the final value stored by resolvedImportPathMap for that import is the file path
(or stripped extension) expected when lookupNodeModuleSubpath returns './',
covering the branch guarded by "return subpath && subpath !== './' ? join(dir,
name, subpath) : r".
🤖 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.

Outside diff comments:
In `@packages/nuxt/src/imports/module.ts`:
- Around line 215-246: Add a regression test for cacheImportPaths that
stubs/mocks lookupNodeModuleSubpath to return './' and verifies the
resolvedImportPathMap for the module key yields the resolved file path (i.e.
treated as the original resolved module file, not transformed into a directory
join(dir,name,subpath)); exercise cacheImportPaths with a non-absolute module
import so the tryResolveModule branch runs and assert the final value stored by
resolvedImportPathMap for that import is the file path (or stripped extension)
expected when lookupNodeModuleSubpath returns './', covering the branch guarded
by "return subpath && subpath !== './' ? join(dir, name, subpath) : r".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f6358b5-c809-44ea-bc51-952e2d4ea949

📥 Commits

Reviewing files that changed from the base of the PR and between 0c359c6 and c4e0705.

📒 Files selected for processing (1)
  • packages/nuxt/src/imports/module.ts

@codspeed

codspeed Bot commented Jun 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/deno-auto-import-types (c4e0705) with main (0c359c6)

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

@danielroe
danielroe enabled auto-merge June 10, 2026 19:30
@danielroe
danielroe requested a review from huang-julien June 10, 2026 19:30
@danielroe
danielroe added this pull request to the merge queue Jun 11, 2026
Merged via the queue into main with commit 6198010 Jun 11, 2026
32 of 33 checks passed
@danielroe
danielroe deleted the fix/deno-auto-import-types branch June 11, 2026 09:25
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026
2 of 5 tasks
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
@github-actions github-actions Bot mentioned this pull request Jul 18, 2026
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.

2 participants