Skip to content

Commit

Permalink
refactor(wrangler): max bundle size is now 3MiB (#7913)
Browse files Browse the repository at this point in the history
* refactor(wrangler): max bundle size is now 3MiB
  • Loading branch information
vicb authored Jan 28, 2025
1 parent bd9228e commit 510d599
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/wrangler/src/deployment-bundle/bundle-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import type { CfModule } from "./worker";
import type { Metafile } from "esbuild";

const ONE_KIB_BYTES = 1024;
const ALLOWED_INITIAL_MAX = ONE_KIB_BYTES * 1024; // Current max is 1 MiB
// Current max is 3 MiB for free accounts, 10 MiB for paid accounts.
// See https://developers.cloudflare.com/workers/platform/limits/#worker-size
const MAX_GZIP_SIZE_BYTES = 3 * ONE_KIB_BYTES * ONE_KIB_BYTES;

async function getSize(modules: Pick<CfModule, "content">[]) {
const gzipSize = gzipSync(
Expand All @@ -30,7 +32,7 @@ export async function printBundleSize(
gzipSize / ONE_KIB_BYTES
).toFixed(2)} KiB`;

const percentage = (gzipSize / ALLOWED_INITIAL_MAX) * 100;
const percentage = (gzipSize / MAX_GZIP_SIZE_BYTES) * 100;

const colorizedReport =
percentage > 90
Expand Down

0 comments on commit 510d599

Please sign in to comment.