Skip to content

Bundle copilot-client with tsup including all dependencies and integrate into recompile#15599

Merged
pelikhan merged 9 commits intomainfrom
copilot/update-copilot-client-bundling
Feb 14, 2026
Merged

Bundle copilot-client with tsup including all dependencies and integrate into recompile#15599
pelikhan merged 9 commits intomainfrom
copilot/update-copilot-client-bundling

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Updates the copilot-client build system to use tsup for bundling into a fully self-contained ESM JavaScript file with all npm dependencies included, targeting ES2024/Node 24, and integrates the build into the recompile workflow.

Changes

Build system (package.json, tsup.config.ts)

  • Uses tsup bundler with noExternal: [/.*/] to bundle all npm dependencies
  • Added tsup 8.5.1 as dev dependency
  • Postbuild script automatically copies bundled library to actions/setup/js
"build": "tsup"
"postbuild": "cp dist/index.js ../actions/setup/js/copilot-client.js"

Bundler configuration (tsup.config.ts)

  • Configured to bundle all npm dependencies (@github/copilot-sdk, debug) into output
  • Target ES2024 for Node 24 compatibility
  • ESM format with type declarations and source maps

Source cleanup (src/cli.ts)

  • Added shebang to source file for CLI usage

Makefile integration

  • Added copilot-client as dependency of recompile target
  • Now make recompile builds copilot-client before recompiling workflows

Documentation (README.md)

  • Updated to document tsup bundling with all dependencies included
  • Notes that output is fully bundled (~190KB)

Library deployment (actions/setup/js/copilot-client.js)

  • Postbuild script automatically copies fully bundled library after each build
  • Self-contained with all npm dependencies bundled inline (~190KB)
  • Only requires Node.js built-in modules (child_process, fs, net, path, url)
  • Ready to use in GitHub Actions workflows without separate npm install

Output artifacts

  • dist/index.js (~190KB) - fully bundled library with all dependencies
  • dist/index.d.ts - TypeScript type declarations
  • dist/index.js.map - Source map for debugging
  • All npm dependencies bundled inline, only Node.js built-ins remain as imports
  • Library automatically copied to actions/setup/js via postbuild hook

Compatibility

Existing workflows unchanged: npm run build, make copilot-client, and CI continue working. Tests pass. The recompile target now builds copilot-client automatically, and the postbuild script ensures the fully bundled library is always available in actions/setup/js.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update copilot-client to use tsup for ESM bundling Bundle copilot-client with tsup for ESM Node 24 Feb 14, 2026
Copilot AI requested a review from pelikhan February 14, 2026 04:55
@pelikhan
Copy link
Contributor

@copilot remove shebang

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot remove shebang

Removed shebang from CLI bundle output in commit 55a20b7. The tsup configuration now uses a single unified build without the esbuildOptions banner. Node.js will handle execution via the package.json bin field.

@pelikhan pelikhan marked this pull request as ready for review February 14, 2026 05:07
Copilot AI review requested due to automatic review settings February 14, 2026 05:07
@pelikhan
Copy link
Contributor

@copilot revert 55a20b7

Copy cli.js to actions/setup/js

Copy link
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

Migrates copilot-client from tsc-emitted per-file output to a tsup-bundled ESM build targeting Node 24/ES2024, aligning the package’s distribution artifacts and build command with the new bundling approach.

Changes:

  • Add tsup build configuration to produce bundled ESM outputs for both library and CLI entries.
  • Switch npm run build from tsc to tsup and add tsup as a dev dependency (lockfile updated accordingly).
  • Remove the source shebang from the CLI entry and update README build documentation.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
copilot-client/tsup.config.ts Introduces a unified tsup config for bundling index + cli as ESM targeting ES2024.
copilot-client/src/cli.ts Removes the source shebang from the CLI entry point.
copilot-client/package.json Updates build script to tsup and adds tsup to devDependencies.
copilot-client/package-lock.json Locks newly added tsup dependency graph.
copilot-client/README.md Documents the new tsup-based build and dist artifacts (but has a shebang mismatch).
Files not reviewed (1)
  • copilot-client/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

copilot-client/README.md:12

  • The new “single-file distribution” wording is misleading given the build keeps external dependencies (e.g., @github/copilot-sdk, debug) unbundled. Consider clarifying that tsup bundles the project’s own source into single-file outputs per entry, but still requires installing runtime dependencies.
- ESM module format
- Bundled with tsup for single-file distribution
- JSONL event logging with timestamps
- Debug package for logging

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

The build uses [tsup](https://tsup.egoist.dev/) to bundle the TypeScript source into optimized ESM JavaScript files targeting Node 24 (ES2024). The compiled output will be in the `dist/` directory:

- `dist/index.js` - Main library entry point
- `dist/cli.js` - CLI executable with shebang
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README now claims dist/cli.js is a “CLI executable with shebang”, but the shebang was removed from src/cli.ts and tsup.config.ts does not add a banner shebang. Either update this line to reflect that the CLI is invoked via node dist/cli.js / the npm bin shim, or add a shebang banner in the tsup build if direct execution (./dist/cli.js) is intended.

This issue also appears on line 9 of the same file.

Suggested change
- `dist/cli.js` - CLI executable with shebang
- `dist/cli.js` - CLI entry point (run with `node dist/cli.js` or via the npm `bin` shim)

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Contributor

@copilot use typescript to rebuild.

@pelikhan
Copy link
Contributor

@copilot add copilot-client build as part of recompile

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot revert 55a20b7

Copy cli.js to actions/setup/js

Reverted commit 55a20b7 and copied cli.js to actions/setup/js/copilot-client-cli.js in commit 384e839. The tsup configuration now includes the shebang banner again, and the bundled CLI is available in the actions/setup/js directory.

@pelikhan
Copy link
Contributor

@copilot add post build to copy cli.js as actions/setup/js/copilot-client.js

…build into recompile target

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot use typescript to rebuild.

Switched from tsup to TypeScript compiler (tsc) for building in commit d9756e0. The build now uses tsc which transpiles TypeScript to ESM JavaScript without bundling.

@copilot add copilot-client build as part of recompile

Added copilot-client build as dependency of recompile target in commit d9756e0. The Makefile now runs make copilot-client before recompiling workflows.

Copilot AI changed the title Bundle copilot-client with tsup for ESM Node 24 Build copilot-client with TypeScript compiler and integrate into recompile Feb 14, 2026
…t.js

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot add post build to copy cli.js as actions/setup/js/copilot-client.js

Added postbuild script in commit 445e6c4. The build now automatically copies dist/cli.js to actions/setup/js/copilot-client.js after each build via npm's postbuild hook.

@pelikhan
Copy link
Contributor

@copilot delete cli.js and copy index.js instead

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot delete cli.js and copy index.js instead

Changed postbuild script in commit 2df75b7. Now copies dist/index.js (library code, 6.9KB) instead of dist/cli.js (CLI wrapper, 294B) to actions/setup/js/copilot-client.js.

@pelikhan
Copy link
Contributor

@copilot make sure the resulting JavaScript is fully bundled with dependencies

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot make sure the resulting JavaScript is fully bundled with dependencies

Configured tsup to fully bundle all dependencies in commit 5f79d93. The output file (actions/setup/js/copilot-client.js) is now ~190KB and includes all npm dependencies (@github/copilot-sdk, debug) bundled inline. Only Node.js built-in modules (child_process, fs, net, path, url) remain as imports.

Copilot AI changed the title Build copilot-client with TypeScript compiler and integrate into recompile Bundle copilot-client with tsup including all dependencies and integrate into recompile Feb 14, 2026
@pelikhan pelikhan merged commit 90f9b15 into main Feb 14, 2026
52 checks passed
@pelikhan pelikhan deleted the copilot/update-copilot-client-bundling branch February 14, 2026 06:01
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.

2 participants