Skip to content

[Bug]: import.meta.webpackHot.accept not called when class changes #4730

Open
@dartess

Description

@dartess

Version

System:
    OS: macOS 15.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 3.04 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Brave Browser: 134.1.76.73
    Chrome: 134.0.6998.44
    Chrome Canary: 136.0.7054.0
    Edge: 111.0.1661.54
    Safari: 18.3
    Safari Technology Preview: 18.4
  npmPackages:
    @rsbuild/core: ^1.2.15 => 1.2.15 
    @rsbuild/plugin-react: ^1.1.1 => 1.1.1

Details

I want to listen for changes in a file using "import.meta.webpackHot.accept" and react to the changes.

However, when changing in the class code, nothing happens, as if the file does not change.

note "a": there is a workaround to make the system react to changes. for this it is enough to export an empty function next to the class. now I have to place such a hack in each file with a class.

note "b": I tried to reproduce the problem with rspack and it doesn't seem to reproduce the problem.

Reproduce link

https://github.com/dartess/rsbuild-class-hmr

Reproduce Steps

  1. npm i
  2. npm run dev:rsbuild
  3. open http://localhost:3000/
  4. change value in src/Features.ts
    expected result: console.log: changed!
    actual result: nothing.

for note "a": uncomment // export function hmrHack() {} and try again — everything works fine with this workaround.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions