@@ -339,11 +339,20 @@ function validateCompatibilityDate(log: Log, compatibilityDate: string) {
339
339
return compatibilityDate ;
340
340
}
341
341
342
- function buildJsonBindings ( bindings : Record < string , Json > ) : Worker_Binding [ ] {
343
- return Object . entries ( bindings ) . map ( ( [ name , value ] ) => ( {
344
- name,
345
- json : JSON . stringify ( value ) ,
346
- } ) ) ;
342
+ function buildBindings ( bindings : Record < string , Json > ) : Worker_Binding [ ] {
343
+ return Object . entries ( bindings ) . map ( ( [ name , value ] ) => {
344
+ if ( typeof value === "string" ) {
345
+ return {
346
+ name,
347
+ text : value ,
348
+ } ;
349
+ } else {
350
+ return {
351
+ name,
352
+ json : JSON . stringify ( value ) ,
353
+ } ;
354
+ }
355
+ } ) ;
347
356
}
348
357
349
358
const WRAPPED_MODULE_PREFIX = "miniflare-internal:wrapped:" ;
@@ -368,7 +377,7 @@ export const CORE_PLUGIN: Plugin<
368
377
const bindings : Awaitable < Worker_Binding > [ ] = [ ] ;
369
378
370
379
if ( options . bindings !== undefined ) {
371
- bindings . push ( ...buildJsonBindings ( options . bindings ) ) ;
380
+ bindings . push ( ...buildBindings ( options . bindings ) ) ;
372
381
}
373
382
if ( options . wasmBindings !== undefined ) {
374
383
bindings . push (
@@ -424,7 +433,7 @@ export const CORE_PLUGIN: Plugin<
424
433
// Build binding
425
434
const moduleName = workerNameToWrappedModule ( scriptName ) ;
426
435
const innerBindings =
427
- bindings === undefined ? [ ] : buildJsonBindings ( bindings ) ;
436
+ bindings === undefined ? [ ] : buildBindings ( bindings ) ;
428
437
// `scriptName`'s bindings will be added to `innerBindings` when
429
438
// assembling the config
430
439
return {
0 commit comments