fix(schema): enable HMR for defineNuxtComponent in JSX - #35620
#35620fix(schema): enable HMR for defineNuxtComponent in JSX#35620danielroe merged 2 commits intomainnuxt/nuxt:mainfrom fix/tsx-defineNuxtComponent-hmrnuxt/nuxt:fix/tsx-defineNuxtComponent-hmrCopy head branch name to clipboard
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/schema/src/config/vite.ts`:
- Around line 74-78: Update the returned options object in the Vite
configuration flow to spread options before assigning the enforced
isCustomElement and defineComponentName fields. Preserve the compiler-derived
isCustomElement handler and ensure defineComponentName always includes
defineNuxtComponent, even when user options provide overrides.
🪄 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: f8cc5cfb-d271-46d3-b9fd-7685ff9620fd
📒 Files selected for processing (1)
packages/schema/src/config/vite.ts
| return { | ||
| // TODO: investigate type divergence between types for @vue/compiler-core and @vue/babel-plugin-jsx | ||
| isCustomElement: (await get('vue')).compilerOptions?.isCustomElement as undefined | ((tag: string) => boolean), | ||
| ...typeof val === 'object' ? val : {}, | ||
| defineComponentName: [...new Set([...options.defineComponentName ?? ['defineComponent'], 'defineNuxtComponent'])], | ||
| ...options, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Apply enforced options after spreading user options.
...options on Line 78 overwrites both values calculated above. A configured defineComponentName can therefore omit defineNuxtComponent, and a configured isCustomElement can replace the compiler-derived handler. Spread options first, then assign these enforced fields.
Proposed fix
return {
+ ...options,
// TODO: investigate type divergence between types for `@vue/compiler-core` and `@vue/babel-plugin-jsx`
isCustomElement: (await get('vue')).compilerOptions?.isCustomElement as undefined | ((tag: string) => boolean),
defineComponentName: [...new Set([...options.defineComponentName ?? ['defineComponent'], 'defineNuxtComponent'])],
- ...options,
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| return { | |
| // TODO: investigate type divergence between types for @vue/compiler-core and @vue/babel-plugin-jsx | |
| isCustomElement: (await get('vue')).compilerOptions?.isCustomElement as undefined | ((tag: string) => boolean), | |
| ...typeof val === 'object' ? val : {}, | |
| defineComponentName: [...new Set([...options.defineComponentName ?? ['defineComponent'], 'defineNuxtComponent'])], | |
| ...options, | |
| return { | |
| ...options, | |
| // TODO: investigate type divergence between types for `@vue/compiler-core` and `@vue/babel-plugin-jsx` | |
| isCustomElement: (await get('vue')).compilerOptions?.isCustomElement as undefined | ((tag: string) => boolean), | |
| defineComponentName: [...new Set([...options.defineComponentName ?? ['defineComponent'], 'defineNuxtComponent'])], | |
| } |
🤖 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/schema/src/config/vite.ts` around lines 74 - 78, Update the returned
options object in the Vite configuration flow to spread options before assigning
the enforced isCustomElement and defineComponentName fields. Preserve the
compiler-derived isCustomElement handler and ensure defineComponentName always
includes defineNuxtComponent, even when user options provide overrides.
@nuxt/kit
@nuxt/nitro-server
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Merging this PR will not alter performance
Comparing Footnotes
|
🔗 Linked issue
resolves #35465
📚 Description
this adds
defineNuxtComponentto the list of component factories with HMR