Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How I Cut 40KB from My Edge Bundle with Zero-Dep Utils

说明与用途

通过将大型依赖替换为零依赖工具,将 Cloudflare Workers 的包大小从约 40 KB 减少到约 2 KB,提升冷启动速度并符合限制。

问题

Large bundle size in Cloudflare Workers caused cold start delays and exceeded free tier limits.

结果

Reduced bundle size from ~40 KB to ~2 KB, a 95 % reduction, eliminating large dependencies and container usage.

工作流

  • Identify utilities inflating bundle size.
  • Select or build zero‑dependency replacements.
  • Integrate fetch-retry-jitter for retry logic.
  • Integrate env-assert-typed for environment validation.
  • Replace tj-actions/changed-files with ci-diff-changed in GitHub Actions.
  • Measure bundle size before and after.
  • Publish results and provide starter templates.

证据

Every "lightweight" utility pulled in dependencies. zod (1.1 MB), p-retry (7 KB + deps), axios-retry (requires axios).

来源

fetch-retry-jitter (1.6 KB gzip)

来源

env-assert-typed (528 B gzip)

来源

ci-diff-changed (Action, ~80 lines bash)

来源

Total bundle reduction: ~40 KB → ~2 KB (95% reduction)

来源

  • 记录日期: 2026-11-01T08:14:18.769Z