[Bug]: Rspack persistent cache fails to resolve `buildDependencies` imports when using tsconfig `paths`
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:
{
"compilerOptions": {
// ...
"rootDir": ".",
"paths": {
"@/rspack/*": ["./conf/rspack/*"]
}
},
}Example rspack config:
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:
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
Source: web-infra-dev/rspack