Skip to main content

Module workers

Module workers 

Source
Expand description

Shared Workers-build plumbing for bynk dev and bynk deploy.

Both commands do the same four things before they diverge: prepare a managed build directory, compile the project into it, discover the worker directories that came out, and shell wrangler. That machinery grew up inside dev.rs and deploy.rs reached across for it, which left dev reading as deploy’s utility library. It lives here instead — a sibling of both, owned by neither.

Enums§

SelectError
Why context selection failed — rendered to the user with the next step.

Functions§

compile_once
One compile of the project into build_dir, on the same rooting rule as bynkc compile <project_root> (#524, via [bynk_driver::project_options]). Default: in-process. Escape hatch: a BYNK_BYNKC override shells that binary instead — the only path on which a second, skewable compiler enters (doctor reports its skew only here). Returns false on failure with the diagnostics already rendered.
discover_workers
The worker directories under <build>/workers/ that carry a wrangler.toml (the unit wrangler dev can serve), sorted for deterministic messages.
prepare_build_dir
Ensure .bynk/ is gitignored on first build (cargo’s target/.gitignore precedent — a dev run never dirties git status), then clear the workers/ tree so selection only ever sees this build’s contexts (D1).
select_contexts
Pick the workers dev will serve together (#552). No --context serves every context in the project — the whole point of the increment, since a cross-context call only resolves when its callee is up too. --context is repeatable and narrows to a subset, in available’s deterministic order rather than the order they were typed, and duplicates collapse.
wrangler_command
Build the wrangler dev invocation for a resolved provenance: an installed binary is run directly; an npx-provisionable one goes through npx --yes. None when wrangler is genuinely missing.