-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): ensure appConfig sources are not duplicated #32216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where duplicate application configuration files were being pushed into the app configurations array.
- Prevent duplicate app config paths by checking for existence before pushing
- Addresses an HMR-related bug that causes duplicated config entries
Comments suppressed due to low confidence (1)
packages/nuxt/src/core/app.ts:227
- Adding a duplicate check is a necessary fix, but ensure that appConfigPath values are consistently formatted (e.g., resolved to absolute paths) to reliably prevent duplicates.
if (appConfigPath && !app.configs.includes(appConfigPath)) {
WalkthroughThe change updates the comment above the final normalization and deduplication step in the 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (14)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
packages/nuxt/src/core/app.ts
Outdated
if (appConfigPath && !app.configs.includes(appConfigPath)) { | ||
app.configs.push(appConfigPath) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Middleware and plugin deduplication occur after app:resolve
. If this should be deduplicated, perhaps it should happen there, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, we should also deduplicate after the app:resolve
hook.
An easy way as uniqueBy
is for array with objects would be to do on lines 230 and 238:
app.configs = [...new Set(app.configs)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodSpeed Performance ReportMerging #32216 will not alter performanceComparing Summary
|
interesting. I wonder if the root cause is the source of #30267. if so it may be that we can solve all these issues at source (or it's possible that deduplicating is the correct option - I'm very happy with this approach too) |
Co-authored-by: Daniel Roe <daniel@roe.dev>
thank you ❤️ |
🔗 Linked issue
nuxtlabs/docus#1077
📚 Description
This issue is related to how Nuxt Content handles HMR:
Updating Markdown content in local development with HMR triggers duplication of bottom links in the table of content of Docus v2 (currently WIP). Those links are represented by an array in the app.config.ts file.
Nuxt Content is calling updateTemplates to update dump and manifest templates and ensure database integrity.
This call triggers the
builder:generateApp
which itself call theresolveApp
method. SinceresolveApp
is also called by Nuxt HMR it results in multiple call happening at the same time and updating the sameapp
instance.In this case same config files are push to
app.configs
and are duplicated.I'm simply ensuring that config file are push only if they do not already exist.
Here is a video to explain the issue:
docus-duplicate-code.mp4
PS1: I'll be happy to provide a reproduction in test but I need help to create the test.
PS: It might also exists an issue with the way defufn is handling array merge here but I'm not sure how to provide a fix.