@@ -23,7 +23,11 @@ import {
2323 syncAssets ,
2424} from "./helpers/assets" ;
2525import { getBindings } from "./helpers/binding-utils" ;
26- import { printBundleSize } from "./helpers/bundle-reporter" ;
26+ import {
27+ getSize ,
28+ printBundleSize ,
29+ type BundleSize ,
30+ } from "./helpers/bundle-reporter" ;
2731import { confirmLatestDeploymentOverwrite } from "./helpers/confirm-latest-deployment-overwrite" ;
2832import { createWorkerUploadForm } from "./helpers/create-worker-upload-form" ;
2933import { deployWfpUserWorker } from "./helpers/deploy-wfp" ;
@@ -140,6 +144,7 @@ type DeployResult = {
140144 workerTag : string | null ;
141145 assetUploadStats ?: AssetUploadStats ;
142146 targets ?: string [ ] ;
147+ bundleSize ?: BundleSize ;
143148} ;
144149
145150export default async function deploy (
@@ -161,6 +166,12 @@ export default async function deploy(
161166 targets : result . targets ,
162167 wrangler_environment : props . env ,
163168 worker_name_overridden : props . workerNameOverridden ?? false ,
169+ bundle_size : result . bundleSize
170+ ? {
171+ raw_bytes : result . bundleSize . size ,
172+ gzip_bytes : result . bundleSize . gzipSize ,
173+ }
174+ : undefined ,
164175 } ) ;
165176
166177 return result ;
@@ -367,10 +378,8 @@ async function deployWorker(
367378 0
368379 ) ;
369380
370- await printBundleSize (
371- { name : path . basename ( resolvedEntryPointPath ) , content : content } ,
372- modules
373- ) ;
381+ const bundleSize = await getSize ( [ ...modules , { content } ] ) ;
382+ printBundleSize ( bundleSize ) ;
374383
375384 // We can use the new versions/deployments APIs if we:
376385 // * are uploading a worker that already exists
@@ -746,7 +755,7 @@ async function deployWorker(
746755
747756 if ( isDryRun ) {
748757 logger . log ( `--dry-run: exiting now.` ) ;
749- return { versionId, workerTag } ;
758+ return { versionId, workerTag, bundleSize } ;
750759 }
751760
752761 const uploadMs = Date . now ( ) - start ;
@@ -769,7 +778,7 @@ async function deployWorker(
769778 // Early exit for WfP since it doesn't need the below code
770779 if ( props . dispatchNamespace !== undefined ) {
771780 deployWfpUserWorker ( props . dispatchNamespace , versionId ) ;
772- return { versionId, workerTag, assetUploadStats } ;
781+ return { versionId, workerTag, assetUploadStats, bundleSize } ;
773782 }
774783 assert ( accountId ) ;
775784 // deploy triggers
@@ -793,5 +802,6 @@ async function deployWorker(
793802 workerTag,
794803 assetUploadStats,
795804 targets : targets ?? [ ] ,
805+ bundleSize,
796806 } ;
797807}
0 commit comments