warn if `pages:extend` adds a route which replaces an existing route
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 60.9k
- Forks
- 5.8k
- Avg merge
- 7h 8m
- Merged PRs (30d)
- 162
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the extendPages callback in src/module.ts and reproduce the conflict using the module and playground pages described in the issue. Trace how the pages array handles duplicate names and paths; done means a duplicate route replacement is reported with a warning while the intended route behavior is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100