-
-
Notifications
You must be signed in to change notification settings - Fork 102
feat: add auto-hmr-plugin and autoHmr option #655
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new plugin for automatic Vue Router HMR integration was added. The main plugin now conditionally includes this HMR plugin based on a new Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (9)
✨ Finishing Touches
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 (
|
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: 1
♻️ Duplicate comments (1)
src/auto-hmr/index.ts (1)
77-77
: Regex reliability concern.Same issue as line 35 - regex matching in code can be unreliable.
🧹 Nitpick comments (1)
src/auto-hmr/index.ts (1)
35-35
: Consider regex reliability.The regex
/handleHotUpdate\([\s\S]*?\)/
may match unintended occurrences like comments or strings. Consider using AST-based detection instead.- const handleHotUpdateCallRegex = /handleHotUpdate\([\s\S]*?\)/
Use AST parsing to detect function calls more reliably:
function hasHandleHotUpdateCall(ast: any): boolean { // Walk AST to find CallExpression with callee.name === 'handleHotUpdate' }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/auto-hmr/index.ts
(1 hunks)src/index.ts
(2 hunks)src/options.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/index.ts (2)
src/auto-hmr/index.ts (1)
createAutoHmrPlugin
(34-101)src/core/moduleConstants.ts (1)
MODULE_ROUTES_PATH
(6-6)
🔇 Additional comments (11)
src/options.ts (1)
216-220
: LGTM!Clean addition of the new option with proper documentation.
src/index.ts (2)
24-24
: Clean import addition.
206-212
: Good integration pattern.Follows the same conditional plugin inclusion pattern as the experimental autoExportsDataLoaders.
src/auto-hmr/index.ts (8)
4-6
: Helper function is correct.
8-15
: Router detection logic is sound.
17-28
: Import detection logic is correct.
42-42
: Virtual module filtering is correct.
46-48
: Early return optimization is good.
82-86
: Import injection looks correct.
89-91
: Function call injection is correct.
93-95
: Code transformation approach is sound.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This reverts commit 7abc277.
@coderabbitai review |
✅ Actions performedReview triggered.
|
reimpl: #617
This pr is similar to the implementation of vuejs/pinia#2954, which transfers the work of automatically injecting hmr code to the plugin part, and adds an option to control whether the plugin is enabled or not.
Summary by CodeRabbit