Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

ShenQingchuan
Copy link
Member

@ShenQingchuan ShenQingchuan commented Aug 16, 2025

Since ts-morph action may cause panic on HMR, it's more robust to add a try-catch here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of TypeScript hot module updates by handling processing errors gracefully instead of crashing.
    • Displays clear, formatted error messages in the console when an update fails, aiding quick diagnosis while keeping the dev server running.
    • Ensures new or changed TypeScript files continue to update the module graph correctly during HMR, reducing unexpected interruptions during development.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds try-catch around ts-morph updates in handleHotUpdate for TypeScript files. On errors, reports via this.error. Keeps existing behavior: create new SourceFile and ensure Vite module graph entry for new files; replace content for existing files. No public API changes.

Changes

Cohort / File(s) Summary
Vite plugin HMR ts-morph error handling
packages/vite-plugin/src/index.ts
Wraps ts-morph update logic in try-catch during handleHotUpdate; logs formatted errors via this.error. Preserves logic to create SourceFile and ensure Vite module graph for new TS files, or update contents for existing ones. No exported signatures changed.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Vite as Vite HMR
  participant Plugin as Vite Plugin
  participant TS as ts-morph

  Dev->>Vite: Save TS file
  Vite->>Plugin: handleHotUpdate(file, content)
  Plugin->>Plugin: try { ... }
  alt New TS file
    Plugin->>TS: createSourceFile(path, content)
    Plugin->>Vite: ensure module graph entry
  else Existing TS file
    Plugin->>TS: replace text with content
  end
  Plugin-->>Vite: continue HMR pipeline
  opt Error
    Plugin->>Plugin: catch(e)
    Plugin->>Vite: this.error(formatted message)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I nibble cables, ears alert and bright,
Hot updates hop—now guarded in their flight.
If ts-morph trips, I squeak, “Error! Beware!”
Then thump the log with structured, careful care.
Code burrows safe, no panic in the night. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 629f1f1 and 0fd9309.

📒 Files selected for processing (1)
  • packages/vite-plugin/src/index.ts (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch next-patch

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Aug 16, 2025

Deploy Preview for vue-vine ready!

Name Link
🔨 Latest commit 0fd9309
🔍 Latest deploy log https://app.netlify.com/projects/vue-vine/deploys/68a09b6e0a2f8000082ae311
😎 Deploy Preview https://deploy-preview-305--vue-vine.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ShenQingchuan ShenQingchuan merged commit 55047ad into main Aug 16, 2025
14 of 16 checks passed
Copy link

pkg-pr-new bot commented Aug 16, 2025

Open in StackBlitz

@vue-vine/compiler

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/compiler@305

create-vue-vine

npm i https://pkg.pr.new/vue-vine/vue-vine/create-vue-vine@305

@vue-vine/eslint-config

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/eslint-config@305

@vue-vine/eslint-parser

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/eslint-parser@305

@vue-vine/eslint-plugin

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/eslint-plugin@305

@vue-vine/language-server

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/language-server@305

@vue-vine/language-service

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/language-service@305

@vue-vine/nuxt

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/nuxt@305

vue-vine-tsc

npm i https://pkg.pr.new/vue-vine/vue-vine/vue-vine-tsc@305

@vue-vine/vite-plugin

npm i https://pkg.pr.new/vue-vine/vue-vine/@vue-vine/vite-plugin@305

vue-vine

npm i https://pkg.pr.new/vue-vine/vue-vine@305

commit: 0fd9309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant