fix: failed to load CSS update file for lazy bundle#2150
Conversation
🦋 Changeset detectedLatest commit: b0dfc81 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
📝 WalkthroughWalkthroughUpdates 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
305ee3b to
7dd0f32
Compare
177e442 to
67ab5f0
Compare
The base branch was changed.
Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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.
CodSpeed Performance ReportMerging this PR will degrade performance by 5.63%Comparing Summary
Performance Changes
Footnotes
|
Web Explorer#7411 Bundle Size — 383.56KiB (0%).b0dfc81(current) vs 1a5f2a1 main#7408(baseline) Bundle metrics
Bundle size by type
|
| Current #7411 |
Baseline #7408 |
|
|---|---|---|
252.66KiB |
252.66KiB |
|
95.85KiB |
95.85KiB |
|
35.05KiB |
35.05KiB |
Bundle analysis report Branch fix/lazy-bundle-hmr-entrynames Project dashboard
Generated by RelativeCI Documentation Report issue
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>
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>
Summary by CodeRabbit
Bug Fixes
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Checklist