feat!: add JavaScript API and enhance CLI behaviour#1394
Merged
Timeless0911 merged 5 commits intomainfrom Dec 29, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the CLI initialization and error handling to improve user experience. The main changes include renaming the public API from runCli to runCLI (following proper casing convention), consolidating CLI setup logic, and implementing smarter output formatting for different package managers. The refactor also adds a process title for easier identification and simplifies build error logging.
Key changes:
- Renamed public API
runClitorunCLIand consolidated CLI initialization logic into a new/cli/index.tsfile - Removed the
prepareClifunction and integrated its functionality into the main CLI entry point - Enhanced package manager detection to handle output formatting for npx, Bun, and Node.js
--runcommand - Introduced
RSPACK_BUILD_ERRORconstant to conditionally suppress redundant error messages - Renamed internal function
initConfigtoinitfor better clarity
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/index.ts | Updated public API exports: renamed runCli to runCLI and removed prepareCli export |
| packages/core/src/cli/prepare.ts | Deleted file - functionality moved to /cli/index.ts |
| packages/core/src/cli/init.ts | Renamed function from initConfig to init |
| packages/core/src/cli/index.ts | New file consolidating CLI initialization with improved package manager detection and greeting logic |
| packages/core/src/cli/commands.ts | Added RSPACK_BUILD_ERROR constant and error filtering logic; renamed import from initConfig to init; updated import path |
| packages/core/bin/rslib.js | Simplified entry point to call runCLI directly without try-catch wrapper |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
8320ba4 to
e2d7a37
Compare
chenjiahan
reviewed
Dec 24, 2025
08eb493 to
eb74ce2
Compare
fi3ework
reviewed
Dec 25, 2025
fi3ework
approved these changes
Dec 29, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Highlights 💡
New JavaScript API
This release introduces a new, comprehensive JavaScript API for Rslib.
Caution
This is a Breaking Change. The previously exposed informal API has been removed. You can switch to the new JavaScript API and refer to the docs below to re-integrate.
See the API docs for details:
Usage
@rslib/corepackage:Summary
Provide a comprehensive JavaScript API
Type:
Example:
Refactor public API
Core methods:
runCLIcreateRslibdefineConfigloadConfigloadEnvmergeRslibConfigVerbose Rslib/Rsbuild/Rspack configurations when running with
DEBUG=rslibAdd
--no-envcli options to control disable loading of .env files after refactorRelated Links
close: #1040
close: #967
Checklist