-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): safe-guard extraPageMetaExtractionKeys
#32510
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
Conversation
|
WalkthroughThe changes update the handling of the 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
extraPageMetaExtractionKeys
extraPageMetaExtractionKeys
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32510 will not alter performanceComparing Summary
|
packages/nuxt/src/pages/module.ts
Outdated
const extraPageMetaExtractionKeys = nuxt.options.experimental.extraPageMetaExtractionKeys | ||
const extractedKeys = [ | ||
...defaultExtractionKeys, | ||
'middleware', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emmm.. middleware
is also in defaultExtractionKeys
, does it need to remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, does it make sense to use defaultExtractionKeys
here as well?
It only contains 'middleware'
https://github.com/nuxt/nuxt/pull/32510/files#diff-c2594c96f1f7e8279fb8940560db036a9efa49e39522509ee02193dbac213092R77
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it seem that it maybe could also be deleted? But it doesn't matter with this.
nuxt/packages/nuxt/src/pages/utils.ts
Line 241 in d39f540
const extractionKeys = new Set<keyof NuxtPage>([...defaultExtractionKeys, ...extraExtractionKeys as Set<keyof NuxtPage>]) |
This is a nice check, but also highlights an issue with the wrong version of I have plans to fix/improve that (but for a start, |
const augmentCtx = { | ||
extraExtractionKeys: new Set(['middleware', ...nuxt.options.experimental.extraPageMetaExtractionKeys]), | ||
extraExtractionKeys: new Set([ | ||
'middleware', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danielroe maybe you know if defaultExtractionKeys
can be used here instead of just adding 'middleware'
? Came up here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it can't - we treat them slightly separately in terms of whether we remove them from the route metadata that's accessible at runtime from route.meta
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!!
packages/nuxt/src/pages/module.ts
Outdated
@@ -489,7 +489,12 @@ export default defineNuxtModule({ | |||
} | |||
|
|||
// Extract macros from pages | |||
const extractedKeys = [...defaultExtractionKeys, 'middleware', ...nuxt.options.experimental.extraPageMetaExtractionKeys] | |||
const extraPageMetaExtractionKeys = nuxt.options?.experimental?.extraPageMetaExtractionKeys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could probably just do:
const extraPageMetaExtractionKeys = nuxt.options?.experimental?.extraPageMetaExtractionKeys | |
const extraPageMetaExtractionKeys = nuxt.options?.experimental?.extraPageMetaExtractionKeys || [] |
... as the issue is presumably that it's not defined, rather than set to a string or something like that
thank you ❤️ |
🔗 Linked issue
This issue came up while checking the canary tests in Sentry Nuxt: getsentry/sentry-javascript#16762
Building the application resulted in this error:
nuxt.options.experimental.extraPageMetaExtractionKeys is not iterable
📚 Description
This PR creates a safeguard (
Array.isArray()
) before spreading the experimental value.