Repository navigation
fix(nuxt): emit auto-import paths as files, not directories - #35333
Conversation
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
WalkthroughThis PR modifies the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
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 | 🟡 MinorAdd regression test for the
'./'subpath case incacheImportPaths.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) whenlookupNodeModuleSubpathreturns'./'.🤖 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
📒 Files selected for processing (1)
packages/nuxt/src/imports/module.ts
Merging this PR will not alter performance
Comparing Footnotes
|
🔗 Linked issue
nitrojs/nitro#4333
#35248
📚 Description
this pairs with nitrojs/nitro#4333 - we had the same issue elsewhere in nuxt