Skip to content

fix: lazy bundle HMR set correct entryName#2134

Merged
upupming merged 1 commit intomainfrom
feat/DEV_ONLY_SetSnapshotEntryName
Jan 26, 2026
Merged

fix: lazy bundle HMR set correct entryName#2134
upupming merged 1 commit intomainfrom
feat/DEV_ONLY_SetSnapshotEntryName

Conversation

@upupming
Copy link
Collaborator

@upupming upupming commented Jan 23, 2026

This fix follows #2048 but for non standalone lazy bundles. We now will pass the snapshotCreator function from BTS to MTS but miss the correct globDynamicComponentEntry field. It will fail to execute __SetCSSId for lazy bundle.

Summary by CodeRabbit

  • New Features

    • Added a lazy-loaded component example with Suspense fallback.
  • Bug Fixes

    • Fixed CSS loss during hot module replacement for lazy bundles.
  • Style

    • Minor layout and styling adjustments for suspense and lazy component UI.
  • Tests

    • Added tests covering non-standalone lazy bundle snapshot behavior.

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

@upupming upupming requested review from HuJean and hzy as code owners January 23, 2026 11:17
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 8b25961

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

This PR includes changesets to release 1 package
Name Type
@lynx-js/react 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 Jan 23, 2026

📝 Walkthrough

Walkthrough

Adds a DEV_ONLY_SetSnapshotEntryName snapshot operation and apply logic to patch lazy-bundle entry names for HMR, introduces a lazy-loaded example component with CSS, and adds test coverage and a changeset documenting the fix.

Changes

Cohort / File(s) Summary
Changeset documentation
\.changeset/itchy-candies-smoke.md
Adds a changeset entry documenting a patch bump for @lynx-js/react and a fix for lazy bundle HMR losing CSS.
Example lazy-loaded component
examples/react-lazy-bundle/src/LazyComponent.tsx, examples/react-lazy-bundle/src/LazyComponent.css
New default-exported LazyComponent and associated CSS (.LazyComponent bold, yellow).
App component modifications
examples/react-lazy-bundle/src/App.tsx, examples/react-lazy-bundle/src/App.css
Adds lazy + Suspense usage to load LazyComponent with a fallback and minor spacing CSS for .Suspense.
Snapshot operation definition
packages/react/runtime/src/lifecycle/patch/snapshotPatch.ts
Introduces DEV_ONLY_SetSnapshotEntryName operation (enum value 102) and parameter descriptor.
Snapshot patch application
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts
Adds handler to apply DEV_ONLY_SetSnapshotEntryName: replaces globDynamicComponentEntry placeholder with the provided entryName and re-evaluates snapshot function (dev-only).
Snapshot creation flow
packages/react/runtime/src/snapshot.ts
Emits DEV_ONLY_SetSnapshotEntryName patch when creating lazy-bundle snapshots with a non-default entryName in dev/JS context.
Test coverage
packages/react/runtime/__test__/snapshotPatch.test.jsx
Adds test case(s) exercising non-standalone lazy-bundle snapshot patching and reapplication; duplicate test block appears in diff.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • HuJean
  • hzy

Poem

🐰 I hopped through patches, swift and bright,
Replaced a name to keep styles right.
Lazy loads bloom in Suspense's light,
HMR hums through day and night. 🎨✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 'fix: lazy bundle HMR set correct entryName' directly and specifically describes the main change—fixing the lazy bundle HMR mechanism to properly set the entryName parameter.

✏️ 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.

@codecov
Copy link

codecov bot commented Jan 23, 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!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 23, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 11.06%

Comparing feat/DEV_ONLY_SetSnapshotEntryName (8b25961) with main (444f83b)

Summary

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 61 untouched benchmarks
⏩ 3 skipped benchmarks1

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

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 41.7 ms 46.9 ms -11.06%
basic-performance-nest-level-100 7.6 ms 7.1 ms +6.99%

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

relativeci bot commented Jan 23, 2026

Web Explorer

#7346 Bundle Size — 384.14KiB (0%).

8b25961(current) vs 0efda9d main#7342(baseline)

Bundle metrics  no changes
                 Current
#7346
     Baseline
#7342
No change  Initial JS 154.12KiB 154.12KiB
No change  Initial CSS 35.05KiB 35.05KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 238 238
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
#7346
     Baseline
#7342
No change  JS 252.07KiB 252.07KiB
No change  Other 97.02KiB 97.02KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch feat/DEV_ONLY_SetSnapshotEntryNa...Project dashboard


Generated by RelativeCIDocumentationReport issue

@upupming upupming force-pushed the feat/DEV_ONLY_SetSnapshotEntryName branch from 6901479 to 8b25961 Compare January 23, 2026 12:07
@upupming upupming merged commit c691f87 into main Jan 26, 2026
67 of 70 checks passed
@upupming upupming deleted the feat/DEV_ONLY_SetSnapshotEntryName branch January 26, 2026 03:51
colinaaa pushed a commit that referenced this pull request Jan 26, 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/react@0.116.1

### Patch Changes

- Fix the issue that lazy bundle HMR will lost CSS.
([#2134](#2134))

## @lynx-js/rspeedy@0.13.2

### Patch Changes

- Bump Rsbuild 1.7.2 with Rspack 1.7.1.
([#2136](#2136))

## @lynx-js/lynx-bundle-rslib-config@0.2.1

### Patch Changes

- Add
[`globalObject`](https://webpack.js.org/configuration/output/#outputglobalobject)
config for external bundle loading, user can configure it to
`globalThis` for BTS external bundle sharing.
([#2123](#2123))

## @lynx-js/external-bundle-rsbuild-plugin@0.0.2

### Patch Changes

- Add
[`globalObject`](https://webpack.js.org/configuration/output/#outputglobalobject)
config for external bundle loading, user can configure it to
`globalThis` for BTS external bundle sharing.
([#2123](#2123))

- Updated dependencies
\[[`959360c`](959360c)]:
    -   @lynx-js/externals-loading-webpack-plugin@0.0.3

## @lynx-js/externals-loading-webpack-plugin@0.0.3

### Patch Changes

- Add
[`globalObject`](https://webpack.js.org/configuration/output/#outputglobalobject)
config for external bundle loading, user can configure it to
`globalThis` for BTS external bundle sharing.
([#2123](#2123))

## create-rspeedy@0.13.2



## upgrade-rspeedy@0.13.2

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.

2 participants