N
Nuxt3y ago
Dan H

Can you use definePageMeta within pages registered by a module?

I am registering some pages using the extendPages function within a module, but seeing the following warning while running the site:
definePageMeta() is a compiler-hint helper that is only usable inside the script block of a single file component which is also a page. Its arguments should be compiled away and passing it at runtime has no effect.
definePageMeta() is a compiler-hint helper that is only usable inside the script block of a single file component which is also a page. Its arguments should be compiled away and passing it at runtime has no effect.
I have added the call within <script setup> of my pages, it isn't used anywhere else, and only has static values supplied. I'm not sure if I'm doing something wrong? Thanks
2 Replies
harlan
harlan3y ago
definePageMeta is a compiler macro, meaning it needs to be included as part of the server / client builds you can probably do some config to get your page to be included, by default node_modules are ignored from this
nuxt.options.build.transpile.push(path)
nuxt.options.build.transpile.push(path)
this might work but not exactly sure how it works under the hood so hard to say
Dan H
Dan HOP3y ago
Thank you, I'll look into that! That didn't seem to prevent the warning, but in testing I did spot the meta property on the NuxtPage objects you add in extendPages, so I've switched to using that, which seems to work

Did you find this page helpful?