Skip to content

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 24, 2025

Reverts #13817

Summary by CodeRabbit

  • Bug Fixes

    • Improved Hot Module Replacement (HMR) reliability during development by ensuring the runtime initializes consistently. This reduces sporadic failures where updates wouldn’t apply, minimizes unexpected full reloads, and provides more predictable live updates across edits.
  • Refactor

    • Simplified the HMR runtime initialization logic to streamline behavior and reduce edge cases encountered in development environments, leading to a more stable and consistent hot-reload experience.

Copy link

coderabbitai bot commented Sep 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The HMR runtime initialization in packages/runtime-core/src/hmr.ts now unconditionally assigns VUE_HMR_RUNTIME on the global object using tryWrap(createRecord, rerender, reload), removing the previous guard that preserved any existing runtime.

Changes

Cohort / File(s) Change Summary
HMR Runtime Init
packages/runtime-core/src/hmr.ts
Switched from guarded global initialization of __VUE_HMR_RUNTIME__ to unconditional assignment, always setting { createRecord, rerender, reload } wrapped via tryWrap.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Application Startup
  participant Global as Global Object
  participant HMR as __VUE_HMR_RUNTIME__

  rect rgba(230,240,255,0.5)
  note over App,Global: Initialization phase (modified)
  App->>Global: Assign __VUE_HMR_RUNTIME__ = tryWrap({createRecord, rerender, reload})
  activate Global
  Global->>HMR: Overwrite or create runtime object
  deactivate Global
  end

  note over HMR: Runtime API available regardless of prior value
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

scope: hmr

Poem

A hare hops in hot-reload light,
Flips the switch—overwrite on sight.
No more peeking, “is it there?”
Just set and bound, with cautious care.
tryWrap snug as twilight’s glove—
HMR warms the code I love. 🐇⚡️

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-13817-edison/fix/hmrOverride

📜 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 8bb8fb2 and 618ac3f.

📒 Files selected for processing (1)
  • packages/runtime-core/src/hmr.ts (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@edison1105 edison1105 merged commit 6b68f72 into main Sep 24, 2025
14 of 16 checks passed
@edison1105 edison1105 deleted the revert-13817-edison/fix/hmrOverride branch September 24, 2025 10:02
Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 102 kB 38.6 kB 34.7 kB
vue.global.prod.js 160 kB 58.7 kB 52.3 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.7 kB 18.3 kB 16.7 kB
createApp 54.7 kB 21.3 kB 19.5 kB
createSSRApp 58.9 kB 23 kB 21 kB
defineCustomElement 60 kB 23 kB 20.9 kB
overall 68.8 kB 26.5 kB 24.2 kB

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