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

fix(nuxt): run page meta plugin on all pages (and only pages) #20628

Merged
merged 2 commits into from May 3, 2023

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

resolves #19955
alternate implementation of #19966

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Huge credit to @huang-julien - while reviewing his PR (which was great) it occurred to me that we could take the opportunity to rework how the page meta plugin works, which should also have the effect of improving performance. So this PR:

  1. only runs page-meta plugin (which parses AST, and therefore is costly) on imports with ?macro=true query, which means it also will run for all pages, however, they are added, including via pages:extend hook
  2. for perf, in dev mode we can keep definePageMeta in the component and only warn based on usage (namely, whether the component rendered is a route component). This will need testing to make sure we won't give users false positives here. I'd be up for fully removing the warning if needed.
  3. in build we can fully tree-shake calls to definePageMeta

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented May 2, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@huang-julien
Copy link
Member

huang-julien commented May 2, 2023

Looks wonderful ! ❀️ can't wait for it πŸ™Œ . I did have some hydration issues with hmr with github codespace but couldn't reproduce it once at home. Guess this is probably due to my poor connection on the train

@danielroe danielroe added the 3.x label May 3, 2023
@danielroe danielroe merged commit 566fa85 into main May 3, 2023
17 checks passed
@danielroe danielroe deleted the perf/page-meta branch May 3, 2023 14:14
@github-actions github-actions bot mentioned this pull request May 3, 2023
@ineshbose
Copy link
Member

Awesome! I was thinking of suggesting a similar macro for components like defineComponentMeta that could take component schema arguments?

@danielroe
Copy link
Member Author

Nice idea πŸ‘Œ

huang-julien added a commit to huang-julien/nuxt that referenced this pull request May 10, 2023
commit 29f2930
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 10 14:45:52 2023 +0100

    feat(nuxi): allow passing overrides to other nuxi commands (nuxt#20760)

commit 53fef72
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 10 13:57:27 2023 +0100

    fix(nuxt): deduplicate global components before registration (nuxt#20743)

commit 8cca5cc
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 10 13:45:49 2023 +0100

    fix(vite): expand `fs.allow` dirs to include app files (nuxt#20755)

commit cbcd254
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 10 13:11:13 2023 +0100

    refactor(kit): use esm utils for `resolvePath` (nuxt#20756)

commit 3b820ad
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 10 13:10:23 2023 +0100

    fix(kit): prefer esm resolution for modules to install (nuxt#20757)

commit 32fa44c
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Wed May 10 09:35:04 2023 +0100

    chore(deps): update all non-major dependencies (main) (nuxt#20712)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Daniel Roe <daniel@roe.dev>

commit 10e9d71
Author: Eckhardt (Kaizen) Dreyer <eckhardt.dreyer@gmail.com>
Date:   Wed May 10 10:15:11 2023 +0200

    chore: fix typo in `pnpm-workspace.yaml` (nuxt#20751)

commit 018bf12
Author: Julien Huang <julien.huang@outlook.fr>
Date:   Wed May 10 00:46:03 2023 +0200

    feat(nuxt): add apps to nuxt build-time instance (nuxt#20637)

commit 5781cf1
Author: Eduardo San Martin Morote <posva@users.noreply.github.com>
Date:   Tue May 9 19:08:07 2023 +0200

    feat(nuxt): add experimental `typedPages` option (nuxt#20367)

commit 80d7899
Author: Daniel Roe <daniel@roe.dev>
Date:   Tue May 9 17:47:46 2023 +0100

    fix(nuxt): prevent treeshaking hooks with composable names (nuxt#20745)

commit eb8e916
Author: Daniel Roe <daniel@roe.dev>
Date:   Tue May 9 16:57:23 2023 +0100

    fix(nuxt): generate empty sourcemaps for wrappers (nuxt#20744)

commit fd9b179
Author: Tom Lienard <tom.lienrd@gmail.com>
Date:   Tue May 9 17:41:02 2023 +0200

    docs: add lagon to presets list (nuxt#20706)

commit 1da25c8
Author: Daniel Roe <daniel@roe.dev>
Date:   Tue May 9 11:22:38 2023 +0100

    fix(nuxt): allow resolving client nuxt app to singleton (nuxt#20639)

commit ddbb847
Author: Daniel Roe <daniel@roe.dev>
Date:   Mon May 8 18:38:49 2023 +0100

    fix(webpack): warn when using deprecated `build.extend` hook (nuxt#20605)

commit a793e7a
Author: Daniel Roe <daniel@roe.dev>
Date:   Sat May 6 23:00:50 2023 +0100

    chore: type-check `.mjs` files (nuxt#20711)

commit 7cb4c69
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat May 6 09:44:07 2023 +0100

    feat(deps): upgrade to nitropack v2.4 (nuxt#20688)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Daniel Roe <daniel@roe.dev>

commit fa8b29a
Author: scscgit <scscgit@users.noreply.github.com>
Date:   Fri May 5 16:39:50 2023 +0200

    docs: recommend `<NuxtLayout>` when migrating `error.vue` (nuxt#20690)

commit ad97cb4
Author: Daniel Roe <daniel@roe.dev>
Date:   Fri May 5 13:53:49 2023 +0100

    chore: disallow `.only` in tests

commit 24c30eb
Author: darioferderber <dario.ferderber@broj42.com>
Date:   Fri May 5 15:50:06 2023 +0200

    docs: add `useSeoMeta` and `useServerSeoMeta` pages (nuxt#20656)

commit 2eee641
Author: Daniel Roe <daniel@roe.dev>
Date:   Fri May 5 11:41:01 2023 +0100

    chore: do not install example dependencies (nuxt#20689)

commit 4f0d3d4
Author: Daniel Roe <daniel@roe.dev>
Date:   Fri May 5 10:25:44 2023 +0100

    chore: ban `@ts-ignore`

commit 1f38863
Author: Anthony Fu <anthonyfu117@hotmail.com>
Date:   Thu May 4 18:19:03 2023 +0200

    fix(nuxt, vite): ignore `nuxt_component` ssr style and `isVue` (nuxt#20679)

commit 8c75961
Author: Daniel Roe <daniel@roe.dev>
Date:   Thu May 4 15:08:07 2023 +0100

    docs: ensure we guard all `navigateTo` examples (nuxt#20678)

commit 30132f3
Author: ClΓ©ment Ollivier <clement.o2p@gmail.com>
Date:   Thu May 4 12:52:46 2023 +0200

    docs: selective pre-rendering options (nuxt#20670)

commit 47591c9
Author: Daniel Roe <daniel@roe.dev>
Date:   Thu May 4 10:38:02 2023 +0100

    test: test with bundler module resolution (nuxt#20629)

    Co-authored-by: pooya parsa <pyapar@gmail.com>

commit c543ea8
Author: Jamie Warburton <jamie@hexdigital.com>
Date:   Thu May 4 09:58:39 2023 +0100

    docs: note that `useCookie` does not share state (nuxt#20665)

commit 0508ec2
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu May 4 07:22:18 2023 +0100

    chore(deps): update all non-major dependencies (main) (nuxt#20657)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Daniel Roe <daniel@roe.dev>
    Co-authored-by: pooya parsa <pyapar@gmail.com>

commit c586f02
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu May 4 05:52:16 2023 +0100

    chore(deps): update dependency cookie-es to v1 (main) (nuxt#20660)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit ca1cb61
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Thu May 4 05:51:44 2023 +0100

    chore(deps): update dependency perfect-debounce to v1 (main) (nuxt#20661)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 566fa85
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 3 15:14:12 2023 +0100

    fix(nuxt): run page meta plugin on all pages (and only pages) (nuxt#20628)

    Co-authored-by: Julien Huang <julien.huang@outlook.fr>

commit da33574
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 3 11:02:07 2023 +0100

    feat(nuxt): add `nuxtApp.runWithContext` (nuxt#20608)

commit a81f9e4
Author: Daniel Roe <daniel@roe.dev>
Date:   Wed May 3 09:51:00 2023 +0100

    ci: run 2.x nightly release on node 16

commit 3306cfe
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Wed May 3 07:00:29 2023 +0100

    chore(deps): update all non-major dependencies (main) (nuxt#20632)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit af75f18
Author: Daniel Roe <daniel@roe.dev>
Date:   Tue May 2 21:11:13 2023 +0100

    ci: run autofix on renovate branches

commit fb76b39
Author: Anthony Fu <anthonyfu117@hotmail.com>
Date:   Tue May 2 15:24:11 2023 +0200

    feat(nuxi): allow greater control of `nuxi analyze` from cli (nuxt#20387)

commit 84559e8
Author: Anthony Fu <anthonyfu117@hotmail.com>
Date:   Tue May 2 13:17:41 2023 +0200

    feat(kit): support passing getter to `addVitePlugin` and `addWebpackPlugin` (nuxt#20525)

commit 787d5e9
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Tue May 2 12:12:31 2023 +0100

    chore(deps): update dependency vite to v4.3.4 (main) (nuxt#20619)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

commit 16bf228
Author: Daniel Roe <daniel@roe.dev>
Date:   Mon May 1 23:55:24 2023 +0100

    fix(nuxt): ensure `useError` is called with nuxt app context (nuxt#20585)

commit 675445f
Author: Daniel Roe <daniel@roe.dev>
Date:   Mon May 1 23:48:11 2023 +0100

    chore: revert `markdownlint-cli` update and prevent auto-update

commit f3cfb5f
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Mon May 1 23:46:29 2023 +0100

    chore(deps): update all non-major dependencies (main) (nuxt#20609)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    Co-authored-by: Daniel Roe <daniel@roe.dev>
@github-actions github-actions bot mentioned this pull request May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

definePageMeta support for files added in pages:extend
4 participants