Skip to main content

Module environment

Module environment 

Source
Expand description

The [env.<name>] block of a named-environment deploy (back-half paydown 1C.2, Decision A of #4039).

Why a named environment needs a block at all. Wrangler does not inherit a Worker’s bindings into a named environment: a bare --env staging against the flat config super::emit_wrangler_toml writes would deploy with no bindings. The block restates what Wrangler does not inherit, and it cannot be written at build time, because no environment is known then and its values (the ids the deploy has just resolved, the environment’s names) do not exist until the deploy.

What this renders it from. The generated wrangler.toml as the deploy has materialised it for the environment, which is the file Wrangler is about to upload, so the top level and the block cannot disagree (ADR 0193 D3, ADR 0254 D2). What it does with each top-level key is the key’s WranglerKey::environment_rule, one exhaustive match over every table the emitter writes: a binding table cannot be left out of the block by omission (#3577, #3586). A key that is not one of the emitter’s is dropped.

The bytes. The block is a [toml::Table], keys sorted, written by toml::to_string_pretty and appended after a newline. The top level is never touched. This layout is what bynk deploy has always handed Wrangler, and it stays (no format change).

Structs§

Resolved
What the deploy has resolved for the environment that the generated file does not say.

Functions§

render
config_text with the [env.<environment>] block appended, or unchanged when the block would be empty (a config that names nothing and binds nothing, which bynk build never emits).