@@ -13,7 +13,7 @@ import cron from "node-cron";
1313import sourceMap , { UrlAndMap } from "source-map-support" ;
1414import StandardWebSocket from "ws" ;
1515import Youch from "youch" ;
16- import { MiniflareError } from "./helpers" ;
16+ import { MiniflareError , formatSize } from "./helpers" ;
1717import { Cache , KVStorageNamespace } from "./kv" ;
1818import { ConsoleLog , Log , NoOpLog , logResponse } from "./log" ;
1919import { ResponseWaitUntil } from "./modules" ;
@@ -146,6 +146,9 @@ export class Miniflare {
146146 // processedModulesRules are always set in this
147147 assert ( this . #options?. scripts && this . #options. processedModulesRules ) ;
148148
149+ // Keep track of the size in bytes of all scripts
150+ let size = 0 ;
151+
149152 // Build modules linker maintaining set of referenced paths for watching
150153 const linker = new ScriptLinker ( this . #options. processedModulesRules ) ;
151154 this . #extraSourceMaps = linker . extraSourceMaps ;
@@ -170,6 +173,7 @@ export class Miniflare {
170173 this . log . debug ( `Reloading ${ path . relative ( "" , script . fileName ) } ...` ) ;
171174
172175 // Parse script and build instance
176+ size += Buffer . byteLength ( script . code , "utf8" ) ;
173177 let instance : ScriptScriptInstance | ModuleScriptInstance < ModuleExports > ;
174178 try {
175179 instance = this . #options. modules
@@ -240,7 +244,15 @@ export class Miniflare {
240244 ws . close ( 1012 , "Service Restart" ) ;
241245 }
242246
243- this . log . info ( "Worker reloaded!" ) ;
247+ // Log total size of worker with warning if required
248+ size += linker . referencedPathsTotalSize ;
249+ this . log . info ( `Worker reloaded! (${ formatSize ( size ) } )` ) ;
250+ if ( size > 1_048_576 )
251+ this . log . warn (
252+ "Worker's uncompressed size exceeds 1MiB!" +
253+ "Note that your worker will be compressed during upload " +
254+ "so you may still be able to deploy it."
255+ ) ;
244256 }
245257
246258 /** @deprecated Since 1.2.0, this is just an alias for reloadOptions() */
0 commit comments