Skip to content

feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config#1882

Merged
colinaaa merged 2 commits intolynx-family:mainfrom
luhc228:feat/apply-hmr-liveReload-to-rsbuild-config
Oct 12, 2025
Merged

feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config#1882
colinaaa merged 2 commits intolynx-family:mainfrom
luhc228:feat/apply-hmr-liveReload-to-rsbuild-config

Conversation

@luhc228
Copy link
Copy Markdown
Collaborator

@luhc228 luhc228 commented Oct 11, 2025

Related PR: #458

If we set dev.hmr or dev.liveReload to false in lynx.config.js:

import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  dev: {
    hmr: false,
    liveReload: false,
  }
})

Now we will get different value of dev.hmr and dev.liveReload in rsbuild plugin:

function myRsbuildPlugin(api) {
  // first way
  // this config is user config
  const { config } = api.useExposed(Symbol.for('rspeedy.api'))!
  console.log(config.dev.hmr, config.dev.liveReload) // false false

  // second way
  // from environment config
  api.modifyBundlerChain((chain, { environment }) => {
    const { config } = environment
    console.log(config.dev.hmr, config.dev.liveReload) // true true
  })
}

We can also set these two config in environment config and above can't read the real value by the first way above:

import { defineConfig } from '@lynx-js/rspeedy'

export default defineConfig({
  environment: {
    lynx: {
      hmr: false,
      liveReload: false,
    }
  }
})

I think Rspeedy should apply the two configs to rsbuild config and other plugins should read the config from environment.config first.

Summary by CodeRabbit

  • New Features
    • Development builds now default to Hot Module Replacement (HMR) and Live Reload enabled when not explicitly configured; these flags honor environment-specific overrides.
  • Tests
    • Expanded coverage to verify dev.hmr and dev.liveReload behavior, including environment-specific override cases.
  • Chores
    • Added a changeset to publish a patch release reflecting the default dev.hmr and dev.liveReload settings.

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).

@luhc228 luhc228 requested a review from colinaaa as a code owner October 11, 2025 12:48
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Oct 11, 2025

🦋 Changeset detected

Latest commit: 8bb39c3

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

This PR includes changesets to release 3 packages
Name Type
@lynx-js/rspeedy Patch
create-rspeedy Patch
upgrade-rspeedy 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

@luhc228 luhc228 requested review from gaoachao and upupming October 11, 2025 12:49
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 11, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Reads HMR and live-reload settings from environment-specific config (defaulting to true), adds defaults for dev.hmr and dev.liveReload in RSBuild config generation, adds tests covering environment-derived overrides, and introduces a patch changeset for @lynx-js/rspeedy. No public API changes.

Changes

Cohort / File(s) Summary
Release metadata
\.changeset/dull-kiwis-like.md
Adds a patch-level changeset for @lynx-js/rspeedy documenting the dev.hmr/dev.liveReload patch.
RSBuild config defaults
packages/rspeedy/core/src/config/rsbuild/index.ts
Ensure dev.hmr and dev.liveReload default to true when not provided in generated rsbuild config.
Dev plugin behavior
packages/rspeedy/core/src/plugins/dev.plugin.ts
Switch source of HMR/liveReload flags to environment-scoped config (environment.config.dev?.hmr / environment.config.dev?.liveReload) when building dev server search params; values still emitted as "true"/"false" strings.
Tests: dev plugin env overrides
packages/rspeedy/core/test/plugins/dev.plugin.test.ts
Add tests asserting the dev transport alias/searchParam reflects environment-driven hmr and liveReload (true/false cases).
Tests: rsbuild snapshot
packages/rspeedy/core/test/config/rsbuild.test.ts
Update snapshot/expectation: when dev is undefined, emitted rsbuildConfig.dev now contains hmr: true and liveReload: true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • upupming
  • gaoachao

Poem

A rabbit hops through lines of code,
Tucks HMR and reload in a cozy node.
Env flags twinkle, tests give a cheer,
Patch in the burrow — release is near! 🥕🐇

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 succinctly captures the primary change by indicating that the dev.hmr and dev.liveReload settings are now applied to the Rsbuild configuration, accurately reflecting the core intent of the pull request.

📜 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 06899f5 and 8bb39c3.

📒 Files selected for processing (1)
  • packages/rspeedy/core/src/config/rsbuild/index.ts (1 hunks)

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/dull-kiwis-like.md (1)

5-5: Consider expanding the changeset description.

The current description is concise but could be more informative for users reviewing release notes. Consider adding context about what this fixes or why it matters.

For example:

-Should apply `dev.hmr` and `dev.liveReload` to Rsbuild config.
+Fix inconsistency where `dev.hmr` and `dev.liveReload` config values differ when accessed via the exposed user config versus environment config in Rsbuild plugins. These settings now default to `true` in the Rsbuild config, ensuring consistent behavior across plugin access methods.
📜 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 85a8b58 and e14b458.

📒 Files selected for processing (3)
  • .changeset/dull-kiwis-like.md (1 hunks)
  • packages/rspeedy/core/src/config/rsbuild/index.ts (1 hunks)
  • packages/rspeedy/core/test/plugins/dev.plugin.test.ts (5 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/dull-kiwis-like.md
🧠 Learnings (1)
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
PR: lynx-family/lynx-stack#1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.

Applied to files:

  • .changeset/dull-kiwis-like.md
🧬 Code graph analysis (1)
packages/rspeedy/core/test/plugins/dev.plugin.test.ts (1)
packages/rspeedy/core/test/createStubRspeedy.ts (1)
  • createStubRspeedy (20-64)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
  • GitHub Check: zizmor
🔇 Additional comments (7)
packages/rspeedy/core/src/config/rsbuild/index.ts (1)

27-28: LGTM!

The addition of default values for hmr and liveReload correctly addresses the inconsistency described in the PR objectives. Defaulting both to true aligns with standard development server expectations and ensures these values are consistently available in the Rsbuild config for other plugins to read from environment.config.

packages/rspeedy/core/test/plugins/dev.plugin.test.ts (6)

433-433: LGTM!

Good addition to verify the default hmr value is accessible via the public getRsbuildConfig() API, addressing the inconsistency noted in the PR objectives.

Also applies to: 439-439


450-450: LGTM!

Correctly verifies that explicitly setting hmr: false is reflected in the public Rsbuild config.

Also applies to: 456-456


467-467: LGTM!

Properly tests explicit hmr: true configuration through the public API.

Also applies to: 473-473


480-480: LGTM!

Good coverage for the default liveReload behavior via getRsbuildConfig().

Also applies to: 486-486


497-497: LGTM!

Correctly validates that liveReload: false is accessible through the public config API.

Also applies to: 503-503


514-514: LGTM!

Appropriate test coverage for explicit liveReload: true configuration.

Also applies to: 520-520

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@luhc228 luhc228 changed the title feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config [WIP] feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config Oct 11, 2025
@luhc228 luhc228 marked this pull request as draft October 11, 2025 12:54
@luhc228 luhc228 changed the title [WIP] feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config feat(rspeedy): apply dev.hmr and dev.liveReload config to Rsbuild config Oct 11, 2025
@relativeci
Copy link
Copy Markdown

relativeci bot commented Oct 11, 2025

React Example

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

8bb39c3(current) vs dd7c14a main#5878(baseline)

Bundle metrics  no changes
                 Current
#5879
     Baseline
#5878
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
#5879
     Baseline
#5878
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.8KiB 91.8KiB

Bundle analysis reportBranch luhc228:feat/apply-hmr-liveReloa...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Oct 11, 2025

Web Explorer

#5874 Bundle Size — 364.46KiB (0%).

8bb39c3(current) vs dd7c14a main#5873(baseline)

Bundle metrics  Change 1 change
                 Current
#5874
     Baseline
#5873
No change  Initial JS 144.52KiB 144.52KiB
No change  Initial CSS 32KiB 32KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 220(+0.46%) 219
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
#5874
     Baseline
#5873
No change  JS 238.66KiB 238.66KiB
No change  Other 93.8KiB 93.8KiB
No change  CSS 32KiB 32KiB

Bundle analysis reportBranch luhc228:feat/apply-hmr-liveReloa...Project dashboard


Generated by RelativeCIDocumentationReport issue

@luhc228 luhc228 force-pushed the feat/apply-hmr-liveReload-to-rsbuild-config branch from e14b458 to 0911c3f Compare October 11, 2025 13:01
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 11, 2025

CodSpeed Performance Report

Merging #1882 will degrade performances by 6.35%

Comparing luhc228:feat/apply-hmr-liveReload-to-rsbuild-config (8bb39c3) with main (820b3f9)

Summary

❌ 2 regressions
✅ 51 untouched
⏩ 3 skipped1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
basic-performance-image-100 9.8 ms 10.4 ms -6.35%
basic-performance-small-css 6.9 ms 7.3 ms -5.39%

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.

@luhc228 luhc228 marked this pull request as ready for review October 11, 2025 13:04
@luhc228 luhc228 force-pushed the feat/apply-hmr-liveReload-to-rsbuild-config branch from 0911c3f to 06899f5 Compare October 11, 2025 23:48
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/rspeedy/core/test/plugins/dev.plugin.test.ts (1)

489-506: Standardize test naming for consistency.

The test names have minor inconsistencies:

  • Line 455 uses "environment.dev.hmr: false" (with dot)
  • Line 489 uses "environment dev.hmr: true" (without dot)
  • Line 534 uses "environment dev.liveReload: false" (without dot)
  • Line 568 uses "environments dev.liveReload: true" (plural, without dot)

The test logic is correct, but for consistency, consider standardizing the naming convention. Either use "environment.dev" with a dot throughout, or "environment dev" without a dot, and keep "environment" singular.

Apply this diff to standardize the naming:

-  test('environment dev.hmr: true', async () => {
+  test('environment.dev.hmr: true', async () => {
     const rsbuild = await createStubRspeedy({
       environments: {
         lynx: {
           dev: {
             hmr: true,
           },
         },
       },
     })

     const config = await rsbuild.unwrapConfig()

     expect(config.resolve?.alias).toHaveProperty(
       '@lynx-js/webpack-dev-transport/client',
       expect.stringContaining('hot=true'),
     )
   })

-  test('environment dev.liveReload: false', async () => {
+  test('environment.dev.liveReload: false', async () => {
     const rsbuild = await createStubRspeedy({
       environments: {
         lynx: {
           dev: {
             liveReload: false,
           },
         },
       },
     })

     const config = await rsbuild.unwrapConfig()

     expect(config.resolve?.alias).toHaveProperty(
       '@lynx-js/webpack-dev-transport/client',
       expect.stringContaining('live-reload=false'),
     )
   })

-  test('environments dev.liveReload: true', async () => {
+  test('environment.dev.liveReload: true', async () => {
     const rsbuild = await createStubRspeedy({
       environments: {
         lynx: {
           dev: {
             liveReload: true,
           },
         },
       },
     })

     const config = await rsbuild.unwrapConfig()

     expect(config.resolve?.alias).toHaveProperty(
       '@lynx-js/webpack-dev-transport/client',
       expect.stringContaining('live-reload=true'),
     )
   })

Also applies to: 534-551, 568-585

📜 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 0911c3f and 06899f5.

📒 Files selected for processing (5)
  • .changeset/dull-kiwis-like.md (1 hunks)
  • packages/rspeedy/core/src/config/rsbuild/index.ts (1 hunks)
  • packages/rspeedy/core/src/plugins/dev.plugin.ts (1 hunks)
  • packages/rspeedy/core/test/config/rsbuild.test.ts (1 hunks)
  • packages/rspeedy/core/test/plugins/dev.plugin.test.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/rspeedy/core/src/plugins/dev.plugin.ts
  • packages/rspeedy/core/src/config/rsbuild/index.ts
  • .changeset/dull-kiwis-like.md
🧰 Additional context used
🧬 Code graph analysis (1)
packages/rspeedy/core/test/plugins/dev.plugin.test.ts (1)
packages/rspeedy/core/test/createStubRspeedy.ts (1)
  • createStubRspeedy (20-64)
🔇 Additional comments (2)
packages/rspeedy/core/test/config/rsbuild.test.ts (1)

19-21: LGTM!

The snapshot correctly reflects the new default values for hmr and liveReload when the dev config is undefined. This aligns with the PR objective of ensuring these flags are properly applied to the rsbuild configuration.

packages/rspeedy/core/test/plugins/dev.plugin.test.ts (1)

455-472: LGTM!

The test correctly verifies that when hmr is set to false in environment-specific config, the transport client alias reflects this with hot=false. This aligns with the PR objective of ensuring environment config is properly propagated.

colinaaa
colinaaa previously approved these changes Oct 12, 2025
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +27 to +28
hmr: config.dev?.hmr ?? true,
liveReload: config.dev?.liveReload ?? true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nitpick: we should sort in alphabetical order

@colinaaa colinaaa merged commit dd7c14a into lynx-family:main Oct 12, 2025
10 of 11 checks passed
colinaaa pushed a commit that referenced this pull request Oct 12, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/web-core@0.18.0

### Minor Changes

-   fix: ([#1837](#1837))

    1.  `LynxView.updateData()` cannot trigger `dataProcessor`.

2. **This is a break change:** The second parameter of
`LynxView.updateData()` has been changed from `UpdateDataType` to
`string`, which is the `processorName` (default is `default` which will
use `defaultDataProcessor`). This change is to better align with Native.
The current complete type is as follows:

    ```ts
LynxView.updateData(data: Cloneable, processorName?: string | undefined,
callback?: (() => void) | undefined): void
    ```

### Patch Changes

- Updated dependencies
\[[`77397fd`](77397fd),
[`7d90ed5`](7d90ed5)]:
    -   @lynx-js/web-worker-runtime@0.18.0
    -   @lynx-js/web-constants@0.18.0
    -   @lynx-js/web-mainthread-apis@0.18.0
    -   @lynx-js/web-worker-rpc@0.18.0

## @lynx-js/react@0.114.2

### Patch Changes

- fix: main thread functions created during the initial render cannot
correctly call `runOnBackground()` after hydration
([#1878](#1878))

## @lynx-js/rspeedy@0.11.6

### Patch Changes

- Should apply `dev.hmr` and `dev.liveReload` to Rsbuild config.
([#1882](#1882))

- Support CLI flag `--root` to specify the root of the project.
([#1836](#1836))

## @lynx-js/react-rsbuild-plugin@0.11.2

### Patch Changes

- Fix using wrong version of `@lynx-js/react/refresh`.
([#1756](#1756))

-   Updated dependencies \[]:
    -   @lynx-js/react-alias-rsbuild-plugin@0.11.2
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4
    -   @lynx-js/react-webpack-plugin@0.7.1

## @lynx-js/web-constants@0.18.0

### Patch Changes

-   fix: ([#1837](#1837))

    1.  `LynxView.updateData()` cannot trigger `dataProcessor`.

2. **This is a break change:** The second parameter of
`LynxView.updateData()` has been changed from `UpdateDataType` to
`string`, which is the `processorName` (default is `default` which will
use `defaultDataProcessor`). This change is to better align with Native.
The current complete type is as follows:

    ```ts
LynxView.updateData(data: Cloneable, processorName?: string | undefined,
callback?: (() => void) | undefined): void
    ```

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.18.0

## @lynx-js/web-elements@0.8.8

### Patch Changes

-   fix: ([#1837](#1837))

    1.  `LynxView.updateData()` cannot trigger `dataProcessor`.

2. **This is a break change:** The second parameter of
`LynxView.updateData()` has been changed from `UpdateDataType` to
`string`, which is the `processorName` (default is `default` which will
use `defaultDataProcessor`). This change is to better align with Native.
The current complete type is as follows:

    ```ts
LynxView.updateData(data: Cloneable, processorName?: string | undefined,
callback?: (() => void) | undefined): void
    ```

-   Updated dependencies \[]:
    -   @lynx-js/web-elements-template@0.8.8

## @lynx-js/web-explorer@0.0.10

### Patch Changes

- chore: update `@lynx-js/lynx-core` to `0.1.3`, `@lynx-js/web-core` to
`0.17.1`. ([#1839](#1839))

## @lynx-js/web-mainthread-apis@0.18.0

### Patch Changes

-   fix: ([#1837](#1837))

    1.  `LynxView.updateData()` cannot trigger `dataProcessor`.

2. **This is a break change:** The second parameter of
`LynxView.updateData()` has been changed from `UpdateDataType` to
`string`, which is the `processorName` (default is `default` which will
use `defaultDataProcessor`). This change is to better align with Native.
The current complete type is as follows:

    ```ts
LynxView.updateData(data: Cloneable, processorName?: string | undefined,
callback?: (() => void) | undefined): void
    ```

- feat: mouse event output structures remain aligned
([#1820](#1820))

- Updated dependencies
\[[`77397fd`](77397fd)]:
    -   @lynx-js/web-constants@0.18.0
    -   @lynx-js/web-style-transformer@0.18.0

## @lynx-js/web-worker-runtime@0.18.0

### Patch Changes

-   fix: ([#1837](#1837))

    1.  `LynxView.updateData()` cannot trigger `dataProcessor`.

2. **This is a break change:** The second parameter of
`LynxView.updateData()` has been changed from `UpdateDataType` to
`string`, which is the `processorName` (default is `default` which will
use `defaultDataProcessor`). This change is to better align with Native.
The current complete type is as follows:

    ```ts
LynxView.updateData(data: Cloneable, processorName?: string | undefined,
callback?: (() => void) | undefined): void
    ```

- Updated dependencies
\[[`77397fd`](77397fd),
[`7d90ed5`](7d90ed5)]:
    -   @lynx-js/web-constants@0.18.0
    -   @lynx-js/web-mainthread-apis@0.18.0
    -   @lynx-js/web-worker-rpc@0.18.0

## create-rspeedy@0.11.6



## @lynx-js/react-alias-rsbuild-plugin@0.11.2



## upgrade-rspeedy@0.11.6



## @lynx-js/web-core-server@0.18.0



## @lynx-js/web-elements-template@0.8.8



## @lynx-js/web-rsbuild-server-middleware@0.18.0



## @lynx-js/web-style-transformer@0.18.0



## @lynx-js/web-worker-rpc@0.18.0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants