Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: error if d1 bindings used with no-bundle #1955

Merged
merged 2 commits into from Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .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.
10 changes: 10 additions & 0 deletions packages/wrangler/src/dev/dev.tsx
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions packages/wrangler/src/publish.ts
Expand Up @@ -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,
Expand Down