-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): account for app's base URL when reloading app in nuxt:chunk-reload-immediate
#32382
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
…-reload-immediate`
|
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 updates the chunk reload plugin to factor in the application’s baseURL
when rebuilding the reload path, ensuring the app reloads correctly on chunk errors or manifest updates.
- Tracks the full
RouteLocationNormalized
object instead of justto.path
- Introduces
reloadAppAtPath
to construct reload URLs usingbaseURL
and handle hash navigation - Replaces the old
reloadNuxtApp_
wrapper and updates hooks to use the new function
Comments suppressed due to low confidence (2)
packages/nuxt/src/app/plugins/chunk-reload-immediate.client.ts:20
- The new
reloadAppAtPath
function’s logic for combiningbaseURL
,fullPath
, and hash handling isn’t covered by existing tests. Please add Vitest unit tests to validate URL construction under differentbaseURL
and hash scenarios.
function reloadAppAtPath (to: RouteLocationNormalized) {
packages/nuxt/src/app/plugins/chunk-reload-immediate.client.ts:20
- [nitpick] Add a JSDoc or inline comment above
reloadAppAtPath
explaining its purpose and detailing how it constructs the reload URL withbaseURL
and hash-based navigation for future maintainability.
function reloadAppAtPath (to: RouteLocationNormalized) {
const isHash = 'href' in to && (to.href as string)[0] === '#' | ||
const path = isHash ? config.app.baseURL + (to as any).href : joinURL(config.app.baseURL, to.fullPath) |
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.
RouteLocationNormalized does not include an href
property, so this check will always fail. Consider using to.hash
(e.g. const isHash = to.hash.startsWith('#')
) or inspecting to.fullPath
to detect hash-based navigation.
const isHash = 'href' in to && (to.href as string)[0] === '#' | |
const path = isHash ? config.app.baseURL + (to as any).href : joinURL(config.app.baseURL, to.fullPath) | |
const isHash = to.hash && to.hash.startsWith('#') | |
const path = isHash ? config.app.baseURL + to.hash : joinURL(config.app.baseURL, to.fullPath) |
Copilot uses AI. Check for mistakes.
WalkthroughThe plugin has been updated to track the complete route object ( 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
✨ Finishing Touches
🧪 Generate Unit Tests
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: |
CodSpeed Performance ReportMerging #32382 will not alter performanceComparing Summary
|
@DamianGlowala I wonder it this can fix #31915 too? |
🔗 Linked issue
resolves #32312
📚 Description
Takes into account app's base URL when reloading an app on chunk error/manifest update.