@@ -9,12 +9,11 @@ import {
99} from "../ai/fetcher" ;
1010import { ModuleTypeToRuleType } from "../deployment-bundle/module-collection" ;
1111import { withSourceURLs } from "../deployment-bundle/source-url" ;
12- import { createFatalError , UserError } from "../errors" ;
12+ import { UserError } from "../errors" ;
1313import { getFlag } from "../experimental-flags" ;
1414import {
1515 EXTERNAL_IMAGES_WORKER_NAME ,
1616 EXTERNAL_IMAGES_WORKER_SCRIPT ,
17- imagesLocalFetcher ,
1817 imagesRemoteFetcher ,
1918} from "../images/fetcher" ;
2019import { logger } from "../logger" ;
@@ -461,6 +460,7 @@ type WorkerOptionsBindings = Pick<
461460 | "workflows"
462461 | "wrappedBindings"
463462 | "secretsStoreSecrets"
463+ | "images"
464464 | "email"
465465 | "analyticsEngineDatasets"
466466 | "tails"
@@ -764,7 +764,8 @@ export function buildMiniflareBindingOptions(
764764 }
765765 }
766766
767- if ( bindings . images ?. binding ) {
767+ // Uses the implementation in miniflare instead if the users enable local mode
768+ if ( bindings . images ?. binding && ! config . imagesLocalMode ) {
768769 externalWorkers . push ( {
769770 name : `${ EXTERNAL_IMAGES_WORKER_NAME } :${ config . name } ` ,
770771 modules : [
@@ -775,9 +776,7 @@ export function buildMiniflareBindingOptions(
775776 } ,
776777 ] ,
777778 serviceBindings : {
778- FETCHER : config . imagesLocalMode
779- ? imagesLocalFetcher
780- : imagesRemoteFetcher ,
779+ FETCHER : imagesRemoteFetcher ,
781780 } ,
782781 } ) ;
783782
@@ -883,6 +882,15 @@ export function buildMiniflareBindingOptions(
883882 email : {
884883 send_email : bindings . send_email ,
885884 } ,
885+ images :
886+ bindings . images && config . imagesLocalMode
887+ ? {
888+ binding : bindings . images . binding ,
889+ mixedModeConnectionString : getFlag ( "MIXED_MODE" )
890+ ? mixedModeConnectionString
891+ : undefined ,
892+ }
893+ : undefined ,
886894
887895 durableObjects : Object . fromEntries ( [
888896 ...internalObjects . map ( ( { name, class_name } ) => {
@@ -1124,7 +1132,6 @@ export function handleRuntimeStdio(stdout: Readable, stderr: Readable) {
11241132let didWarnMiniflareCronSupport = false ;
11251133let didWarnMiniflareVectorizeSupport = false ;
11261134let didWarnAiAccountUsage = false ;
1127- let didWarnImagesLocalModeUsage = false ;
11281135
11291136export type Options = Extract < MiniflareOptions , { workers : WorkerOptions [ ] } > ;
11301137
@@ -1172,23 +1179,6 @@ export async function buildMiniflareOptions(
11721179 }
11731180 }
11741181
1175- if ( config . bindings . images && config . imagesLocalMode ) {
1176- if ( ! didWarnImagesLocalModeUsage ) {
1177- try {
1178- await import ( "sharp" ) ;
1179- } catch {
1180- const msg =
1181- "Sharp must be installed to use the Images binding local mode; check your version of Node is compatible" ;
1182- throw createFatalError ( msg , false ) ;
1183- }
1184-
1185- didWarnImagesLocalModeUsage = true ;
1186- logger . info (
1187- "You are using Images local mode. This only supports resizing, rotating and transcoding."
1188- ) ;
1189- }
1190- }
1191-
11921182 const upstream =
11931183 typeof config . localUpstream === "string"
11941184 ? `${ config . upstreamProtocol } ://${ config . localUpstream } `
0 commit comments