Skip to content

fix: failed to load CSS update file for lazy bundle#2150

Merged
upupming merged 8 commits intomainfrom
fix/lazy-bundle-hmr-entrynames
Jan 29, 2026
Merged

fix: failed to load CSS update file for lazy bundle#2150
upupming merged 8 commits intomainfrom
fix/lazy-bundle-hmr-entrynames

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Jan 28, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed "Failed to load CSS update file" error for lazy bundles.
  • Improvements

    • Improved handling of async chunk naming for lazy-loaded bundles to better support multi-entry scenarios.
  • Tests

    • Added end-to-end tests covering lazy bundle loading, HMR behavior, and CSS hot-update validation.

✏️ Tip: You can customize this high-level summary in your review 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).

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 28, 2026

🦋 Changeset detected

Latest commit: b0dfc81

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/template-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 Jan 28, 2026

📝 Walkthrough

Walkthrough

Updates add React lazy-loading test fixtures and tests for HMR/entry-name handling, plus a template-webpack-plugin change to derive multiple entry names from chunk groups for async chunk encoding (and a changeset documenting a patch release).

Changes

Cohort / File(s) Summary
Changeset
​.changeset/brave-news-sin.md
Adds patch release entry documenting fix for "Failed to load CSS update file" in lazy bundles
Test fixtures
packages/rspeedy/plugin-react/test/fixtures/lazy-bundle/LazyComponent.tsx, packages/rspeedy/plugin-react/test/fixtures/lazy-bundle/LazyComponent.css, packages/rspeedy/plugin-react/test/fixtures/lazy-bundle/index.tsx, packages/rspeedy/plugin-react/test/fixtures/lazy-bundle/index.css
New React component, CSS, and Suspense-based app fixture for lazy-loading scenarios
Tests
packages/rspeedy/plugin-react/test/lazy.test.ts
Adds tests to capture beforeEncode/beforeEmit behavior: verifies emitted entryNames and ensures app-service.js does not load hot-update.js during HMR
Template plugin
packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
Per-entry async processing now collects multiple entryNames from chunk groups, computes async chunkNames from them, and passes array of entryNames into encodeByAssetsInformation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

framework:React

Suggested reviewers

  • colinaaa
  • hzy

Poem

🐰 I hopped through chunks both slow and spry,
Collected names beneath the sky,
Suspense held fast while CSS took flight,
Hot-update files hidden from sight—
A tiny patch, the bundle's delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the main fix implemented in this PR: resolving CSS update file loading issues for lazy-loaded bundles, which is addressed by changes to LynxTemplatePlugin.ts and new test fixtures.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@upupming upupming marked this pull request as ready for review January 28, 2026 08:31
@upupming upupming force-pushed the fix/lazy-bundle-hmr-entrynames branch from 305ee3b to 7dd0f32 Compare January 28, 2026 08:33
HuJean
HuJean previously approved these changes Jan 28, 2026
@upupming upupming force-pushed the fix/lazy-bundle-hmr-entrynames branch from 177e442 to 67ab5f0 Compare January 28, 2026 09:20
luhc228
luhc228 previously approved these changes Jan 28, 2026
Base automatically changed from fix/lazy-bundle-hmr to main January 28, 2026 11:21
@upupming upupming dismissed stale reviews from luhc228 and HuJean January 28, 2026 11:21

The base branch was changed.

@upupming upupming requested a review from hzy as a code owner January 28, 2026 11:21
hzy
hzy previously approved these changes Jan 28, 2026
Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 28, 2026

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!

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: 3

🤖 Fix all issues with AI agents
In @.changeset/brave-news-sin.md:
- Line 5: In .changeset/brave-news-sin.md tighten the release note by removing
the duplicated word "error" in the line that currently reads: Fix error "Failed
to load CSS update file" error for lazy bundle — replace it with a concise
phrasing such as Fix "Failed to load CSS update file" for lazy bundle or Fix
failure to load CSS update file for lazy bundle so the message isn't repetitive.

In `@packages/rspeedy/plugin-react/test/lazy.test.ts`:
- Around line 177-293: The test "lazy bundle beforeEncode entryNames" calls
vi.stubEnv('NODE_ENV', 'development') but never restores it; wrap the
build+assertion block in a try/finally and restore the stub in finally (call
vi.unstubEnv() or the proper Vitest undo helper your test-suite uses) so
NODE_ENV is always reverted; locate the vi.stubEnv call near the top of that
test and ensure the try/finally encloses the await rsbuild.build() and all
expectations that reference entryNamesOfBeforeEncode and backgroundJSContent.
- Around line 295-416: The test mutates fixtures and stubs NODE_ENV without
guaranteeing cleanup; wrap the HMR mutation and related assertions in a
try/finally so the original LazyComponent.tsx content (tmpContent) is always
restored and the environment is reset after the test: capture the original
process.env.NODE_ENV before vi.stubEnv, perform the file write,
waitCompilationDone and assertions inside try, and in finally write back
tmpContent to the LazyComponent.tsx path and restore process.env.NODE_ENV (or
clear the stub) so subsequent tests remain isolated; update symbols referenced:
the test block 'lazy bundle app-service.js should not load hot-update.js',
tmpContent, fs.readFile/fs.writeFile calls for
'./fixtures/lazy-bundle/LazyComponent.tsx', waitCompilationDone, and vi.stubEnv.
🧹 Nitpick comments (1)
packages/rspeedy/plugin-react/test/fixtures/lazy-bundle/index.tsx (1)

1-12: Handle lazy-load failures to avoid blank renders.

If the chunk fails to load (e.g., missing HMR update), the error will bubble and the fixture renders nothing. Consider wrapping with an error boundary or add error handling in the lazy loader.

✅ Suggested change (async/await with fallback)
-const LazyComponent = lazy(() => import('./LazyComponent.js'))
+const LazyComponent = lazy(async () => {
+  try {
+    return await import('./LazyComponent.js')
+  } catch {
+    return { default: () => <text>Load failed</text> }
+  }
+})

As per coding guidelines: **/*.{js,ts,jsx,tsx}: Use async/await patterns with proper error handling in JavaScript/TypeScript code.

Comment thread .changeset/brave-news-sin.md Outdated
Comment thread packages/rspeedy/plugin-react/test/lazy.test.ts
Comment thread packages/rspeedy/plugin-react/test/lazy.test.ts
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jan 28, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 5.63%

Comparing fix/lazy-bundle-hmr-entrynames (b0dfc81) with main (1a5f2a1)

Summary

❌ 1 regressed benchmark
✅ 62 untouched benchmarks
⏩ 3 skipped benchmarks1

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

Performance Changes

Benchmark BASE HEAD Efficiency
basic-performance-nest-level-100 6.9 ms 7.4 ms -5.63%

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 Jan 28, 2026

Web Explorer

#7411 Bundle Size — 383.56KiB (0%).

b0dfc81(current) vs 1a5f2a1 main#7408(baseline)

Bundle metrics  Change 1 change
                 Current
#7411
     Baseline
#7408
No change  Initial JS 154.71KiB 154.71KiB
No change  Initial CSS 35.05KiB 35.05KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 238(-0.42%) 239
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.99% 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7411
     Baseline
#7408
No change  JS 252.66KiB 252.66KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch fix/lazy-bundle-hmr-entrynamesProject dashboard


Generated by RelativeCIDocumentationReport issue

upupming and others added 3 commits January 28, 2026 23:46
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
@upupming upupming requested review from HuJean and hzy January 29, 2026 03:07
@upupming upupming merged commit 92881e7 into main Jan 29, 2026
46 of 47 checks passed
@upupming upupming deleted the fix/lazy-bundle-hmr-entrynames branch January 29, 2026 03:53
colinaaa pushed a commit that referenced this pull request Feb 1, 2026
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/motion@0.0.2

### Patch Changes

- Add initial support for `@lynx-js/motion`
([#1062](#1062))

## @lynx-js/react@0.116.2

### Patch Changes

- Fix "TypeError: not a function" error caused by `replaceAll` not
supported in ES5.
([#2142](#2142))

- Bump `swc_core` v56.
([#2154](#2154))

- Use `disableDeprecatedWarning` option to suppress BROKEN warnings
during compilation.
([#2157](#2157))

1. BROKEN: `getNodeRef`/`getNodeRefFromRoot`/`createSelectorQuery` on
component instance is broken and MUST be migrated in ReactLynx 3.0,
please use ref or lynx.createSelectorQuery instead.
2. BROKEN: `getElementById` on component instance is broken and MUST be
migrated in ReactLynx 3.0, please use ref or lynx.getElementById
instead.

- Fix memory leak by clearing list callbacks when \_\_DestroyLifetime
event is triggered.
([#2112](#2112))

## @lynx-js/rspeedy@0.13.3

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.7

## @lynx-js/qrcode-rsbuild-plugin@0.4.4

### Patch Changes

- Bump `@clack/prompts` v1.0
([#2171](#2171))

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

### Patch Changes

- Updated dependencies
\[[`92881e7`](92881e7),
[`1a5f2a1`](1a5f2a1)]:
    -   @lynx-js/template-webpack-plugin@0.10.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.7
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

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

### Patch Changes

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

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

### Patch Changes

- feat: add browser config of lynx-view, now you can customize the
browser config of lynx-view:
([#2140](#2140))

        lynxView.browserConfig = {
          pixelRatio: 1,
          pixelWidth: 1234,
          pixelHeight: 5678,
        }

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7
    -   @lynx-js/web-mainthread-apis@0.19.7
    -   @lynx-js/web-worker-rpc@0.19.7
    -   @lynx-js/web-worker-runtime@0.19.7

## @lynx-js/web-core-wasm@0.0.2

### Patch Changes

- Updated dependencies
\[[`43fc7e7`](43fc7e7)]:
    -   @lynx-js/web-elements@0.11.1
    -   @lynx-js/web-worker-rpc@0.19.7

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

### Patch Changes

- feat: add wheel event handling and corresponding tests for
x-foldview-ng
([#2145](#2145))

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7
    -   @lynx-js/web-mainthread-apis@0.19.7
    -   @lynx-js/web-worker-rpc@0.19.7

## @lynx-js/template-webpack-plugin@0.10.3

### Patch Changes

- Fix "Failed to load CSS update file" for lazy bundle
([#2150](#2150))

- Fix "TypeError: cannot read property 'call' of undefined" error of
lazy bundle HMR.
([#2146](#2146))

## create-rspeedy@0.13.3



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



## upgrade-rspeedy@0.13.3



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



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



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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants