Skip to content

feat(cli): replace vite-lib config with direct tsdown integration#381

Merged
fengmk2 merged 1 commit intomainfrom
vite-lib-cli-using-tsdown-js-api
Jan 4, 2026
Merged

feat(cli): replace vite-lib config with direct tsdown integration#381
fengmk2 merged 1 commit intomainfrom
vite-lib-cli-using-tsdown-js-api

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Jan 4, 2026

TL;DR

Replaced the Rust-based Vite lib config generation with a Node.js implementation using the cac CLI library.

What changed?

  • Removed the Rust code that was generating a temporary Vite lib config file
  • Added a new lib-bin.ts file that implements the lib command functionality in Node.js
  • Updated resolve-lib.ts to point to the new Node.js implementation
  • Added cac as a dependency for command-line argument parsing
  • Created a simple test CLI file to demonstrate cac usage

How to test?

  1. Run vite lib command with various options
  2. Verify that the command correctly processes arguments and passes them to tsdown
  3. Check that the lib command correctly reads configuration from vite.config.ts

Why make this change?

This change simplifies the architecture by moving the lib command implementation from Rust to Node.js. Using cac for command-line parsing provides better flexibility and maintainability for the CLI interface. The Node.js implementation can directly interact with the tsdown API without needing to generate intermediate configuration files.


Note

Moves vite lib to a Node-based implementation and removes the interim Vite config generation.

  • Adds src/lib-bin.ts using cac to implement vite lib, resolving vite.config.ts, forwarding flags, and calling build from @voidzero-dev/vite-plus-core/lib
  • Removes Rust write_vite_lib_config path; simplifies cli.rs to call lib without generating vite-lib.config.js
  • Updates resolve-lib.ts to run bundled lib-bin.js instead of tsdown’s run.js
  • Refreshes help/flags and snapshots for vite lib; example outputs now show index.mjs
  • Adds cac to workspace and lockfile

Written by Cursor Bugbot for commit 7a5dbf8. This will update automatically on new commits. Configure here.

@fengmk2 fengmk2 changed the title feat: create custom lib cli to call tsdown js api feat(cli): replace vite-lib config with direct tsdown integration Jan 4, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Jan 4, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 self-assigned this Jan 4, 2026
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 9089b4f to eb49060 Compare January 4, 2026 05:48
@fengmk2 fengmk2 marked this pull request as ready for review January 4, 2026 05:57
@fengmk2 fengmk2 requested review from Brooooooklyn and Copilot and removed request for Copilot January 4, 2026 05:57
Comment thread packages/cli/src/testcli.ts Outdated
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from eb49060 to 27bc06c Compare January 4, 2026 06:08
Copilot AI review requested due to automatic review settings January 4, 2026 06:08
Comment thread packages/cli/src/lib-bin.ts Outdated
Copy link
Copy Markdown
Contributor

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 replaces the Rust-based Vite lib config generation with a Node.js implementation using the cac CLI library to simplify the architecture and enable direct interaction with the tsdown API.

Key Changes:

  • Removed Rust code that generated temporary Vite lib config files
  • Implemented lib command in Node.js using cac for CLI parsing and tsdown's build API
  • Updated path resolution to point to the new lib-bin.js instead of tsdown's CLI

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/cli/src/lib-bin.ts New Node.js implementation of the lib command with CLI parsing and tsdown integration
packages/cli/src/resolve-lib.ts Updated binPath to point to lib-bin.js instead of tsdown's run.js
packages/cli/binding/src/cli.rs Removed Rust code for generating temporary vite-lib.config.js files
packages/cli/package.json Added cac dependency for CLI argument parsing
pnpm-workspace.yaml Added cac to the catalog
pnpm-lock.yaml Updated lockfile with cac dependency
packages/cli/snap-tests/command-lib/snap.txt Updated test snapshots to reflect new CLI output without tsdown version/config messages
packages/cli/snap-tests/command-lib-monorepo/snap.txt Updated test snapshots showing format change from cjs to mjs
packages/cli/snap-tests/command-helper/snap.txt Updated help output snapshots for the new CLI interface
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/resolve-lib.ts
Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/src/lib-bin.ts Outdated
Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/snap-tests/command-lib-monorepo/snap.txt Outdated
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 27bc06c to 7a5dbf8 Compare January 4, 2026 06:14
@Brooooooklyn
Copy link
Copy Markdown
Member

cursor review

Comment thread packages/cli/package.json Outdated
Comment thread packages/cli/src/lib-bin.ts Outdated
Copilot AI review requested due to automatic review settings January 4, 2026 06:24
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 7a5dbf8 to 71104a0 Compare January 4, 2026 06:24
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 71104a0 to 6a9597b Compare January 4, 2026 06:27
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/src/lib-bin.ts
Comment thread packages/cli/src/lib-bin.ts
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 6a9597b to 6a4e3b6 Compare January 4, 2026 06:32
Copilot AI review requested due to automatic review settings January 4, 2026 06:36
@fengmk2 fengmk2 force-pushed the vite-lib-cli-using-tsdown-js-api branch from 6a4e3b6 to 6fe7515 Compare January 4, 2026 06:36
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/cli/src/resolve-lib.ts:23

  • The documentation comment still refers to "Tsdown binary path" and "resolves the Tsdown binary path using Node.js module resolution" and "executes Tsdown for running lib", but the implementation has changed to use a custom lib-bin.js file instead of Tsdown's binary. The comments should be updated to accurately reflect that this now resolves the custom lib command implementation rather than directly pointing to Tsdown.
 * Tsdown tool resolver for the vite-plus CLI.
 *
 * This module exports a function that resolves the Tsdown binary path
 * using Node.js module resolution. The resolved path is passed back
 * to the Rust core, which then executes Tsdown for running lib.
 *
 * Used for: `vite-plus lib` command
 */

import { join } from 'node:path';

import { DEFAULT_ENVS } from './utils.js';

/**
 * Resolves the Tsdown binary path and environment variables.
 *
 * @returns Promise containing:
 *   - binPath: Absolute path to the Tsdown CLI entry point
 *   - envs: Environment variables to set when executing Tsdown
 *
 * Tsdown is a tool that provides a library for building JavaScript/TypeScript libraries.
 */

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 merged commit e6f1154 into main Jan 4, 2026
17 of 18 checks passed
Copy link
Copy Markdown
Member Author

fengmk2 commented Jan 4, 2026

Merge activity

@fengmk2 fengmk2 deleted the vite-lib-cli-using-tsdown-js-api branch January 4, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants