nuxt/framework

[@nuxt/kit] Can't use `addPluginTemplate` after `pages:extend` hook in module

victorgarciaesgi opened this issue · 0 comments

Environment

  • Operating System: Darwin
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.9
  • Nitro Version: 0.5.0
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/victorgarciaesgi/nuxt-typed-router/tree/bug/addPlugin

You can checkout the branch bug/addPlugin

yarn build:local && yarn play

Describe the bug

In my module nuxt-typed-router, I want to create a runtime plugin. But to create this plugin, I depend on pages getting resolved. I use nuxt.hook('pages:extend') to have all the routes tree.

Inside this hook, I can get routes names from it and generate a declaration tree, and use it in my plugin template

I added write: true to see if the plugin is generated and there is nothing in the .nuxt folder. I tried outside the hook and it is correctly generated, but I can't access the info I need outside the hook.

I also tried the runtimeConfig approach like in https://stackblitz.com/edit/github-jauvhr?file=modules%2Fhello.ts , but with no success

Additional context

No response

Logs

No response