Skip to content

Conversation

OrbisK
Copy link
Collaborator

@OrbisK OrbisK commented Jul 13, 2025

🔗 Linked issue

fixes #32657

📚 Description

This PR follows up on #32119 and is wating for vuejs/core#13462

@OrbisK OrbisK requested a review from danielroe as a code owner July 13, 2025 15:19
Copy link

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

Copy link

coderabbitai bot commented Jul 13, 2025

Walkthrough

The changes remove references to the 'assets' directory from directory resolution and aliasing logic across multiple packages. In the schema configuration, 'assets' is no longer included in the list of directories checked for existence, and its default mapping in the directory configuration object is deleted. In both the Vite and Webpack build configurations, the alias entry for the assets directory, previously keyed by its basename, is removed along with the related import of the basename function. Additionally, the vue.transformAssetUrls configuration structure is modified by nesting tag mappings under a tags object and adding a preserveTilde flag. Test bundle size snapshot expectations are updated with minor byte size changes. No other logic or exported entities are altered.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

@danielroe danielroe changed the title fix: remove assets alias for all resolvers fix(nuxt): remove assets alias for all resolvers Jul 13, 2025
Copy link

pkg-pr-new bot commented Jul 13, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 8734759

Copy link

codspeed-hq bot commented Jul 13, 2025

CodSpeed Performance Report

Merging #32598 will not alter performance

Comparing OrbisK:assets-alias (8734759) with main (53f2acd)

Summary

✅ 10 untouched benchmarks

@@ -89,7 +89,6 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
},
resolve: {
alias: {
[basename(nuxt.options.dir.assets)]: resolve(nuxt.options.srcDir, nuxt.options.dir.assets),
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to keep this entry here and in the webpack presets until vuejs/core#13462 merges.

see 03d7c6e

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay. Looks like vuejs/core#13462 comes with next minor

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8734759 and bf87b7a.

📒 Files selected for processing (2)
  • packages/schema/src/config/app.ts (1 hunks)
  • test/bundle.test.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • test/bundle.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .github/copilot-instructions.md
**/*.{ts,tsx,vue}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • .github/copilot-instructions.md
🧠 Learnings (2)
📓 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: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Remove code that is not used or needed
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.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{test,spec}.{ts,tsx} : Write unit tests for core functionality using vitest
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.
packages/schema/src/config/app.ts (6)
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components
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: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Remove code that is not used or needed
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Add comments only to explain complex logic or non-obvious implementations
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
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-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Use clear, descriptive variable and function names
⏰ 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). (1)
  • GitHub Check: Socket Security: Pull Request Alerts

Comment on lines +10 to +17
preserveTilde: true,
tags: {
video: ['src', 'poster'],
source: ['src'],
img: ['src'],
image: ['xlink:href', 'href'],
use: ['xlink:href', 'href'],
},
Copy link

@coderabbitai coderabbitai bot Jul 13, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the Vue transformAssetUrls API structure for correctness.

The configuration structure has been updated to nest tag mappings under a tags object and add a preserveTilde flag. This appears to align with a newer Vue API format, but please verify this matches the expected structure.


🌐 Web query:

What is the correct structure for Vue's transformAssetUrls configuration in the latest version? Does it support a preserveTilde option and require tag mappings to be nested under a tags object?

💡 Result:

The correct structure for Vue's transformAssetUrls configuration in the latest versions (Vue Loader v16+, Vite + @vitejs/plugin-vue, Vue 3) remains a flat object, mapping tag names to attribute names or arrays of attribute names. The standard structure is as follows:

{
  transformAssetUrls: {
    img: 'src',
    image: ['xlink:href', 'href'],
    source: 'src',
    video: ['src', 'poster'],
    use: ['xlink:href', 'href'],
    // custom tag/attribute mappings as needed
  }
}

Tag mappings do not need to be nested under a tags object; the tag name is the top-level key[2][5][8].

Example from Official Docs

The default value for transformAssetUrls is:

{
  video: ['src', 'poster'],
  source: 'src',
  img: 'src',
  image: ['xlink:href', 'href'],
  use: ['xlink:href', 'href']
}
```[2][5]

Custom Component Support

If you’re using custom components (like from BootstrapVue or Vuetify), simply add them directly as keys on the root of the transformAssetUrls object—not inside a tags object[5].

preserveTilde Option

There is no official preserveTilde option supported in the mainline vue-loader, @vitejs/plugin-vue, or the Vite ecosystem, as of 2025. The handling of the tilde (~) prefix for asset paths (used to indicate webpack aliases) has changed in recent build tools:

  • In Vite, the tilde alias is deprecated and not processed the same way as in webpack.
  • If you want to preserve ~ or handle special aliases, you must rely on Vite's alias configuration or preprocess your paths, but there is no preserveTilde flag in transformAssetUrls[2][3][5].

Summary Table

Feature Supported Notes
Flat object (tag: attrs) mapping Yes Tag names map directly to attrs on root object.
Nested tags object No Not required or supported.
preserveTilde option No No such option in official plugins/loaders.

In summary, keep transformAssetUrls as a flat object of tag/attr mappings, and do not use a nested tags object or expect support for a preserveTilde option[2][5][8]. For handling tilde, manage aliases at the build tool config level instead.

Citations:


transformAssetUrls configuration needs to be a flat mapping
The current nesting under a tags object and the preserveTilde flag are not supported by Vue’s official transformAssetUrls API. You must:

• Remove the preserveTilde: true property
• Lift all tag entries out of the tags object into the root of transformAssetUrls

Locations to update:

  • packages/schema/src/config/app.ts (around lines 10–17)

Suggested diff:

- vue: {
-   transformAssetUrls: {
-     preserveTilde: true,
-     tags: {
-       video: ['src', 'poster'],
-       source: ['src'],
-       img: ['src'],
-       image: ['xlink:href', 'href'],
-       use: ['xlink:href', 'href'],
-     },
-   },
- },
+ vue: {
+   transformAssetUrls: {
+     video: ['src', 'poster'],
+     source: 'src',
+     img: 'src',
+     image: ['xlink:href', 'href'],
+     use: ['xlink:href', 'href'],
+   },
+ },
🤖 Prompt for AI Agents
In packages/schema/src/config/app.ts around lines 10 to 17, the
transformAssetUrls configuration incorrectly nests tag mappings under a tags
object and includes a preserveTilde property, which Vue's official API does not
support. To fix this, remove the preserveTilde property entirely and move all
tag-to-attribute mappings out of the tags object to be direct properties of
transformAssetUrls at the root level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lift all tag entries out of the tags object into the root of transformAssetUrls

From vue changelog 3.0.0-beta.9

compiler-sfc: @vue/compiler-sfc's transformAssetUrlsBase option has been removed. It is merged into trasnformAssetUrls which now also accepts the format of

{
  base?: string
  includeAbsolute?: string
  tags?: { [name: string]: string[] }
}

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@OrbisK
Copy link
Collaborator Author

OrbisK commented Jul 13, 2025

@danielroe I have prepared this PR to be compatible when vuejs/core#13462 gets merged.

I moved the legacy transformAssetsUrls tags to the tags key, because it does not let me set the new tilde option because of this check: https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/template/transformAssetUrl.ts#L52

Tests are passing locally with:

  "pnpm": {
    "overrides": {
      "vue": "https://pkg.pr.new/vue@13462",
      "@vue/compiler-sfc": "https://pkg.pr.new/@vue/compiler-sfc@13462"
    }
  },

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.

Images Not displayed in V4
2 participants