Skip to content

Conversation

fi3ework
Copy link
Member

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

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings September 29, 2025 15:15
Copy link
Contributor

@Copilot Copilot AI left a 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;
Copy link
Preview

Copilot AI Sep 29, 2025

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.

Suggested change
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;
}
Copy link
Preview

Copilot AI Sep 29, 2025

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.

Suggested change
}
}
lib.output = output;

Copilot uses AI. Check for mistakes.

Copy link

netlify bot commented Sep 29, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 0819f3b
🔍 Latest deploy log https://app.netlify.com/projects/rslib/deploys/68daa424d2f1430008670b78
😎 Deploy Preview https://deploy-preview-1258--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@fi3ework fi3ework force-pushed the op branch 2 times, most recently from 0819f3b to b4e70c7 Compare September 29, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant