@@ -18,6 +18,14 @@ export async function setupDevBindings(
18
18
const continueSetup = shouldSetupContinue ( ) ;
19
19
if ( ! continueSetup ) return ;
20
20
21
+ if ( ! options ) {
22
+ throwError ( 'No options provided to setupDevBindings' ) ;
23
+ }
24
+
25
+ if ( ! options . bindings ) {
26
+ throwError ( "The provided options object doesn't include a bindings field" ) ;
27
+ }
28
+
21
29
const mf = await instantiateMiniflare ( options ) ;
22
30
23
31
const bindings = await mf . getBindings ( ) ;
@@ -69,10 +77,6 @@ export interface ServiceDesignator {
69
77
async function instantiateMiniflare (
70
78
options : DevBindingsOptions ,
71
79
) : Promise < Miniflare > {
72
- options ??= {
73
- bindings : { } ,
74
- } ;
75
-
76
80
const devBindingsDurableObjectOptions = Object . fromEntries (
77
81
Object . entries ( options . bindings ) . filter (
78
82
( [ , binding ] ) => binding . type === 'durable-object' ,
@@ -84,7 +88,7 @@ async function instantiateMiniflare(
84
88
devBindingsDurableObjectOptions as DevBindingsDurableObjectOptions ,
85
89
) ) ?? { } ;
86
90
87
- const bindings = await getMiniflareBindingOptions ( options . bindings ?? { } ) ;
91
+ const bindings = await getMiniflareBindingOptions ( options . bindings ) ;
88
92
89
93
const workers : WorkerOptions [ ] = [
90
94
{
@@ -331,3 +335,7 @@ export function warnAboutD1Names(d1DatabaseNamesUsed: string[]): void {
331
335
. join ( '\n' ) } \x1b[0m\n\n`,
332
336
) ;
333
337
}
338
+
339
+ function throwError ( message : string ) : never {
340
+ throw new Error ( `⚠️ [setupDevBindings Error]: ${ message } ` ) ;
341
+ }
0 commit comments