feat(core): accept loadConfig result as config input - #1915
Conversation
Deploying rslib with
|
| Latest commit: |
83c488a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://33e66dec.rslib.pages.dev |
| Branch Preview URL: | https://chenjiahan-feat-config-load.rslib.pages.dev |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
The new isLoadConfigResult runtime guard is too permissive and can misclassify user configs, leading to incorrect config handling.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates @rslib/core to let createRslib accept the full loadConfig result (or an async factory returning it), so Rslib can forward config file path + dependency metadata to Rsbuild for better file watching and persistent cache invalidation, without manually forwarding _privateMeta.
Changes:
- Extend
CreateRslibOptions.configto acceptLoadConfigResult(and async factories returning it), and forward the load result metadata intocreateRsbuild. - Align
loadConfigtypes/behavior with Rsbuild’sLoadConfigResultshape (includingdependencies) and update CLI + test helpers to pass the full result. - Update API docs (EN/ZH) and add a unit test covering the “pass full loadConfig result” path.
File summaries
| File | Description |
|---|---|
| website/docs/zh/api/javascript-api/core.mdx | Documents createRslib accepting LoadConfigResult and explains why callers should pass full results. |
| website/docs/en/api/javascript-api/core.mdx | Same as above for English docs. |
| tests/scripts/shared.ts | Updates test helper to pass full loadConfig() result into createRslib. |
| packages/core/tests/config.test.ts | Adds test asserting Rsbuild receives config file path/dependencies when given full load result. |
| packages/core/src/types/rslib.ts | Broadens CreateRslibOptions.config type to include LoadConfigResult. |
| packages/core/src/loadConfig.ts | Re-exports Rsbuild’s LoadConfigResult shape and returns it directly from loadConfig. |
| packages/core/src/createRslib.ts | Detects LoadConfigResult inputs and forwards metadata to createRsbuild. |
| packages/core/src/cli/init.ts | Ensures CLI passes the complete load result (not just content) into createRslib. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Motivation
Rslib relies on private configuration metadata to preserve file watching and cache dependencies. Rsbuild now supports passing the complete load result directly (rsbuild#8147).
Changes
Allow
createRslibto accept a completeloadConfigresult, directly or through an async factory, and forward its file path and dependencies alongside the transformed Rsbuild configuration.Preserve Rsbuild's loaded configuration, including
_privateMeta, while removing Rslib's explicit forwarding of that private field.Update the CLI, test helper, and API documentation to pass complete results; callers passing only
result.contentmust migrate to preserve configuration watching and cache dependencies.