From b9946049b0cfe273b8d950f5abcb25ddd386a872 Mon Sep 17 00:00:00 2001 From: Skye <46286597+Skye-31@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:42:46 +0100 Subject: [PATCH] Fix: vitest-pool-workers use env in .dev.vars (#6180) https://github.com/cloudflare/workers-sdk/pull/5612 added support for selecting the environment of config used, but it missed passing it to the code that reads `.dev.vars.{environment}` --- .changeset/itchy-bags-shake.md | 10 ++++++++++ .../wrangler/src/api/integrations/platform/index.ts | 5 ++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/itchy-bags-shake.md diff --git a/.changeset/itchy-bags-shake.md b/.changeset/itchy-bags-shake.md new file mode 100644 index 000000000000..71f69cbe65bb --- /dev/null +++ b/.changeset/itchy-bags-shake.md @@ -0,0 +1,10 @@ +--- +"wrangler": patch +"@cloudflare/vitest-pool-workers": patch +--- + +Fix: pass env to getBindings to support reading `.dev.vars.{environment}` + +https://github.com/cloudflare/workers-sdk/pull/5612 added support for selecting the environment of config used, but it missed passing it to the code that reads `.dev.vars.{environment}` + +Closes #5641 diff --git a/packages/wrangler/src/api/integrations/platform/index.ts b/packages/wrangler/src/api/integrations/platform/index.ts index 674120ad655d..66f5e73f4287 100644 --- a/packages/wrangler/src/api/integrations/platform/index.ts +++ b/packages/wrangler/src/api/integrations/platform/index.ts @@ -237,7 +237,7 @@ export type SourcelessWorkerOptions = Omit< export function unstable_getMiniflareWorkerOptions( configPath: string, - environment?: string + env?: string ): { workerOptions: SourcelessWorkerOptions; define: Record; @@ -245,7 +245,7 @@ export function unstable_getMiniflareWorkerOptions( } { const config = readConfig(configPath, { experimentalJsonConfig: true, - env: environment, + env, }); const modulesRules: ModuleRule[] = config.rules @@ -256,7 +256,6 @@ export function unstable_getMiniflareWorkerOptions( fallthrough: rule.fallthrough, })); - const env = undefined; const bindings = getBindings(config, env, true, {}); const { bindingOptions } = buildMiniflareBindingOptions({ name: undefined,