Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement nuxt's definePageMeta #44

Open
danielroe opened this issue Aug 1, 2022 · 2 comments
Open

implement nuxt's definePageMeta #44

danielroe opened this issue Aug 1, 2022 · 2 comments
Labels
⚡️ enhancement improvement over an existing feature

Comments

@danielroe
Copy link
Sponsor Collaborator

danielroe commented Aug 1, 2022

In Nuxt, we extract route metadata through a macro and need to inject this in the generated routes. We don't serialise it but instead keep it in the rollup build and import with a custom query param, e.g. import { meta } from '~/pages/index.vue?macro=true.

Using a library like this, we would either need to take full control of the generated routes file (not the .d.ts) or have a callback to manipulate the generated file, ideally via some kind of AST that lets us have raw access to inject real code.

Edit by Eduardo: after calling with Daniel, we should add the same macro Nuxt has (definePageMeta()) See if we should name it differently and allow rename through option.

@posva posva changed the title callback to allow manipulating generated code implement nuxt's definePageMeta Aug 2, 2022
@stenet
Copy link

stenet commented Aug 4, 2022

Hi,

I have done some tests with many pages and with the current implementation (i.e. with a route block to configure meta data). Currently it doesn't matter if there are two pages or a thousand pages, it's always super fast. With Nuxt and definePageMeta(), loading an app with a thousand pages takes some time (5 seconds in my case) because all pages are called with ?macro=true.

For this reason I would prefer some kind of configuration to disable the definePageMeta() behavior. Or will this implementation be different from the Nuxt implementation? Or is there a way to optimize this that I am not aware of?

My sample https://github.com/stenet/vue-auto-import

posva added a commit that referenced this issue Sep 30, 2022
@posva
Copy link
Owner

posva commented Sep 30, 2022

Added definePage() to the docs and released it. I think the version tries to skip parsing as soon as possible but ideally there should be hooks in vue compiler (vuejs/rfcs#430) to make this faster

@settings settings bot removed the enhancement label Feb 21, 2024
@posva posva added the ⚡️ enhancement improvement over an existing feature label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡️ enhancement improvement over an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants