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
- Lazy import: Change
GoogleDriveProvider to use await import("googleapis") in its constructor/init method rather than a top-level import
- Separate entry point: Export
GoogleDriveProvider from a separate sub-path like @happyvertical/files/gdrive instead of the barrel
- 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
Problem
The
@happyvertical/filespackage barrel-exportsGoogleDriveProviderfromsrc/providers/gdrive.ts, which statically imports the fullgoogleapisnpm package (~23.8 MB, 641K lines).When consumers bundle
@happyvertical/filesfor SSR (e.g. via Vitessr.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-townbuild (exit code 137).Impact
index30.js) generated even when Google Drive is not usedSuggested Fixes
GoogleDriveProviderto useawait import("googleapis")in its constructor/init method rather than a top-level importGoogleDriveProviderfrom a separate sub-path like@happyvertical/files/gdriveinstead of the barrel@googleapis/drive: Replace the heavyweightgoogleapispackage with the lighter single-service@googleapis/drivepackage (~200KB)Workaround
Consumers can add
googleapisto their Vitessr.externalarray:Environment
@happyvertical/files(latest via `@happyveImpact
-core` v0.20.47)