Skip to content

[Bug]: buildCache not invalidated on environment variable change #4586

@WKBae

Description

@WKBae

Version

System:
    OS: macOS 15.0.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 94.36 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Safari: 18.0.1
  npmPackages:
    @rsbuild/core: ^1.2.8 => 1.2.8

Details

When build cache is enabled, changes to environment variables(process.env.PUBLIC_* and import.meta.env.PUBLIC_*, via shell or .env.* files) do not trigger a rebuild, resulting in output that retains outdated cached variables.
Configuring performance.buildCache.cacheDigest will work; if this is an expected behavior, adding a note to buildCache docs will help users.

Reproduce link

https://github.com/WKBae/rsbuild-cache-env

Reproduce Steps

  1. Build once: PUBLIC_GREETING=Hello yarn build
  2. Change variable: PUBLIC_GREETING=Hola yarn build
  3. Check dist/, HTML and JS contains old PUBLIC_GREETING value Hello.

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