-
-
Notifications
You must be signed in to change notification settings - Fork 59
feat: support more param for build command #1258
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 adds comprehensive CLI option support for the rslib build
command, allowing users to override config file settings through command line parameters. The feature supports commonly used build options like format, entry points, output directory, bundling mode, and other build configurations.
Key changes:
- Added extensive CLI option parsing for build command parameters
- Implemented option overriding functionality that applies CLI values over config file settings
- Updated documentation to reflect new CLI capabilities
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
packages/core/src/cli/initConfig.ts | New module implementing CLI option parsing and config merging logic |
packages/core/src/cli/commands.ts | Added CLI option definitions and updated command handlers to use new config system |
packages/core/src/cli/init.ts | Removed original init function (replaced by initConfig) |
tests/integration/cli/build/build.test.ts | Added comprehensive tests for CLI option functionality |
tests/scripts/shared.ts | Enhanced test utilities with config extraction and better error handling |
website/docs/*/guide/basic/cli.mdx | Updated documentation with new CLI options for both English and Chinese |
packages/core/tests/config.test.ts | Added unit tests for CLI option application |
packages/core/tests/cli.test.ts | Added unit tests for option parsing functions |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if (options.bundle !== undefined) lib.bundle = options.bundle; | ||
if (options.dts !== undefined) lib.dts = options.dts; | ||
if (options.autoExtension !== undefined) | ||
lib.autoExtension = options.autoExtension; |
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.
The assignment of options.autoExtension
to lib.autoExtension
should maintain type consistency. Based on the test snapshot showing autoExtension: 'false'
as a string, consider ensuring boolean values are properly handled or document the expected type behavior.
lib.autoExtension = options.autoExtension; | |
lib.autoExtension = | |
typeof options.autoExtension === 'string' | |
? options.autoExtension === 'true' || options.autoExtension === '1' | |
: Boolean(options.autoExtension); |
Copilot uses AI. Check for mistakes.
if (options.distPath) { | ||
output.distPath ??= {}; | ||
output.distPath.root = options.distPath; | ||
} |
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.
The assignment to output.distPath
should be updated to maintain the existing structure. The code assigns to lib.output
but then modifies a local output
variable without reassigning it back to lib.output
.
} | |
} | |
lib.output = output; |
Copilot uses AI. Check for mistakes.
✅ Deploy Preview for rslib ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
0819f3b
to
b4e70c7
Compare
Summary
support more build options, there are no plans to support all options, as some options can be written very complexly. this PR only supports some commonly used options, allowing overriding options in the config file when executing
rslib build
.the next step is to remove the constraint of requiring a configuration file, so that we can build entirely through CLI parameters, e.g.
rslib build --format=cjs --dist-path=dist/cjs
.Related Links
Checklist