Skip to content

feat(release): ship esbuild bundle in npm package#19171

Merged
yunaseoul merged 3 commits intogoogle-gemini:mainfrom
genneth:bundle-npm-release
Mar 4, 2026
Merged

feat(release): ship esbuild bundle in npm package#19171
yunaseoul merged 3 commits intogoogle-gemini:mainfrom
genneth:bundle-npm-release

Conversation

@genneth
Copy link
Copy Markdown
Contributor

@genneth genneth commented Feb 15, 2026

Summary

  • Add scripts/prepare-npm-release.js that transforms the CLI package.json to ship bundle/ instead of dist/, strips all dependencies, and adds optionalDependencies for native modules (node-pty, keytar)
  • Add a "Prepare bundled CLI for npm release" step in .github/actions/publish-release/action.yml, conditioned on non-GitHub registry URLs
  • Result: npm package drops from 44,835 files to ~129 files (6.8 MB compressed)

Context

The npm registry publish path ships unbundled dist/ plus full node_modules/, totaling 44,835 files. On Windows, this causes ~1-2 minute cold starts because Windows Defender real-time scanning hits every file on first access.

The GitHub registry path already ships a single-file esbuild bundle via scripts/prepare-github-release.js. This PR applies the same transformation to the npm path, with one addition: optionalDependencies are preserved so platform-specific native modules (node-pty, keytar) continue to install automatically.

Closes #19169

Test plan

  • Local smoke test: npm run bundle then node scripts/prepare-npm-release.js — verified packages/cli/package.json transformation and packages/cli/bundle/ contents
  • Dry-run publish: npm publish --dry-run confirmed 129 files, 6.8 MB, bundle-only contents
  • CI validation on the publish workflow
  • End-to-end: install from published package, verify gemini --version and native module fallbacks

@genneth genneth requested a review from a team as a code owner February 15, 2026 20:00
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @genneth, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly optimizes the npm package release process for the CLI by transitioning from an unbundled distribution to an esbuild-generated bundle. This change addresses performance issues, particularly slow cold starts on Windows, by dramatically reducing the number of files shipped in the package while carefully preserving platform-specific optional native modules.

Highlights

  • New Release Preparation Script: Introduced scripts/prepare-npm-release.js to automate the transformation of the CLI package.json for npm releases, ensuring it ships a bundled version and correctly handles optional native dependencies.
  • CI Workflow Integration: Integrated the new preparation script into the .github/actions/publish-release/action.yml workflow, ensuring it runs specifically for npm registry publications, excluding GitHub registry releases.
  • Package Size Reduction: The changes drastically reduce the npm package size from approximately 44,835 files to around 129 files, leading to a significant decrease in compressed size (6.8 MB) and improved cold start performance on Windows.
Changelog
  • .github/actions/publish-release/action.yml
    • Added a new step to execute the prepare-npm-release.js script conditionally for npm registry publications.
  • scripts/prepare-npm-release.js
    • Created a new script to copy the esbuild bundle, modify the packages/cli/package.json to reference the bundle, remove development dependencies, and re-add specific optional native module dependencies.
Activity
  • The author has completed local smoke tests and a dry-run publish to verify the package.json transformation, bundle contents, and reduced file count.
  • CI validation on the publish workflow and end-to-end testing (install from published package, verify gemini --version and native module fallbacks) are planned for future verification.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Feb 15, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a build script to prepare a bundled version of the CLI for npm release, which is a great improvement for reducing package size and installation time. The changes in the GitHub Actions workflow and the new script are logical. I've found one area for improvement in the new script to make it more robust and maintainable, which I've detailed in a specific comment.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 15, 2026
The npm registry publish path ships unbundled dist/ plus full
node_modules/ (44,835 files), causing ~1-2 minute cold starts on
Windows due to Defender real-time scanning. The GitHub registry
path already ships a single-file bundle with zero dependencies.

Apply the same bundle transformation to the npm publish path:
- Add scripts/prepare-npm-release.js that rewrites the CLI
  package.json to ship bundle/ instead of dist/, removes all
  dependencies, and adds optionalDependencies for native modules
  (node-pty, keytar) so platform-specific features keep working.
- Add a "Prepare bundled CLI for npm release" step in the publish
  action, conditioned on non-GitHub registry URLs.

Result: npm package drops from 44,835 files to ~129 files (6.8 MB).

Closes google-gemini#19169
Instead of maintaining a hardcoded allowlist of native modules,
copy all optionalDependencies from the root package.json and
exclude only gemini-cli-devtools. Less brittle if new native
deps are added in the future.
@genneth
Copy link
Copy Markdown
Contributor Author

genneth commented Feb 27, 2026

Closing this out — looks like the team is tracking bundling under #10168 as an internal roadmap item. Totally understand wanting to own that end-to-end given the cross-platform complexity.

Thanks for the triage and for the work you're doing on this. Happy to help if there's anything useful to pull from this PR down the line. 👋

@genneth genneth closed this Feb 27, 2026
@yunaseoul yunaseoul reopened this Mar 4, 2026
@yunaseoul yunaseoul enabled auto-merge March 4, 2026 22:17
Copy link
Copy Markdown
Contributor

@yunaseoul yunaseoul left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! The logic in this PR looks solid. We’ll move forward with testing this now.

@yunaseoul yunaseoul added this pull request to the merge queue Mar 4, 2026
Merged via the queue into google-gemini:main with commit a5fd5d0 Mar 4, 2026
27 checks passed
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
SUNDRAM07 pushed a commit to SUNDRAM07/gemini-cli that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows cold-start penalty: 44,835 files in node_modules triggers antivirus rescan on every first launch

2 participants