11import { kCurrentWorker , Miniflare } from "miniflare" ;
22import { getAssetsOptions } from "../../../assets" ;
3- import { readConfig } from "../../../config" ;
3+ import { formatConfigSnippet , readConfig } from "../../../config" ;
44import { DEFAULT_MODULE_RULES } from "../../../deployment-bundle/rules" ;
55import { getBindings } from "../../../dev" ;
66import { getBoundRegisteredWorkers } from "../../../dev-registry" ;
@@ -11,7 +11,9 @@ import {
1111 buildSitesOptions ,
1212} from "../../../dev/miniflare" ;
1313import { run } from "../../../experimental-flags" ;
14+ import { logger } from "../../../logger" ;
1415import { getSiteAssetPaths } from "../../../sites" ;
16+ import { dedent } from "../../../utils/dedent" ;
1517import { CacheStorage } from "./caches" ;
1618import { ExecutionContext } from "./executionContext" ;
1719import { getServiceBindings } from "./services" ;
@@ -112,6 +114,7 @@ export async function getPlatformProxy<
112114 const mf = new Miniflare ( {
113115 script : "" ,
114116 modules : true ,
117+ name : "worker" ,
115118 ...( miniflareOptions as Record < string , unknown > ) ,
116119 } ) ;
117120
@@ -136,14 +139,26 @@ async function getMiniflareOptionsFromConfig(
136139) : Promise < Partial < MiniflareOptions > > {
137140 const bindings = getBindings ( rawConfig , env , true , { } ) ;
138141
142+ if ( bindings . durable_objects ) {
143+ logger . warn ( dedent `
144+ You have defined an internal Durable Object (ie the binding does not have a script_name field).
145+ You will not be able to develop it locally, but it should work in production.
146+
147+ Alternatively, you can define your DO "externally" in another worker.
148+ To do this, create another Worker + Wrangler config file. Export your DO from there.
149+ Then, set the script_name field in your original DO binding to equal the name field from your new external DO config.
150+ You will be able to develop this locally by running:
151+ npx wrangler dev -c path/to/original/wrangler.toml -c path/to/external-do/wrangler.toml
152+ ` ) ;
153+ }
139154 const workerDefinitions = await getBoundRegisteredWorkers ( {
140155 name : rawConfig . name ,
141156 services : bindings . services ,
142157 durableObjects : rawConfig [ "durable_objects" ] ,
143158 } ) ;
144159
145160 const { bindingOptions, externalWorkers } = buildMiniflareBindingOptions ( {
146- name : undefined ,
161+ name : rawConfig . name ,
147162 bindings,
148163 workerDefinitions,
149164 queueConsumers : undefined ,
@@ -162,6 +177,7 @@ async function getMiniflareOptionsFromConfig(
162177 {
163178 script : "" ,
164179 modules : true ,
180+ name : rawConfig . name ,
165181 ...bindingOptions ,
166182 serviceBindings : {
167183 ...serviceBindings ,
0 commit comments