-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): use klona to deep clone extractedMeta #30717
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 pull request introduces changes to the The changes impact three primary files: These modifications enhance the robustness of metadata handling in the Nuxt page routing system by implementing safer object cloning techniques and expanding test coverage. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (20)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
@nuxt/kit
@nuxt/rspack-builder
nuxt
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #30717 will not alter performanceComparing Summary
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/nuxt/test/pages.test.ts (2)
841-854
: Consider enhancing test coverage and clarity.While the test effectively verifies the basic functionality, consider these improvements:
- Use more realistic path names (e.g., '/about', '/about-team', '/about-company')
- Use more descriptive metadata properties that reflect real use cases
- Add test cases for error scenarios (e.g., conflicting metadata)
const files: NuxtPage[] = [ - { path: 'home', file: `pages/index.vue` }, - { path: 'home1', file: `pages/index.vue`, meta: { test: true } }, - { path: 'home2', file: `pages/index.vue`, meta: { snap: true } }, + { path: 'about', file: `pages/index.vue` }, + { path: 'about-team', file: `pages/index.vue`, meta: { layout: 'team' } }, + { path: 'about-company', file: `pages/index.vue`, meta: { layout: 'company' } }, ]
856-872
: Enhance assertion specificity.Consider adding more specific assertions to verify:
- The shared file content (definePageMeta) is correctly applied to all routes
- The metadata isolation between routes is maintained
await augmentPages(files, vfs) +// Verify shared content is applied +for (const file of files) { + expect(file.meta).toHaveProperty(DYNAMIC_META_KEY) + expect(file.meta[DYNAMIC_META_KEY]).toBeInstanceOf(Set) + expect(file.meta[DYNAMIC_META_KEY].has('meta')).toBe(true) +} + +// Verify metadata isolation +expect(files[1].meta).not.toEqual(files[2].meta) + expect(files).toEqual([ { path: 'home',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/nuxt/test/pages.test.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, rspack, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, rspack, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, js, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, 18)
- GitHub Check: typecheck (windows-latest, node)
- GitHub Check: test-benchmark
- GitHub Check: typecheck (windows-latest, bundler)
- GitHub Check: release-pr
- GitHub Check: typecheck (ubuntu-latest, node)
- GitHub Check: typecheck (ubuntu-latest, bundler)
🔇 Additional comments (1)
packages/nuxt/test/pages.test.ts (1)
838-874
: Well-structured test suite for page extension functionality.The test suite effectively verifies the handling of route metadata when multiple entries reference the same file but have different metadata configurations. The implementation follows good testing practices with clear setup and assertions.
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/nuxt/test/pages.test.ts (2)
840-845
: Consider renaming the test to enhance clarity.
Although the current test name is acceptable, a more descriptive name (e.g. “should preserve distinct metadata for multiple routes referencing the same file”) may convey the scenario more clearly.Here is a possible update:
- it('should correct route metadata by same file with different metadata', async () => { + it('should preserve distinct metadata for multiple routes referencing the same file', async () => {
856-873
: Confirm the correctness of deep object comparisons.
toEqual
is acceptable for this scenario, but if more exact checking is needed (especially for object prototype verifications),toStrictEqual
could be used. For now, this is sufficiently robust.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/nuxt/test/pages.test.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (18)
- GitHub Check: test-fixtures (windows-latest, built, rspack, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, webpack, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, rspack, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, rspack, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, js, 18)
- GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-on, json, 18)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, 18)
- GitHub Check: typecheck (windows-latest, node)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, 18)
- GitHub Check: typecheck (windows-latest, bundler)
- GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, 18)
- GitHub Check: test-benchmark
🔇 Additional comments (2)
packages/nuxt/test/pages.test.ts (2)
838-839
: Test suite appears well-structured.
No issues identified with the creation of thepage:extends
suite or the constant declaration.
846-855
: Virtual file system usage is effective.
The approach for constructing the virtual file system and passing it toaugmentPages
is clean. There are no concurrency or performance concerns here.
🔗 Linked issue
resolves #30695
📚 Description
I think add a unique cacheKey with
hash(route)
could resolve this?If has any other idea, please tell me. Thank you very much.