You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve type safety in core hooks, server helpers, plugin configuration, and tests by replacing unsafe arguments with explicit types and using array length assertions where appropriate. Upgrade rspack-chain to 2.3.1 to use its more precise configuration types. Skip unconfigured loaders when copying plugin rules and default missing CSS importLoaders to zero.
Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
chenjiahan
changed the title
refactor: improve type safety with rspack-chain 2.3.1
refactor: improve type safety in core, plugins and tests
Sep 7, 2026
Ecosystem CI regression: rsbuild/plugins, rsbuild/lynx-stack, and rsbuild/modernjs
Attribution: Confirmed source
Impact: Three downstream suites no longer type-check against Rsbuild main because exported rspack-chain getters and merge patches are now stricter.
Why this PR
This PR upgraded rspack-chain from 2.2.0 to 2.3.1 and adapted Rsbuild's own call sites, so the stricter T | undefined getter results and typed merge patches now reach downstream consumers through @rsbuild/core. The failures start at its merge commit and match those exact type changes. This exposed downstream compatibility constraints rather than introducing a runtime product regression.
Failure signatures: loader getters become string | undefined; CSS loader options become optional; RuleSetRule no longer matches the named merge patch; library can no longer be spread without narrowing; manifest publicPath can be a function.
Flaky/pre-existing check: none of these signatures appears in the previous green run; all persist in later runs.
Config check: not applicable; these are compile-time failures in unconditional downstream build paths.
Alternatives ruled out: all three failing plugin repositories used identical commits in the green and first-bad runs. The failing Modern.js files and Lynx css.ts did not change across their downstream HEAD advances. Later Rsbuild PRs chore: enable import recommended lint preset #8438 and refactor: use named React imports #8439 retain the same signatures and do not touch the relevant type surface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improve type safety in core hooks, server helpers, plugin configuration, and tests by replacing unsafe arguments with explicit types and using array length assertions where appropriate. Upgrade rspack-chain to 2.3.1 to use its more precise configuration types. Skip unconfigured loaders when copying plugin rules and default missing CSS
importLoadersto zero.Related links