fix(packages/cli): disable persistent build cache on config-reload restart#67
fix(packages/cli): disable persistent build cache on config-reload restart#67zrosenbauer merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: e2b85b8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughChanged rspress.ts to add an internal Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Rspress as Rspress (startServer)
participant Builder as Builder (dev()/rsbuild)
CLI->>Rspress: startServer(config, {skipBuildCache: false}) %% initial boot
Rspress->>Builder: dev(extraBuilderConfig + buildCacheOverride(skip=false))
Builder-->>Rspress: start up with persistent build cache
Rspress-->>CLI: dev server ready
CLI->>Rspress: startServer(newConfig, {skipBuildCache: true}) %% config-reload restart
Rspress->>Builder: dev(extraBuilderConfig + buildCacheOverride(skip=true))
Builder-->>Rspress: start up with buildCache disabled
Rspress-->>CLI: restarted without persistent cache
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
…start
Rspress's persistent build cache (`buildCache.cacheDigest`) only tracks
sidebar/nav structure and the Rspress version. It is unaware of zpress-specific
config values (title, theme, colors, `source.define` compile-time constants).
When only those values changed, the stale cached build output was served,
making config changes appear to have no effect.
Additionally, `configFilePath: ''` meant the file-based `buildDependencies`
invalidation path was a no-op, so no config file change could bust the cache.
Disable the persistent build cache on config-reload restarts by passing
`performance: { buildCache: false }` via `extraBuilderConfig`. The initial
cold start still benefits from the cache; only restarts triggered by config
changes bypass it to force a fresh Rsbuild compilation.
Co-Authored-By: Claude <noreply@anthropic.com>
5332ddd to
4ec07bd
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/cli/src/lib/rspress.ts`:
- Around line 254-259: The function buildCacheOverride currently returns a loose
Record<string, unknown>; change its return type to a precise shape (e.g., an
object with an optional performance property containing an optional buildCache
boolean) so consumers and spreads into extraBuilderConfig get proper typing.
Update the signature of buildCacheOverride to return that specific
interface/inline type and ensure the two return paths return objects matching
that shape (performance?: { buildCache?: boolean }), which will improve IDE
assistance and catch typos when spreading into extraBuilderConfig.
- Line 69: Refactor the startServer function to accept a single object parameter
instead of two positional args: change the signature from startServer(config:
ZpressConfig, isRestart: boolean) to startServer({ config, isRestart }: {
config: ZpressConfig; isRestart?: boolean }): Promise<boolean> (keep the
explicit return type), update the implementation to use the destructured
properties, and update all call sites that invoke startServer(...) to pass an
object (e.g., startServer({ config, isRestart })) ensuring optionality/defaults
for isRestart are handled consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f9619fc2-6fa2-4a8e-ac32-7c7e967af545
📒 Files selected for processing (1)
packages/cli/src/lib/rspress.ts
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/cli/src/lib/rspress.ts (1)
77-80: 🛠️ Refactor suggestion | 🟠 MajorRefactor
startServerto a single object parameter.Line 77 still uses two parameters. This violates the repo rule for 2+ args and makes callsites less self-describing.
♻️ Suggested refactor
- async function startServer( - config: ZpressConfig, - internalOptions: StartServerOptions - ): Promise<boolean> { + async function startServer(options: { + readonly config: ZpressConfig + readonly internalOptions: StartServerOptions + }): Promise<boolean> { + const { config, internalOptions } = options const rspressConfig = createRspressConfig({ config, paths, vscode: options.vscode, themeOverride: options.theme, colorModeOverride: options.colorMode, })- const started = await startServer(options.config, { skipBuildCache: false }) + const started = await startServer({ + config: options.config, + internalOptions: { skipBuildCache: false }, + })- const restarted = await startServer(newConfig, { skipBuildCache: true }) + const restarted = await startServer({ + config: newConfig, + internalOptions: { skipBuildCache: true }, + })As per coding guidelines: "Use object parameters for functions with 2+ parameters and include explicit return types".
Also applies to: 114-114, 148-148
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/lib/rspress.ts` around lines 77 - 80, Refactor the startServer function signature to accept a single object parameter instead of two positional args: change it from startServer(config: ZpressConfig, internalOptions: StartServerOptions): Promise<boolean> to startServer({ config, internalOptions }: { config: ZpressConfig; internalOptions: StartServerOptions }): Promise<boolean>, update the function body to use the destructured properties, and keep the explicit Promise<boolean> return type; then update every callsite that invokes startServer(...) to pass an object with properties config and internalOptions (search for startServer usages mentioned in the review), and ensure any related overloads/exports/imports continue to compile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@packages/cli/src/lib/rspress.ts`:
- Around line 77-80: Refactor the startServer function signature to accept a
single object parameter instead of two positional args: change it from
startServer(config: ZpressConfig, internalOptions: StartServerOptions):
Promise<boolean> to startServer({ config, internalOptions }: { config:
ZpressConfig; internalOptions: StartServerOptions }): Promise<boolean>, update
the function body to use the destructured properties, and keep the explicit
Promise<boolean> return type; then update every callsite that invokes
startServer(...) to pass an object with properties config and internalOptions
(search for startServer usages mentioned in the review), and ensure any related
overloads/exports/imports continue to compile.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ba771c6a-93b0-4ea7-b8f8-d9d716878fa8
📒 Files selected for processing (2)
.changeset/fix-config-reload-cache.mdpackages/cli/src/lib/rspress.ts
Summary
zpress.config.tswere not propagating to the dev server because Rspress's persistent build cache (buildCache.cacheDigest) only tracks sidebar/nav structure — it has no visibility into zpress-specific values liketitle,theme,colors, orsource.definecompile-time constantsbuildCache: false) so Rsbuild does a fresh compilation with the updated configChanges
packages/cli/src/lib/rspress.ts: AddedisRestartparameter tostartServer; addedbuildCacheOverridehelper that returns{ performance: { buildCache: false } }on restartsTesting
zpress devin a projecttitle,theme.name, ortheme.colorsinzpress.config.tsSummary by CodeRabbit