Skip to content

Conversation

@colinaaa
Copy link
Collaborator

@colinaaa colinaaa commented Oct 13, 2025

Summary by CodeRabbit

  • Improvements

    • Dev servers now respect dev.hmr and dev.liveReload settings when deciding whether to load hot clients.
    • When both are disabled, hot clients are not loaded; when only HMR is disabled, CSS HMR is off but live reload remains active.
  • Tests

    • Added tests verifying hot client behavior when HMR and/or live reload are disabled.
  • Chores

    • Prepared a patch version bump with a changeset entry.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: d6cf5e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/react-alias-rsbuild-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

📝 Walkthrough

Walkthrough

Implements conditional loading of dev hot clients based on environment.config.dev.hmr and liveReload. Updates plugin-react development entry logic accordingly, adds tests for both disabled and partial HMR scenarios, and includes a changeset to bump @lynx-js/react-rsbuild-plugin with a patch.

Changes

Cohort / File(s) Summary
Versioning / Changeset
/.changeset/cold-frogs-flash.md
Adds a changeset for a patch release noting dev servers now respect dev.hmr and dev.liveReload when loading hot clients.
Plugin logic
packages/rspeedy/plugin-react/src/entry.ts
Extracts hmr/liveReload from environment.config.dev; updates dev entry condition to isDev && !isWeb && !(hmr === false && liveReload === false); gates dev-server, webpack-dev-transport, and react/refresh prepends on this condition.
Tests
packages/rspeedy/plugin-react/test/config.test.ts
Adds tests covering: both hmr and liveReload false (no hot clients), and hmr false with liveReload true (CSS HMR off, live reload on).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

framework:React

Suggested reviewers

  • gaoachao
  • upupming
  • Yradex

Poem

I twitch my ears at dev-time cheer,
When HMR naps, live reload draws near.
Two toggles blink, I hop and think—
Load the hot clients, or don’t, in sync.
Patch bumps squeak, tests thump their beat,
Carrot-approved configs: neat! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title directly highlights the main change of injecting hot clients only under the new hmr/liveReload conditions and concisely summarizes the behavioral fix introduced in the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e42b906 and d6cf5e4.

📒 Files selected for processing (3)
  • .changeset/cold-frogs-flash.md (1 hunks)
  • packages/rspeedy/plugin-react/src/entry.ts (3 hunks)
  • packages/rspeedy/plugin-react/test/config.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/cold-frogs-flash.md
🧬 Code graph analysis (2)
packages/rspeedy/plugin-react/test/config.test.ts (1)
packages/rspeedy/plugin-react/src/pluginReactLynx.ts (1)
  • pluginReactLynx (282-394)
packages/rspeedy/plugin-react/src/entry.ts (2)
packages/webpack/webpack-dev-transport/client/index.ts (1)
  • liveReload (72-78)
packages/webpack/react-webpack-plugin/src/index.ts (1)
  • LAYERS (15-15)
🔇 Additional comments (6)
.changeset/cold-frogs-flash.md (1)

1-5: LGTM!

The changeset accurately documents the behavioral change for honoring dev.hmr and dev.liveReload configuration options.

packages/rspeedy/plugin-react/src/entry.ts (3)

66-66: LGTM!

The nullish coalescing operator safely handles cases where environment.config.dev is undefined or null, defaulting both hmr and liveReload to undefined, which enables the default behavior of loading hot clients.


121-132: LGTM!

The condition correctly gates CSS HMR on the hmr setting. When hmr is undefined (not configured), CSS HMR is enabled by default, which maintains backward compatibility while allowing explicit disabling via hmr: false.


142-163: LGTM with suggestion for additional test coverage.

The conditional logic correctly implements the requirement: hot clients are loaded unless both hmr and liveReload are explicitly set to false. This maintains backward compatibility (default behavior with undefined values) while allowing granular control.

The logic allows these scenarios:

  • Default (both undefined): hot clients loaded
  • hmr: false, liveReload: true: live reload only (no HMR)
  • hmr: false, liveReload: false: no hot clients at all

Consider adding a test case for the default behavior (neither hmr nor liveReload explicitly configured) to ensure backward compatibility is maintained. The existing test at line 1329 ("Defaults in development") should already cover this, but explicitly documenting it as testing the default hot client behavior would improve clarity.

packages/rspeedy/plugin-react/test/config.test.ts (2)

1426-1467: LGTM!

The test correctly validates that when both hmr and liveReload are explicitly set to false, no hot clients are added to the entries. The assertions comprehensively check both the background and main-thread entries.


1469-1511: LGTM!

The test correctly validates the scenario where hmr: false disables CSS HMR (main__main-thread) while liveReload: true keeps the hot clients active (dev-server, webpack-dev-transport, react/refresh in the main entry). This confirms the granular control implementation works as intended.


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

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

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@relativeci
Copy link

relativeci bot commented Oct 13, 2025

Web Explorer

#5883 Bundle Size — 364.58KiB (0%).

d6cf5e4(current) vs e42b906 main#5880(baseline)

Bundle metrics  Change 1 change
                 Current
#5883
     Baseline
#5880
No change  Initial JS 144.53KiB 144.53KiB
No change  Initial CSS 32.11KiB 32.11KiB
Change  Cache Invalidation 0% 48.44%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 219(-0.45%) 220
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.23% 3.23%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5883
     Baseline
#5880
No change  JS 238.67KiB 238.67KiB
No change  Other 93.8KiB 93.8KiB
No change  CSS 32.11KiB 32.11KiB

Bundle analysis reportBranch colinaaa:colin/1013/dev-entriesProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link

relativeci bot commented Oct 13, 2025

React Example

#5887 Bundle Size — 237.56KiB (0%).

d6cf5e4(current) vs e42b906 main#5884(baseline)

Bundle metrics  no changes
                 Current
#5887
     Baseline
#5884
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 166 166
No change  Duplicate Modules 68 68
No change  Duplicate Code 46.82% 46.82%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5887
     Baseline
#5884
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.8KiB 91.8KiB

Bundle analysis reportBranch colinaaa:colin/1013/dev-entriesProject dashboard


Generated by RelativeCIDocumentationReport issue

@colinaaa colinaaa marked this pull request as ready for review October 13, 2025 12:43
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 13, 2025

CodSpeed Performance Report

Merging #1885 will improve performances by 13.82%

Comparing colinaaa:colin/1013/dev-entries (d6cf5e4) with main (e42b906)

Summary

⚡ 2 improvements
✅ 51 untouched
⏩ 3 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
transform 1000 view elements 45 ms 39.6 ms +13.82%
basic-performance-div-100 6.6 ms 6.1 ms +9.41%

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@colinaaa colinaaa requested a review from upupming October 13, 2025 12:55
Comment on lines +158 to +161
.prepend({
layer: LAYERS.BACKGROUND,
import: '@lynx-js/react/refresh',
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think@lynx-js/react/refresh is only needed on HMR, am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants