nuxt / nuxt/bridge

extendPages not resolving component

Open
#1,105 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
285
Forks
33
Avg merge
22h 38m
Merged PRs (30d)
3

Description

Environment
  • Operating System: Darwin
  • Node Version: v18.18.2
  • Nuxt Version: 2.17.3
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: yarn@1.22.19
  • Builder: webpack
  • User Config: bridge, modules, serverHandlers, devServerHandlers, devServer, typescript, nitro, buildModules
  • Runtime Modules: @/modules/addLocale.ts
  • Build Modules: (), @nuxt/bridge@3.0.1-28459804.a0dceb3
Reproduction

Stackblitz: https://stackblitz.com/edit/github-nafqpn?file=modules%2FaddLocale.ts
Repo: https://github.com/yanniznik/nuxt-bridge-extendPages

  1. Add a module file and load it in nuxt.config.ts under modules
  2. Use the nuxt3 extendPages method to add a new route
  3. yarn dev
  4. in Chrome dev console, run $nuxt.$router.options.routes
  5. Go to /Locale and get 404 instead of component
Describe the bug

Current: The page doesn't load (404 not found). The new "/Locale" route was added from a module using extendPage. Looking at the route object clearly shows that the route doesn't have a component attached

Expected: the component is attached to the route so that it can be loaded normally

image
Additional context

The exact same setu in Nuxt3 works. /Locale is apccessible
Example stablitz with Nuxt3, same setup: https://stackblitz.com/github/nuxt/examples/tree/main/examples/advanced/module-extend-pages?embed=1&file=pages/index.vue&theme=dark

Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The reproduction is in modules/addLocale.ts; start by running yarn dev and inspecting $nuxt.$router.options.routes for /Locale. Compare Nuxt Bridge's extendPages behavior with the linked Nuxt 3 example. The work is done when the generated route includes its component and /Locale no longer returns 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.