From 15de8f196f237606ff0aee145348ed786c2d130b Mon Sep 17 00:00:00 2001 From: Cameron Robey Date: Thu, 29 Sep 2022 12:38:47 +0100 Subject: [PATCH 1/2] add errors --- packages/wrangler/src/dev/dev.tsx | 10 ++++++++++ packages/wrangler/src/publish.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/wrangler/src/dev/dev.tsx b/packages/wrangler/src/dev/dev.tsx index 6dc0e09c61f..48d06605350 100644 --- a/packages/wrangler/src/dev/dev.tsx +++ b/packages/wrangler/src/dev/dev.tsx @@ -245,6 +245,16 @@ function DevSession(props: DevSessionProps) { ); } + // If we are using d1 bindings, and are not bundling the worker + // we should error here as the d1 shim won't be added + if (Array.isArray(betaD1Shims) && betaD1Shims.length > 0 && props.noBundle) { + handleError( + new Error( + "While in beta, you cannot use D1 bindings without bundling your worker. Please remove `no_bundle` from your wrangler.toml file or remove the `--no-bundle` flag to access D1 bindings." + ) + ); + } + const workerDefinitions = useDevRegistry( props.name, props.bindings.services, diff --git a/packages/wrangler/src/publish.ts b/packages/wrangler/src/publish.ts index f5f04fcb998..8578b029262 100644 --- a/packages/wrangler/src/publish.ts +++ b/packages/wrangler/src/publish.ts @@ -390,6 +390,19 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m ); } + // If we are using d1 bindings, and are not bundling the worker + // we should error here as the d1 shim won't be added + const betaD1Shims = identifyD1BindingsAsBeta(config.d1_databases); + if ( + Array.isArray(betaD1Shims) && + betaD1Shims.length > 0 && + props.noBundle + ) { + throw new Error( + "While in beta, you cannot use D1 bindings without bundling your worker. Please remove `no_bundle` from your wrangler.toml file or remove the `--no-bundle` flag to access D1 bindings." + ); + } + const { modules, resolvedEntryPointPath, From 6e465623b5f440f9e997e247b311257a4d662624 Mon Sep 17 00:00:00 2001 From: Cameron Robey Date: Thu, 29 Sep 2022 13:35:04 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/kind-crews-sing.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/kind-crews-sing.md diff --git a/.changeset/kind-crews-sing.md b/.changeset/kind-crews-sing.md new file mode 100644 index 00000000000..fafb633b36a --- /dev/null +++ b/.changeset/kind-crews-sing.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +chore: error if d1 bindings used with `no-bundle` + +While in beta, you cannot use D1 bindings without bundling your worker as these are added in through a facade which gets bypassed when using the `no-bundle` option.