nuxt/nuxt
View on GitHubwarn if `pages:extend` adds a route which replaces an existing route
Open
#24174 opened on Nov 7, 2023
good first issue🍰 p2-nice-to-have🛠️ dx
Description
Environment
- Operating System:
Linux - Node Version:
v18.15.0 - Nuxt Version:
3.8.0 - CLI Version:
3.9.1 - Nitro Version:
2.7.0 - Package Manager:
pnpm@8.7.6 - Builder:
- - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
- Starts a module following https://nuxt.com/docs/guide/going-further/modules
- Create a page in
src/runtime/pages/test.vue(module);
<template><h1>Page from module</h1></template>
- Register the page in
src/module.ts:
extendPages((pages) => {
pages.push({
name: 'test',
path: '/test',
file: resolver.resolve('runtime', 'pages', 'test'),
})
})
- Create a page in
playground/pages/test.vue(playground):
<template><h1>Page from playground</h1></template>
- Start the project
- Navigate to http://localhost:3000/test
Describe the bug
The "Page from module" is displayed instead of the "Page from playground"
Additional context
Replacing pages.push with pages.unshift effectively displays the "playground" pages.
Using a different name (than the "generated one") in module such as: name: 'mymodule-test' fixes this but declares two pages (while the former re-group? both pages) in dev tools.
There is no warning or whatsoever that this page is declared twice.
As this is called extendPages I would expect this to not override project pages.
In my case I wan't to be able to "override" module pages from playground pages.
Logs
No response