System Info
System:
OS: macOS 26.5.1
CPU: arm64 Apple M5
Binaries:
Node: 26.0.0
Yarn: 4.9.4
npm: 11.12.1
npmPackages:
@rspack/cli: 2.1.3
@rspack/core: 2.1.3
@rspack/dev-server: 2.1.0
The same implementation is present on the current main branch.
Details
When lazyCompilationMiddleware receives a MultiCompiler, it correctly finds each child compiler that has lazyCompilation enabled, but it creates the request middleware with the parent MultiCompiler:
lazyCompilationMiddlewareInternal(compiler, activeModules, options.prefix)
When a lazy module is activated, the internal middleware calls:
compiler.watching.invalidate()
Because compiler is the parent MultiCompiler, MultiWatching.invalidate() invalidates every child compiler, including compilers that do not use lazy compilation.
In our application, activating a lazy route in the web compiler also caused an unrelated worker compiler to participate in the update cycle. Its HMR client could then request worker hot updates or contribute an unaccepted update that falls back to a full page reload.
Expected behavior: activating a lazy module invalidates only the child compiler that owns that lazy-compilation configuration.
Changing the MultiCompiler branch to pass c fixes the behavior while preserving normal updates when worker source files actually change:
- lazyCompilationMiddlewareInternal(compiler, activeModules, options.prefix)
+ lazyCompilationMiddlewareInternal(c, activeModules, options.prefix)
Reproduce link
A pull request with a focused MultiCompiler regression test will be linked to this issue.
Reproduce Steps
- Create a MultiCompiler with two child compilers.
- Enable
lazyCompilation only on the first child compiler.
- Start both compilers in watch mode and install
lazyCompilationMiddleware(multiCompiler).
- Send a POST request to
/_rspack/lazy/trigger__0 with a previously inactive module key.
- Observe that the parent
MultiWatching.invalidate() is called and both child compilers enter the update cycle.
- Change the middleware argument from the parent
compiler to the lazy-enabled child c.
- Repeat the request and observe that only the lazy-enabled child compiler is invalidated.
System Info
The same implementation is present on the current
mainbranch.Details
When
lazyCompilationMiddlewarereceives aMultiCompiler, it correctly finds each child compiler that haslazyCompilationenabled, but it creates the request middleware with the parentMultiCompiler:When a lazy module is activated, the internal middleware calls:
Because
compileris the parentMultiCompiler,MultiWatching.invalidate()invalidates every child compiler, including compilers that do not use lazy compilation.In our application, activating a lazy route in the web compiler also caused an unrelated worker compiler to participate in the update cycle. Its HMR client could then request worker hot updates or contribute an unaccepted update that falls back to a full page reload.
Expected behavior: activating a lazy module invalidates only the child compiler that owns that lazy-compilation configuration.
Changing the MultiCompiler branch to pass
cfixes the behavior while preserving normal updates when worker source files actually change:Reproduce link
A pull request with a focused MultiCompiler regression test will be linked to this issue.
Reproduce Steps
lazyCompilationonly on the first child compiler.lazyCompilationMiddleware(multiCompiler)./_rspack/lazy/trigger__0with a previously inactive module key.MultiWatching.invalidate()is called and both child compilers enter the update cycle.compilerto the lazy-enabled childc.