chore: reduce bundle size by 50% #129
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR achieves a ~50% reduction in bundle size by replacing the monolithic
googleapisdependency with scoped Google API packages and optimizing the build pipeline to externalize heavy UI/runtime dependencies from the bundled output.Key Changes
🔄 Google API Dependency Split
googleapis(monolithic package) with scoped packages:@googleapis/gmail(v16.1.1)@googleapis/calendar(v14.2.0)googleapis-common(v8.0.1)google.auth.OAuth2→auth.OAuth2(from scoped packages)google.gmail()→gmail()(from@googleapis/gmail)google.calendar()→calendar()(from@googleapis/calendar)🏗️ Build Pipeline Overhaul
scripts/build.ts- new build script that:src/entry.ts→dist/main.jsusing Bun#!/usr/bin/env node)react,ink,ink-gradient,cfonts,ink-big-textpackage.jsonbuild script to use new build pipeline🚀 Bootstrap Entrypoint
src/entry.ts- lightweight bootstrap that:process.noDeprecation = truebefore importing main modulepunycodewarnings from transitive deps)src/main.tswith error handling🧹 Tooling & Config Improvements
tsconfig.jsonandtsconfig.build.jsontsconfig.build.jsonfor build scripts type-checkingscripts/debug-keys.mjs,scripts/debug-parser.mjs).agent/to.gitignoreBundle Size Impact
Result: ~50% reduction in bundle size
Why This Works:
googleapispackage includes ALL Google APIs (~100+ services). By switching to scoped packages, we only bundle what we actually use (Gmail + Calendar APIs).--externalin the build, meaning they're not bundled intodist/main.js. They're still required at runtime (vianode_modules), but the bundle itself is much smaller.Behavior Changes / Notes
react,ink, etc.) must be present innode_modulesat runtime. They're already declared inpackage.jsondependencies, so normal installation (npm install,bun install) handles this automatically. Users don't need to install anything separately.DeprecationWarningoutput (including the noisypunycodewarning from transitive dependencies on newer Node versions).Risk Assessment
Test Plan
bun run buildand verifydist/main.jsis generated with correct shebangbun run start(ornode dist/main.js) and verify CLI starts without deprecation warnings