Skip to content

Commit

Permalink
The new maximum allowed/suggested size for Workers is 10MB, added tha…
Browse files Browse the repository at this point in the history
…t adjustment to the PR
  • Loading branch information
JacobMGEvans committed Sep 14, 2023
1 parent 4053bc5 commit b86c715
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/wrangler/src/deployment-bundle/bundle-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { CfModule } from "./worker";
import type { Metafile } from "esbuild";

const ONE_KIB_BYTES = 1024;
const ONE_MIB_BYTES = ONE_KIB_BYTES * 1024;
const ALLOWED_MAX_SIZE = ONE_KIB_BYTES * ONE_KIB_BYTES * 10; // Current max is 10 MiB

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

const percentage = (gzipSize / ONE_MIB_BYTES) * 100;
const percentage = (gzipSize / ALLOWED_MAX_SIZE) * 100;

const colorizedReport =
percentage > 90
Expand All @@ -41,9 +41,9 @@ export async function printBundleSize(

logger.log(`Total Upload: ${colorizedReport}`);

if (gzipSize > ONE_MIB_BYTES && !process.env.NO_SCRIPT_SIZE_WARNING) {
if (gzipSize > ALLOWED_MAX_SIZE && !process.env.NO_SCRIPT_SIZE_WARNING) {
logger.warn(
"We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding past this can affect cold start time"
"We recommend keeping your script less than 10MiB (10240 KiB) after gzip. Exceeding past this can affect cold start time"
);
}
}
Expand Down

0 comments on commit b86c715

Please sign in to comment.