Skip to content

fix: change the generation conditions of the css.hot-update.json#1811

Merged
colinaaa merged 4 commits intolynx-family:mainfrom
Nirvana-Jie:fix/css-hot-update
Sep 28, 2025
Merged

fix: change the generation conditions of the css.hot-update.json#1811
colinaaa merged 4 commits intolynx-family:mainfrom
Nirvana-Jie:fix/css-hot-update

Conversation

@Nirvana-Jie
Copy link
Copy Markdown
Contributor

@Nirvana-Jie Nirvana-Jie commented Sep 23, 2025

css-hot-update.json should not be generated when hmr configuration is actively turned off

Summary by CodeRabbit

  • Bug Fixes

    • css.hot-update.json is now produced only when Hot Module Replacement (HMR) is active, preventing stray hot-update files in non-HMR builds and improving build outputs.
  • Chores

    • Added a patch changeset to publish this update and ensure the new behavior is released.

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
Copy Markdown

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: 4ca4295

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/css-extract-webpack-plugin Patch
@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
Copy Markdown
Contributor

coderabbitai bot commented Sep 23, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Replaced mode/ENV-based HMR detection with an explicit isHMREnabled(compiler) check (inspecting HotModuleReplacementPlugin presence or devServer.hot !== false) to skip emitting css.hot-update.json when HMR is disabled; added a patch changeset for the package.

Changes

Cohort / File(s) Summary of Changes
Release metadata
\.changeset/eleven-lizards-grin.md
Added a patch changeset for @lynx-js/css-extract-webpack-plugin documenting the change to when css.hot-update.json is generated.
Plugin logic update
packages/webpack/css-extract-webpack-plugin/src/CssExtractRspackPlugin.ts
Added private isHMREnabled(compiler) helper that checks for HotModuleReplacementPlugin in compiler.options.plugins and compiler.options.devServer.hot !== false; replaced previous mode/NODE_ENV-based check with this helper to gate the beforeEmit flow and avoid generating css.hot-update.json when HMR is off.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • upupming
  • gaoachao

Poem

I hop through options, sniff for a hot flag,
Skip the JSON crumbs when the dev server's not agog.
A patch in my paw, a tidy little fix,
No extra updates — neat as carrot sticks. 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change by stating the fix and that it alters the generation conditions of css.hot-update.json, and it directly matches the PR’s intent to gate generation on HMR being enabled or not.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 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 a39ad52 and 4ca4295.

📒 Files selected for processing (1)
  • .changeset/eleven-lizards-grin.md (1 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

@cla-assistant
Copy link
Copy Markdown

cla-assistant bot commented Sep 23, 2025

CLA assistant check
All committers have signed the CLA.

@Nirvana-Jie Nirvana-Jie changed the title fix: change the generation conditions of the 'css.hot-update.json' fix: change the generation conditions of the css.hot-update.json Sep 23, 2025
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: 1

🧹 Nitpick comments (2)
.changeset/eleven-lizards-grin.md (1)

1-6: Changeset exists and targets the correct package — good.

Consider making the note more explicit: mention that generation now keys off devServer.hot, not env/mode, to aid consumers scanning release notes.

Suggested wording:

  • “Generate css.hot-update.json only when devServer.hot is enabled (instead of env/mode checks).”
packages/webpack/css-extract-webpack-plugin/src/CssExtractRspackPlugin.ts (1)

202-205: Use suffix replacement for “.css” to avoid accidental mid-string replacements.

Safer and clearer to replace only a terminal “.css”.

-                filename.replace(
-                  '.css',
+                filename.replace(
+                  /\.css$/,
                   `${this.hash ? `.${this.hash}` : ''}.css.hot-update.json`,
                 ),
-              cssHotUpdatePath!.replace(
-                '.css',
+              cssHotUpdatePath!.replace(
+                /\.css$/,
                 `${this.hash ? `.${this.hash}` : ''}.css.hot-update.json`,
               ),

Also applies to: 261-264

📜 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 1e342fe and bbb3956.

📒 Files selected for processing (2)
  • .changeset/eleven-lizards-grin.md (1 hunks)
  • packages/webpack/css-extract-webpack-plugin/src/CssExtractRspackPlugin.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, always generate a changeset and commit the resulting markdown file(s)

Files:

  • .changeset/eleven-lizards-grin.md
🧠 Learnings (7)
📓 Common learnings
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.
📚 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/eleven-lizards-grin.md
📚 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, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.

Applied to files:

  • .changeset/eleven-lizards-grin.md
📚 Learning: 2025-07-22T09:23:07.797Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.

Applied to files:

  • .changeset/eleven-lizards-grin.md
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.

Applied to files:

  • .changeset/eleven-lizards-grin.md
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • .changeset/eleven-lizards-grin.md
📚 Learning: 2025-08-07T04:00:59.645Z
Learnt from: colinaaa
PR: lynx-family/lynx-stack#1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.

Applied to files:

  • .changeset/eleven-lizards-grin.md
🧬 Code graph analysis (1)
packages/webpack/css-extract-webpack-plugin/src/CssExtractRspackPlugin.ts (1)
packages/webpack/chunk-loading-webpack-plugin/test/cases/chunk-loading/runtime-globals/rspack.config.js (1)
  • compiler (20-20)
🔇 Additional comments (1)
packages/webpack/css-extract-webpack-plugin/src/CssExtractRspackPlugin.ts (1)

197-210: No change required — hot-update assets should use the previous compilation hash.

Verified: webpack/rspack HMR emits .hot-update.{json,js} named with the previous compilation's hash, so emitting filenames with this.hash set after emit is correct.
Applies to: 197–210, 223–224, 230–236, 267–273

luhc228
luhc228 previously approved these changes Sep 23, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Co-authored-by: Yiming Li <yimingli.cs@gmail.com>
Signed-off-by: Nirvana <1357711537@qq.com>
upupming
upupming previously approved these changes Sep 23, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 23, 2025

CodSpeed Performance Report

Merging #1811 will degrade performances by 5.9%

Comparing Nirvana-Jie:fix/css-hot-update (5ce30b6) with main (6411f84)

Summary

❌ 2 regressions
✅ 51 untouched
⏩ 3 skipped1

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

Benchmarks breakdown

Benchmark BASE HEAD Change
transform 1000 view elements 42.4 ms 45.1 ms -5.9%
basic-performance-div-10000 380.2 ms 400.4 ms -5.06%

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.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Sep 23, 2025

React Example

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

5ce30b6(current) vs 316da85 main#5557(baseline)

Bundle metrics  no changes
                 Current
#5573
     Baseline
#5557
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.81% 46.81%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5573
     Baseline
#5557
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.8KiB 91.8KiB

Bundle analysis reportBranch Nirvana-Jie:fix/css-hot-updateProject dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci bot commented Sep 23, 2025

Web Explorer

#5570 Bundle Size — 365.44KiB (0%).

5ce30b6(current) vs 316da85 main#5554(baseline)

Bundle metrics  Change 1 change
                 Current
#5570
     Baseline
#5554
No change  Initial JS 145.71KiB 145.71KiB
No change  Initial CSS 32KiB 32KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 218(-0.46%) 219
No change  Duplicate Modules 16 16
No change  Duplicate Code 3.37% 3.37%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#5570
     Baseline
#5554
No change  JS 239.42KiB 239.42KiB
No change  Other 94.02KiB 94.02KiB
No change  CSS 32KiB 32KiB

Bundle analysis reportBranch Nirvana-Jie:fix/css-hot-updateProject dashboard


Generated by RelativeCIDocumentationReport issue

luhc228
luhc228 previously approved these changes Sep 24, 2025
@luhc228 luhc228 reopened this Sep 25, 2025
@upupming upupming enabled auto-merge (squash) September 28, 2025 07:44
colinaaa
colinaaa previously approved these changes Sep 28, 2025
Signed-off-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
@colinaaa colinaaa dismissed stale reviews from luhc228, upupming, and themself via 4ca4295 September 28, 2025 12:40
@colinaaa colinaaa disabled auto-merge September 28, 2025 12:41
@colinaaa colinaaa merged commit 19f823a into lynx-family:main Sep 28, 2025
1 check was pending
colinaaa pushed a commit that referenced this pull request Oct 1, 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/react@0.114.1

### Patch Changes

- Add `event.stopPropagation` and `event.stopImmediatePropagation` in
MTS, to help with event propagation control
([#1835](#1835))

    ```tsx
    function App() {
      function handleInnerTap(event: MainThread.TouchEvent) {
        "main thread";
        event.stopPropagation();
        // Or stop immediate propagation with
        // event.stopImmediatePropagation();
      }

      // OuterTap will not be triggered
      return (
        <view main-thread:bindtap={handleOuterTap}>
          <view main-thread:bindtap={handleInnerTap}>
            <text>Hello, world</text>
          </view>
        </view>
      );
    }
    ```

Note, if this feature is used in [Lazy Loading Standalone
Project](https://lynxjs.org/react/code-splitting.html#lazy-loading-standalone-project),
both the Producer and the Consumer should update to latest version of
`@lynx-js/react` to make sure the feature is available.

- Fix the "ReferenceError: Node is not defined" error.
([#1850](#1850))

This error would happen when upgrading to `@testing-library/jest-dom`
[v6.9.0](https://github.com/testing-library/jest-dom/releases/tag/v6.9.0).

- fix: optimize main thread event error message
([#1838](#1838))

## @lynx-js/rspeedy@0.11.5

### Patch Changes

- Bump Rsbuild v1.5.13 with Rspack v1.5.8.
([#1849](#1849))

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

### Patch Changes

- Updated dependencies
\[[`19f823a`](19f823a)]:
    -   @lynx-js/css-extract-webpack-plugin@0.6.4
    -   @lynx-js/react-alias-rsbuild-plugin@0.11.1
    -   @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/testing-environment@0.1.8

### Patch Changes

- Fix the "ReferenceError: Node is not defined" error.
([#1850](#1850))

This error would happen when upgrading to `@testing-library/jest-dom`
[v6.9.0](https://github.com/testing-library/jest-dom/releases/tag/v6.9.0).

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

### Patch Changes

- feat: support load bts chunk from remote address
([#1834](#1834))

    -   re-support chunk splitting
    -   support lynx.requireModule with a json file
- support lynx.requireModule, lynx.requireModuleAsync with a remote url
- support to add a breakpoint in chrome after reloading the web page

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

## @lynx-js/web-core@0.17.2

### Patch Changes

- feat: support load bts chunk from remote address
([#1834](#1834))

    -   re-support chunk splitting
    -   support lynx.requireModule with a json file
- support lynx.requireModule, lynx.requireModuleAsync with a remote url
- support to add a breakpoint in chrome after reloading the web page

- Updated dependencies
\[[`a35a245`](a35a245)]:
    -   @lynx-js/web-worker-runtime@0.17.2
    -   @lynx-js/web-constants@0.17.2
    -   @lynx-js/web-mainthread-apis@0.17.2
    -   @lynx-js/web-worker-rpc@0.17.2

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

### Patch Changes

- Updated dependencies
\[[`a35a245`](a35a245)]:
    -   @lynx-js/web-constants@0.17.2
    -   @lynx-js/web-style-transformer@0.17.2

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

### Patch Changes

- feat: support load bts chunk from remote address
([#1834](#1834))

    -   re-support chunk splitting
    -   support lynx.requireModule with a json file
- support lynx.requireModule, lynx.requireModuleAsync with a remote url
- support to add a breakpoint in chrome after reloading the web page

- Updated dependencies
\[[`a35a245`](a35a245)]:
    -   @lynx-js/web-constants@0.17.2
    -   @lynx-js/web-mainthread-apis@0.17.2
    -   @lynx-js/web-worker-rpc@0.17.2

## @lynx-js/css-extract-webpack-plugin@0.6.4

### Patch Changes

- Avoid generating `.css.hot-update.json` when HMR is disabled.
([#1811](#1811))

## create-rspeedy@0.11.5



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



## upgrade-rspeedy@0.11.5



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



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



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



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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Nov 28, 2025
3 tasks
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.

4 participants