Skip to content

Conversation

@lvndry
Copy link
Owner

@lvndry lvndry commented Jan 20, 2026

Summary

This PR achieves a ~50% reduction in bundle size by replacing the monolithic googleapis dependency 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

  • Replaced googleapis (monolithic package) with scoped packages:
    • @googleapis/gmail (v16.1.1)
    • @googleapis/calendar (v14.2.0)
    • googleapis-common (v8.0.1)
  • Refactored Gmail and Calendar services to use scoped imports:
    • Changed from google.auth.OAuth2auth.OAuth2 (from scoped packages)
    • Changed from google.gmail()gmail() (from @googleapis/gmail)
    • Changed from google.calendar()calendar() (from @googleapis/calendar)
  • Updated all service tests to match new import patterns

🏗️ Build Pipeline Overhaul

  • Created scripts/build.ts - new build script that:
    • Bundles from src/entry.tsdist/main.js using Bun
    • Applies minification and Node.js target
    • Adds executable shebang (#!/usr/bin/env node)
    • Externalizes heavy UI dependencies (keeps them out of bundle):
      • react, ink, ink-gradient, cfonts, ink-big-text
    • Runs TypeScript declaration generation after bundling
  • Updated package.json build script to use new build pipeline

🚀 Bootstrap Entrypoint

  • Created src/entry.ts - lightweight bootstrap that:
    • Sets process.noDeprecation = true before importing main module
    • Suppresses noisy Node.js deprecation warnings (e.g., punycode warnings from transitive deps)
    • Dynamically imports src/main.ts with error handling

🧹 Tooling & Config Improvements

  • Updated ESLint config to type-check both tsconfig.json and tsconfig.build.json
  • Added tsconfig.build.json for build scripts type-checking
  • Removed legacy debug scripts (scripts/debug-keys.mjs, scripts/debug-parser.mjs)
  • Added .agent/ to .gitignore

Bundle Size Impact

Result: ~50% reduction in bundle size

Why This Works:

  1. Dependency Footprint Reduction: The monolithic googleapis package includes ALL Google APIs (~100+ services). By switching to scoped packages, we only bundle what we actually use (Gmail + Calendar APIs).
  2. Externalized Dependencies: Heavy UI/runtime dependencies are marked as --external in the build, meaning they're not bundled into dist/main.js. They're still required at runtime (via node_modules), but the bundle itself is much smaller.

Behavior Changes / Notes

  • Runtime Dependencies: The externalized UI dependencies (react, ink, etc.) must be present in node_modules at runtime. They're already declared in package.json dependencies, so normal installation (npm install, bun install) handles this automatically. Users don't need to install anything separately.
  • Deprecation Warnings Suppressed: CLI startup will no longer emit Node.js DeprecationWarning output (including the noisy punycode warning from transitive dependencies on newer Node versions).

Risk Assessment

  • Medium Risk: Google API client refactor could introduce subtle differences in OAuth client construction or API client initialization. Mitigated by existing comprehensive test coverage for Gmail/Calendar services.
  • Low Risk: Build pipeline changes are mostly mechanical, but externalization means "missing dependency" errors would surface at runtime if installation is incomplete.

Test Plan

  • Build Verification: Run bun run build and verify dist/main.js is generated with correct shebang
  • Type Generation: Verify TypeScript declaration files are generated correctly
  • CLI Smoke Test: Run bun run start (or node dist/main.js) and verify CLI starts without deprecation warnings
  • Service Tests: Run existing Gmail/Calendar service tests to validate API client refactor works correctly

@lvndry lvndry merged commit 5d96d55 into main Jan 20, 2026
5 checks passed
@lvndry lvndry deleted the bundle-size branch January 20, 2026 10:05
daryllundy added a commit to daryllundy/jazz that referenced this pull request Jan 20, 2026
* main:
  chore: reduce bundle size by 50% (lvndry#129)
  feat: Agent skills (lvndry#127)
  feat: edit file show diff (lvndry#128)
  0.6.2
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