chore(nuxt): show warning if NuxtPage
is not used with pages enabled
#25490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Linked issue
Resolves #25089
β Type of change
π Description
This PR makes Nuxt show a warning message if pages feature is enabled but
<NuxtPage />
is never used, like it already does for<NuxtLayout />
.In the original issue, @manniL suggested that swap
<RouterView />
in dev mode by a proxy wrapper so that we can insert a logic to be run whenRouterView
is instantiated.In this PR, I took another approach that detection logic is inserted into
<NuxtPage />
, so that component tree can be same between dev and production, and that we can avoid to maintain dev-only component for external library.Although my approach requires 2 flags (dev-only runtime config and in-component flag), I believe it's simple and reasonable enough. What do you think?
π Checklist
I tested if this works in
playground
directory.pages/index.vue
with any contentpnpm run dev
π warning message is shown<RouterView />
toapp.vue
π warning message is shown<RouterView />
with<NuxtPage />
π warning message is not shownUpdate on documentation is already handled by #25106