-
-
Notifications
You must be signed in to change notification settings - Fork 59
feat!: add JavaScript API and enhance CLI behaviour #1394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
59330fc to
f61d16c
Compare
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