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

Skip to content

Conversation

ShenQingchuan
Copy link
Member

@ShenQingchuan ShenQingchuan commented Aug 12, 2025

I found that using a component in template after importing a component from a new .vine.ts file doesn't trigger HMR.
So this is a fix with E2E test.

Summary by CodeRabbit

  • New Features

    • Hot Module Replacement (HMR) now supports newly added component files without requiring a full reload.
    • Smarter dependency analysis enables more targeted updates and faster refresh cycles.
  • Bug Fixes

    • Improved reliability of HMR updates, reducing unexpected full reloads.
    • Better state preservation across edits and component introductions.
  • Refactor

    • Reorganized HMR logic into a dedicated manager for greater stability and maintainability.
  • Tests

    • Added end-to-end coverage for creating, importing, and updating new components during HMR.

Copy link

netlify bot commented Aug 12, 2025

Deploy Preview for vue-vine ready!

Name Link
🔨 Latest commit 579c71e
🔍 Latest deploy log https://app.netlify.com/projects/vue-vine/deploys/689b0ce55e030b00089f5892
😎 Deploy Preview https://deploy-preview-303--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.

Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Refactors Vine HMR into a dedicated manager with dependency analysis, updates Vite plugin hot-update flow to delegate to the manager, and adds ts-morph support for newly created files. E2E tests gain file-creation/deletion helpers and a new scenario covering HMR when introducing new Vine files.

Changes

Cohort / File(s) Summary of changes
E2E tests and utilities
packages/e2e-test/tests/hmr.spec.ts, packages/e2e-test/utils/test-utils.ts
Add createFile/deleteFile helpers; extend HMR test to create/import a new component file, verify HMR updates, and clean up fixtures.
HMR core refactor
packages/vite-plugin/src/hmr/dependency-analyzer.ts, packages/vite-plugin/src/hmr/index.ts, packages/vite-plugin/src/hot-update.ts
Introduce ComponentDependencyAnalyzer and VineHMRManager; move HMR orchestration into new module; hot-update now re-exports manager and wraps legacy vineHMR to delegate to the manager.
Plugin integration update
packages/vite-plugin/src/index.ts
handleHotUpdate now handles files newly added to the ts-morph project; ensures Vite module graph entry; updates or creates SourceFile accordingly.

Sequence Diagram(s)

sequenceDiagram
  participant Vite as Vite Dev Server
  participant HMR as VineHMRManager
  participant Analyzer as ComponentDependencyAnalyzer
  participant Compiler as Vine Compiler
  participant Graph as Vite Module Graph

  Vite->>HMR: handleHMR(ctx, compilerCtx, hooks)
  HMR->>Compiler: Re-parse/reanalyze Vine file(s)
  HMR->>Analyzer: analyzeDependencies(fileCtx)
  Analyzer-->>HMR: Dependency graph/topo order
  HMR->>Graph: Invalidate/ensure modules (incl. new files)
  HMR-->>Vite: Modules to update or full reload
Loading
sequenceDiagram
  participant Vite as Vite handleHotUpdate
  participant TS as ts-morph Project
  participant Graph as Vite Module Graph

  Vite->>TS: get SourceFile(ctx.file)?
  alt exists
    Vite->>TS: replaceWithText(updatedContent)
  else
    Vite->>TS: createSourceFile(ctx.file, updatedContent)
    Vite->>Graph: ensureEntryFromUrl(ctx.file)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

In hot-reload meadows I hop with glee,
New files sprout, and vines agree.
A manager guides the warming breeze,
Graphs and modules sway with ease.
Click—refresh! The leaves don’t fall—
HMR hums; I thump, “That’s all!” 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eec9a7b and 579c71e.

📒 Files selected for processing (6)
  • packages/e2e-test/tests/hmr.spec.ts (3 hunks)
  • packages/e2e-test/utils/test-utils.ts (1 hunks)
  • packages/vite-plugin/src/hmr/dependency-analyzer.ts (1 hunks)
  • packages/vite-plugin/src/hmr/index.ts (1 hunks)
  • packages/vite-plugin/src/hot-update.ts (2 hunks)
  • 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 refactor/hmr-improve

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.

@ShenQingchuan ShenQingchuan merged commit e4228c5 into main Aug 12, 2025
8 of 10 checks passed
@ShenQingchuan ShenQingchuan deleted the refactor/hmr-improve branch August 12, 2025 09:44
Copy link

pkg-pr-new bot commented Aug 12, 2025

Open in StackBlitz

@vue-vine/compiler

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

create-vue-vine

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

@vue-vine/eslint-config

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

@vue-vine/eslint-parser

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

@vue-vine/eslint-plugin

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

@vue-vine/language-server

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

@vue-vine/language-service

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

@vue-vine/nuxt

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

vue-vine-tsc

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

@vue-vine/vite-plugin

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

vue-vine

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

commit: 579c71e

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