Skip to content

Conversation

danielroe
Copy link
Member

🔗 Linked issue

📚 Description

this PR updates a number of places where we hard-code ~/${somePath} for more consistency and fixes bugs resolving paths that have a more precise path (such as in layers)

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

The changes across multiple files primarily standardise how file paths are represented in warning and error messages throughout the codebase. The previous approach, which used relative filesystem paths, has been replaced by a new utility function, resolveToAlias, that converts file paths to Nuxt alias strings for improved consistency. This utility is now used in various modules, including layout handling, component scanning, lazy hydration, loader, app resolution, imports, and pages. Additionally, the extractRouteRules call in the pages module was changed from asynchronous to synchronous. No exported function signatures were altered, except for the addition of the new utility function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa569ed and 63f10ec.

📒 Files selected for processing (8)
  • packages/kit/src/layout.ts (3 hunks)
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts (2 hunks)
  • packages/nuxt/src/components/plugins/loader.ts (2 hunks)
  • packages/nuxt/src/components/scan.ts (3 hunks)
  • packages/nuxt/src/core/app.ts (3 hunks)
  • packages/nuxt/src/imports/module.ts (2 hunks)
  • packages/nuxt/src/pages/module.ts (3 hunks)
  • packages/nuxt/src/utils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/core/app.ts
  • packages/kit/src/layout.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/imports/module.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: Tofandel
PR: nuxt/nuxt#0
File: :0-0
Timestamp: 2024-11-11T12:34:22.648Z
Learning: Ensure that AI-generated summaries accurately reflect the key changes in the PR, focusing on notable changes such as the removal of unused imports and variables starting with underscores.
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
📚 Learning: in `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distdir` are l...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/core/app.ts
  • packages/kit/src/layout.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/imports/module.ts
📚 Learning: in `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally im...
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/core/app.ts
  • packages/kit/src/layout.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/imports/module.ts
📚 Learning: ensure that ai-generated summaries accurately reflect the key changes in the pr, focusing on notable...
Learnt from: Tofandel
PR: nuxt/nuxt#0
File: :0-0
Timestamp: 2024-11-11T12:34:22.648Z
Learning: Ensure that AI-generated summaries accurately reflect the key changes in the PR, focusing on notable changes such as the removal of unused imports and variables starting with underscores.

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/pages/module.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/imports/module.ts
📚 Learning: in nuxt, using `rolldownversion` (not `rollupversion`) is intentional when detecting if rolldown-vit...
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
📚 Learning: applies to **/*.vue : use `<script setup lang="ts">` and the composition api when creating vue compo...
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
📚 Learning: in `packages/kit/src/template.ts`, when updating the `extension_re` regular expression for typescrip...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#29661
File: packages/kit/src/template.ts:227-229
Timestamp: 2024-11-28T21:22:40.496Z
Learning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.

Applied to files:

  • packages/kit/src/layout.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: codeql (javascript-typescript)
  • GitHub Check: code
🔇 Additional comments (18)
packages/nuxt/src/core/app.ts (2)

8-8: LGTM: Import addition is correctly implemented.

The addition of resolveToAlias to the import statement follows TypeScript conventions and supports the standardisation of path representation in error messages.


168-168: LGTM: Consistent alias resolution in warning messages.

The replacement of relative(nuxt.options.srcDir, file) with resolveToAlias(file, nuxt) improves error message consistency by using alias-based paths instead of relative filesystem paths. This aligns with the PR's objective of providing clearer path resolution in warnings.

Also applies to: 187-187

packages/nuxt/src/components/plugins/loader.ts (2)

10-10: LGTM: Import addition correctly implemented.

The addition of resolveToAlias to the import statement is properly structured and supports the improved error messaging functionality.


62-62: LGTM: Enhanced error message with alias resolution.

The replacement of relative(nuxt.options.rootDir, id) with resolveToAlias(id, nuxt) improves the error message by providing alias-based path representation instead of relative filesystem paths. This makes error messages more consistent and user-friendly.

packages/nuxt/src/components/plugins/lazy-hydration-transform.ts (2)

9-9: LGTM: Import updated to use internal utility.

The import change from reverseResolveAlias (external) to resolveToAlias (internal utility) correctly adopts the standardised alias resolution approach introduced in this PR.


106-106: LGTM: Simplified alias resolution in warning message.

The replacement of complex alias resolution logic with resolveToAlias(id, nuxt) simplifies the code whilst maintaining the same functionality. This change improves consistency across the codebase and makes the warning message more readable.

packages/nuxt/src/imports/module.ts (2)

9-9: LGTM: Import addition correctly implemented.

The addition of resolveToAlias to the import statement properly supports the enhanced error messaging functionality.


149-149: LGTM: Improved error message with standardised alias resolution.

The replacement of manual relative path calculation ('~/' + relative(nuxt.options.srcDir, i.from)) with resolveToAlias(i.from, nuxt) simplifies the logic whilst providing more consistent alias-based path representation in error messages. This aligns with the codebase standardisation efforts.

packages/nuxt/src/utils.ts (2)

2-3: LGTM: Import additions correctly implemented.

The imports for tryUseNuxt and reverseResolveAlias are properly added to support the new utility function functionality.


16-23: LGTM: Well-implemented utility function for alias resolution.

The resolveToAlias function provides a clean abstraction for converting file paths to alias-based representations. The implementation correctly:

  • Uses optional parameter with fallback to tryUseNuxt()
  • Merges Nuxt aliases with stripped aliases for '@' and '@@' prefixes
  • Returns the original path as fallback when no alias matches
  • Follows TypeScript conventions with proper typing

This utility effectively standardises alias resolution across the codebase and improves error message consistency.

packages/nuxt/src/pages/module.ts (3)

16-16: LGTM!

The addition of resolveToAlias import is necessary for the alias-based path resolution used in error messages later in the file.


428-429: Excellent improvement to error message consistency.

Replacing relative() path calculations with resolveToAlias() provides more consistent and meaningful path representations in error logs, especially beneficial for projects with layers and complex structures.

Also applies to: 439-439


425-425: Removal of await is intentional and correct

Verified that extractRouteRules is defined as a synchronous function in packages/nuxt/src/pages/route-rules.ts (returning NitroRouteConfig | null), so dropping the await at line 425 in packages/nuxt/src/pages/module.ts aligns with its signature and will not introduce runtime errors.

packages/nuxt/src/components/scan.ts (2)

9-9: LGTM!

The import addition is necessary for the alias-based path resolution used in warning messages.


51-53: Consistent improvement to warning messages.

The replacement of relative() path calculations with resolveToAlias() provides better path representation in component scanning warnings, making them more consistent and meaningful for developers.

Also applies to: 144-144

packages/kit/src/layout.ts (3)

2-2: LGTM with different approach to alias resolution.

The direct import of reverseResolveAlias from 'pathe/utils' instead of using the resolveToAlias utility is acceptable, likely due to the specific alias handling requirements in this context.

Also applies to: 7-7


18-20: Effective alias resolution for layout warnings.

The comprehensive alias resolution using both Nuxt aliases and stripped aliases provides better path representation in layout conflict warnings. The approach is more explicit than using the utility function but serves the same purpose effectively.


30-33: Well-designed alias stripping for cleaner paths.

The strippedAtAliases constant provides a clean way to remove common Nuxt aliases ('@' and '@@') from displayed paths, improving readability in warning messages.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/alias

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

This set of changes standardises the way file paths are displayed in warning and error messages across several Nuxt core and plugin files. The primary update is the introduction of a new utility function, resolveToAlias, which resolves file paths to their Nuxt alias representations, improving consistency in log outputs. Various files previously using methods like relative or reverseResolveAlias for path formatting have been refactored to use this new utility. No changes were made to the signatures or behaviour of exported or public entities, except for the addition of the new utility function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa569ed and 63f10ec.

📒 Files selected for processing (8)
  • packages/kit/src/layout.ts (3 hunks)
  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts (2 hunks)
  • packages/nuxt/src/components/plugins/loader.ts (2 hunks)
  • packages/nuxt/src/components/scan.ts (3 hunks)
  • packages/nuxt/src/core/app.ts (3 hunks)
  • packages/nuxt/src/imports/module.ts (2 hunks)
  • packages/nuxt/src/pages/module.ts (3 hunks)
  • packages/nuxt/src/utils.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/pages/module.ts
  • packages/kit/src/layout.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
📚 Learning: in `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distdir` are l...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.

Applied to files:

  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/pages/module.ts
  • packages/kit/src/layout.ts
📚 Learning: in `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally im...
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.

Applied to files:

  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/utils.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/pages/module.ts
  • packages/kit/src/layout.ts
📚 Learning: ensure that ai-generated summaries accurately reflect the key changes in the pr, focusing on notable...
Learnt from: Tofandel
PR: nuxt/nuxt#0
File: :0-0
Timestamp: 2024-11-11T12:34:22.648Z
Learning: Ensure that AI-generated summaries accurately reflect the key changes in the PR, focusing on notable changes such as the removal of unused imports and variables starting with underscores.

Applied to files:

  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/core/app.ts
  • packages/nuxt/src/imports/module.ts
  • packages/nuxt/src/components/scan.ts
  • packages/nuxt/src/pages/module.ts
  • packages/kit/src/layout.ts
📚 Learning: applies to **/*.vue : use `<script setup lang="ts">` and the composition api when creating vue compo...
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components

Applied to files:

  • packages/nuxt/src/components/plugins/lazy-hydration-transform.ts
  • packages/nuxt/src/components/plugins/loader.ts
📚 Learning: in nuxt, using `rolldownversion` (not `rollupversion`) is intentional when detecting if rolldown-vit...
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.

Applied to files:

  • packages/nuxt/src/components/plugins/loader.ts
  • packages/nuxt/src/imports/module.ts
📚 Learning: applies to **/*.{ts,tsx} : follow standard typescript conventions and best practices...
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-18T16:46:07.446Z
Learning: Applies to **/*.{ts,tsx} : Follow standard TypeScript conventions and best practices

Applied to files:

  • packages/nuxt/src/components/scan.ts
📚 Learning: in `packages/kit/src/template.ts`, when updating the `extension_re` regular expression for typescrip...
Learnt from: GalacticHypernova
PR: nuxt/nuxt#29661
File: packages/kit/src/template.ts:227-229
Timestamp: 2024-11-28T21:22:40.496Z
Learning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.

Applied to files:

  • packages/nuxt/src/components/scan.ts
  • packages/kit/src/layout.ts
🧬 Code Graph Analysis (4)
packages/nuxt/src/core/app.ts (1)
packages/nuxt/src/utils.ts (2)
  • logger (14-14)
  • resolveToAlias (16-18)
packages/nuxt/src/imports/module.ts (1)
packages/nuxt/src/utils.ts (1)
  • resolveToAlias (16-18)
packages/nuxt/src/components/scan.ts (1)
packages/nuxt/src/utils.ts (2)
  • resolveToAlias (16-18)
  • logger (14-14)
packages/nuxt/src/pages/module.ts (2)
packages/nuxt/src/pages/route-rules.ts (1)
  • extractRouteRules (13-45)
packages/nuxt/src/utils.ts (2)
  • resolveToAlias (16-18)
  • logger (14-14)
🔇 Additional comments (24)
packages/nuxt/src/components/plugins/loader.ts (2)

10-10: LGTM: Import statement updated correctly.

The addition of resolveToAlias import is consistent with the standardisation effort across the codebase.


62-62: LGTM: Improved error message path formatting.

The change from relative(nuxt.options.rootDir, id) to resolveToAlias(id, nuxt) provides better alias-based path representation in error messages, improving developer experience.

packages/nuxt/src/core/app.ts (3)

8-8: LGTM: Import statement updated correctly.

The addition of resolveToAlias import maintains consistency with the standardisation effort.


168-168: LGTM: Improved warning message path formatting.

Using resolveToAlias(file, nuxt) instead of relative(nuxt.options.srcDir, file) provides clearer alias-based paths in layout resolution warnings.


187-187: LGTM: Consistent path formatting for middleware warnings.

The middleware warning now uses the same alias-based path formatting as the layout warning, maintaining consistency.

packages/nuxt/src/pages/module.ts (4)

16-16: LGTM: Import statement updated correctly.

The addition of resolveToAlias import aligns with the standardisation effort across the codebase.


425-425: LGTM: Corrected function call from async to sync.

The extractRouteRules function is synchronous and returns NitroRouteConfig | null, so removing the await is the correct approach.


428-429: LGTM: Improved error message path formatting.

Using resolveToAlias(path, nuxt) instead of relative(nuxt.options.srcDir, path) provides clearer alias-based paths in error messages for unmapped inline route rules.


439-439: LGTM: Consistent error message path formatting.

The parsing error message now uses the same alias-based path formatting, maintaining consistency with other error messages.

packages/nuxt/src/components/plugins/lazy-hydration-transform.ts (2)

9-9: LGTM: Simplified import statement.

Replacing manual alias resolution with the centralised resolveToAlias utility reduces code duplication and improves maintainability.


106-106: LGTM: Streamlined path resolution.

Using resolveToAlias(id, nuxt) instead of manual alias handling simplifies the code whilst maintaining the same functionality for component path warnings.

packages/nuxt/src/utils.ts (3)

2-3: LGTM: Required imports added correctly.

The imports for tryUseNuxt and reverseResolveAlias are necessary for the new utility function implementation.


16-18: LGTM: Well-designed utility function.

The resolveToAlias function provides a clean abstraction for alias resolution with sensible defaults and fallback behaviour. Using tryUseNuxt() as the default parameter allows flexible usage across the codebase.


20-23: LGTM: Appropriate constant declaration.

The strippedAtAliases constant is well-scoped and provides the necessary alias mappings for the utility function.

packages/nuxt/src/imports/module.ts (2)

9-9: LGTM: Import addition aligns with standardisation effort.

The addition of resolveToAlias to the import statement is consistent with the broader refactoring to standardise path alias resolution across the codebase.


149-149: LGTM: Improved path resolution for error messages.

The change from using relative with ~/ prefix to resolveToAlias provides more consistent and accurate alias-based path representation in error messages. This improves the user experience by showing paths in a format that matches Nuxt's alias configuration.

packages/nuxt/src/components/scan.ts (3)

9-9: LGTM: Import addition supports path standardisation.

The addition of resolveToAlias to the import statement enables consistent alias-based path resolution in warning messages throughout the component scanning process.


51-53: LGTM: Improved directory path representation in warnings.

The change from using relative paths with ~/ prefix to resolveToAlias for both original and corrected directory paths provides clearer and more consistent path representation in case-insensitive directory mismatch warnings.


144-144: LGTM: Consistent file path representation in component warnings.

The replacement of relative path computation with resolveToAlias ensures that component resolution warnings display paths in a format consistent with Nuxt's alias system, improving the developer experience.

packages/kit/src/layout.ts (5)

2-2: LGTM: Import update reflects new path resolution approach.

The removal of relative from the imports aligns with the shift towards alias-based path resolution.


7-7: LGTM: Addition of reverseResolveAlias import.

The import of reverseResolveAlias from 'pathe/utils' enables the new alias-based path resolution logic.


18-18: LGTM: Improved alias resolution logic.

The change to use reverseResolveAlias with merged aliases (including the new strippedAtAliases) provides consistent path representation that matches Nuxt's alias system. The fallback to the original file path ensures robustness.


20-20: LGTM: Cleaner warning message format.

The removal of the ~/ prefix from the warning message provides cleaner output since the alias resolution now handles the appropriate path format.


30-33: LGTM: Consistent alias stripping logic.

The addition of strippedAtAliases constant mapping '@' and '@@' to empty strings maintains consistency with the alias resolution approach used in other parts of the codebase. This ensures that paths are resolved to their most appropriate alias representation.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/alias

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Aug 4, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 63f10ec

Copy link

codspeed-hq bot commented Aug 4, 2025

CodSpeed Performance Report

Merging #32853 will not alter performance

Comparing fix/alias (63f10ec) with main (aa569ed)

Summary

✅ 10 untouched benchmarks

Comment on lines +15 to +23

export function resolveToAlias (path: string, nuxt = tryUseNuxt()) {
return reverseResolveAlias(path, { ...nuxt?.options.alias || {}, ...strippedAtAliases }).pop() || path
}

const strippedAtAliases = {
'@': '',
'@@': '',
}
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it be better to put this into packages/kit/src/resolve.ts ?

Copy link
Member Author

Choose a reason for hiding this comment

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

you're thinking of creating + exposing a new utility? good idea - we can refactor this in the next minor to add a new export ...

@danielroe danielroe merged commit d75e855 into main Aug 5, 2025
83 of 84 checks passed
@danielroe danielroe deleted the fix/alias branch August 5, 2025 07:10
@github-actions github-actions bot mentioned this pull request Aug 5, 2025
This was referenced Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants