[Bug]: incremental rebuild does not restore a side-effect-only import after sideEffects is re-enabled
Author: hardfistCreated Jul 20, 2026Updated Sep 10, 2026
Reproduction
- Rspack: @rspack/[email protected]
- Repository: https://github.com/hardfist/rspack-repro-incremental-side-effects
- Run: pnpm install && pnpm repro
The repro uses one compiler instance with incremental make enabled and changes a package metadata file between builds:
- sideEffects: true — the side-effect marker is present.
- sideEffects: false — the side-effect-only import is removed.
- sideEffects: true again — the incremental bundle still omits the marker.
- A cold build with sideEffects: true includes the marker again.
Observed output:
incremental: initial sideEffects=true marker=true
incremental: sideEffects=false marker=false
incremental: sideEffects=true again marker=false
cold: final sideEffects=true marker=true
BUG REPRODUCED: the incremental bundle stays stale after re-enabling side effects.Expected behavior
Changing package sideEffects metadata back to true should make the incremental result match a cold build and retain the side-effect-only module.
Suspected area
The stale state appears to cross the make/finish/optimize boundary used for side-effect connection evaluation. Relevant code paths are crates/rspack_core/src/artifacts/side_effects_state_artifact.rs, crates/rspack_core/src/compilation/finish_modules/mod.rs, and crates/rspack_core/src/compilation/build_module_graph/graph_updater/repair/lazy.rs.
The repository contains the complete runnable fixture and a cold-build control.
Source: web-infra-dev/rspack