feat(release): ship esbuild bundle in npm package#19171
feat(release): ship esbuild bundle in npm package#19171genneth wants to merge 2 commits intogoogle-gemini:mainfrom
Conversation
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
Summary of ChangesHello @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
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
|
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. |
There was a problem hiding this comment.
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.
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.
Summary
scripts/prepare-npm-release.jsthat transforms the CLIpackage.jsonto shipbundle/instead ofdist/, strips all dependencies, and addsoptionalDependenciesfor native modules (node-pty, keytar).github/actions/publish-release/action.yml, conditioned on non-GitHub registry URLsContext
The npm registry publish path ships unbundled
dist/plus fullnode_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:optionalDependenciesare preserved so platform-specific native modules (node-pty, keytar) continue to install automatically.Closes #19169
Test plan
npm run bundlethennode scripts/prepare-npm-release.js— verifiedpackages/cli/package.jsontransformation andpackages/cli/bundle/contentsnpm publish --dry-runconfirmed 129 files, 6.8 MB, bundle-only contentsgemini --versionand native module fallbacks