fix: TDZ violation in lazy-hydration plugin with .client components#265
fix: TDZ violation in lazy-hydration plugin with .client components#265huang-julien merged 2 commits intomainfrom
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request changes src/plugins/lazy-load.ts to insert wrapper statements immediately after each individual component import (per-import append) instead of aggregating wrappers and appending them once after imports. Existing logic for renaming original imports, injecting tracking imports, and applying component-specific wrappers in setups is unchanged. Tests were added to test/unit/hydration/lazy-hydration-plugin.test.ts to validate TDZ safety and wrapper placement across single/multiple imports, auto-imported components, and .client.vue variants; the test additions include duplicated blocks in the patch. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/unit/hydration/lazy-hydration-plugin.test.ts (1)
214-237: Consider adding assertion for non-overlapping wrapper positions.The test verifies each wrapper is between its import and usage, but doesn't explicitly verify
wrapperALine !== wrapperBLineor that wrappers don't overlap. This is likely fine since the string comparison is implicit, but an explicit assertion could catch edge cases where both wrappers accidentally get inserted at the same position.🔧 Optional: Add non-overlap assertion
expect(wrapperBLine).toBeGreaterThan(importBLine) expect(wrapperBLine).toBeLessThan(someWrapperBLine) + // Ensure wrappers are in import order (A before B) + expect(wrapperALine).toBeLessThan(wrapperBLine) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/unit/hydration/lazy-hydration-plugin.test.ts` around lines 214 - 237, Add an explicit non-overlap assertion to ensure the inserted wrappers don't occupy the same line: assert that wrapperALine !== wrapperBLine; additionally, if you want to guarantee preserved order, assert the wrappers follow the import order (e.g., if importALine < importBLine then expect(wrapperALine).toBeLessThan(wrapperBLine)). Use the existing variables importALine, importBLine, wrapperALine and wrapperBLine to implement these checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/unit/hydration/lazy-hydration-plugin.test.ts`:
- Around line 214-237: Add an explicit non-overlap assertion to ensure the
inserted wrappers don't occupy the same line: assert that wrapperALine !==
wrapperBLine; additionally, if you want to guarantee preserved order, assert the
wrappers follow the import order (e.g., if importALine < importBLine then
expect(wrapperALine).toBeLessThan(wrapperBLine)). Use the existing variables
importALine, importBLine, wrapperALine and wrapperBLine to implement these
checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9f4b8aaf-5808-49ee-8063-b9c51372ebd1
📒 Files selected for processing (2)
src/plugins/lazy-load.tstest/unit/hydration/lazy-hydration-plugin.test.ts
🔗 Linked issue
📚 Description