Skip to content

perf: @happyvertical/files barrel export pulls in 23.8MB googleapis via GoogleDriveProvider #888

@willgriffin

Description

@willgriffin

Problem

The @happyvertical/files package barrel-exports GoogleDriveProvider from src/providers/gdrive.ts, which statically imports the full googleapis npm package (~23.8 MB, 641K lines).

When consumers bundle @happyvertical/files for SSR (e.g. via Vite ssr.noExternal), the entire Google APIs library is pulled into the server bundle — even if the consumer never uses Google Drive.

In our case this caused a Node.js OOM crash during @anytown/template-small-town build (exit code 137).

Impact

  • OOM crashes during production builds on machines with default Node heap (< 4GB)
  • 23.8 MB server chunk (index30.js) generated even when Google Drive is not used
  • Slow cold starts from loading the massive googleapis bundle

Suggested Fixes

  1. Lazy import: Change GoogleDriveProvider to use await import("googleapis") in its constructor/init method rather than a top-level import
  2. Separate entry point: Export GoogleDriveProvider from a separate sub-path like @happyvertical/files/gdrive instead of the barrel
  3. Use @googleapis/drive: Replace the heavyweight googleapis package with the lighter single-service @googleapis/drive package (~200KB)

Workaround

Consumers can add googleapis to their Vite ssr.external array:

// vite.config.ts
ssr: {
  external: ["googleapis"],
}

Environment

  • @happyvertical/files (latest via `@happyve

Impact

-core` v0.20.47)

  • Vite 5.x with SvelteKit adapter-node
  • Node.js v25.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions