#13734·rspack

[Bug]: Rspack persistent cache fails to resolve `buildDependencies` imports when using tsconfig `paths`

Author: mjames-cCreated Apr 16, 2026Updated Sep 28, 2026
Labelscache

System Info

"@rspack/core": "2.0.0-rc.2",
"@rspack/dev-server": "2.0.0-rc.3"

Details

When given an rspack config similar to below Rspack will fail to resolve the @/rspack/mode dependency and include it in the cache key.

Example tsconfig:

json5
{
  "compilerOptions": {
    // ...
    "rootDir": ".",
    "paths": {
      "@/rspack/*": ["./conf/rspack/*"]
    }
  },
}

Example rspack config:

typescript
import { rspack, type RspackOptions } from "@rspack/core";
import { mode } from "@/rspack/mode";

const config: RspackOptions = {
  mode,
  ...
  cache: {
    type: "persistent",
    buildDependencies: [__filename],
    storage: { type: "filesystem", directory: "./rspack-cache" },
  },
  ...
};

Example warning:

LOG from rspack.persistentCache
<w> BuildDependencies: can't resolve @/rspack/mode in /Users/mjames/work/rspack-loader-chain.
<w> - NotFound("@/rspack/mode")

The buildDependencies resolver is currently hardcoded here:

https://github.com/web-infra-dev/rspack/blob/f29c8da36e521a327db7626bd38d609aeae94cbf/crates/rspack_core/src/cache/persistent/build_dependencies/helper/mod.rs#L35

One option to fix would be to have the buildDependencies resolver reuse the same resolver as specified in the resolve config.. However, users may want the flexibility to specify a different resolve in which case updating the schema of the cache config to be something like buildDependencies?: { files: string[]; resolve?: Resolve; } sounds better.

Reproduce link

https://github.com/mjames-c/rspack-persistent-cache-resolution

Reproduce Steps

See README of https://github.com/mjames-c/rspack-persistent-cache-resolution