-
-
Notifications
You must be signed in to change notification settings - Fork 734
Description
Version
System:
OS: Windows 11 10.0.26100
CPU: (4) x64 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz
Memory: 17.25 GB / 31.83 GB
Browsers:
Firefox: 144.0
Chrome: 141.0.7390.108
Edge: Chromium (140.0.3485.54)
Internet Explorer: 11.0.26100.1882
npmPackages:
@rsbuild/core: ^1.5.17 => 1.5.17
@rsbuild/plugin-react: ^1.4.1 => 1.4.1
@types/md5: ^2.3.6 => 2.3.6
@types/node: ^24.8.1 => 24.8.1
@types/react: ^19.2.2 => 19.2.2
@types/react-dom: ^19.2.2 => 19.2.2
@types/webpack-env: ^1.18.8 => 1.18.8
es-toolkit: ^1.40.0 => 1.40.0
md5: ^2.3.0 => 2.3.0
react: ^19.2.0 => 19.2.0
react-dom: ^19.2.0 => 19.2.0
typescript: ^5.9.3 => 5.9.3Details
When updating a React lazy-loaded component, that has a specific (even nested) dependency (eg. md5 or matrix-js-sdk among those I have tested), when this update includes a new import, it always ends up in a RuntimeError: factory is undefined.
Common updates (such as updating a text) do not trigger this.
If the component does not include the "problematic" dependency, or this dependency is within its own lazyload, the issue does not trigger as well.
Removing the top-level lazyload solves this as well.
In our use case, this problem started being very burdensome after working with matrix-js-sdk. The whole view containing usages of the SDK is very hard to develop, every new import ends up in an error & requires full reload. Even after moving the SDK to its separate lazy-load, the issue reappeared when importing enums from this lib.
After some tinkering, I have also found out that the md5 lib has the same issue. And there are definitely many more. You need to find the root cause.
I have tested rsbuild versions 1.4.10, 1.4.15 and 1.5.17 - the error is in all of them.
See the attached reproduction repo - clone & edit TestPage.tsx (see readme).
Thanks for looking into this!
Reproduce link
https://github.com/vitexikora/rspack-hmr-bug-repro
Reproduce Steps
- clone repo
pnpm ipnpm start- edit TestPage.tsx (uncomment the line with "isEqual", see comments)
- inspect console for errors, see that HMR failed
You can then refresh the page and try again. The HMR will fail every time.