Repository navigation
server: workerd run, workerd check, and Wrangler configs for serve - #8065
bartlomieju wants to merge 2 commits into
Conversation
Standalone workerd needed a Cap'n Proto config for anything, which is the most-cited complaint from people trying to self-host it. This adds a front end that synthesizes the config in-process: - `workerd run app.js` serves a single JavaScript, TypeScript or Python file with the newest compatibility date this release supports. Files beside it are available to relative imports. `--watch` reloads on change; `--port`, `--compat-date`, `--compat-flag` and `--persist` adjust it. - `workerd serve wrangler.jsonc` (and `check`) reads a Wrangler config: main, compatibility date and flags, vars, durable_objects with migrations (SQLite classes), services and dev.port. Durable Objects are persisted under .workerd-state beside the config, since the in-memory storage has no SQLite. Sections that need Cloudflare services are reported and skipped. - `--print-config` prints the synthesized config as a schema file with `embed`s of the project files, so a project can graduate to a hand written config. - `workerd check <config>` starts every service without binding a port, reports every config error rather than exiting at the first, and exits 1 if any. Worker compile errors (syntax errors) are reported too. - Config errors about an unknown service now add a 'Did you mean' hint. The CLI side is Rust (cli/project.rs); the C++ side adds Server::check() and a check mode to the driver.
workerd check and the 'Did you mean' hint move from server.c++ and cli-main.c++, which main deleted, to the Rust server: run::check and entry::check build the service graph without binding sockets, and config.rs adds the hint to both service lookups.
|
🛑 Significant concerns — One blocking bug: Findings: 1 blocking · 4 warnings · 1 info · 1 suggestion The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 🔧 Fix with your agentPaste the following into your coding agent to investigate and fix these issues. 📋 Code Quality: 🛑 1 blocking · 1 warning · 1 info · 1 suggestionModule collection pulls in unrelated files, so a stray Recommendation:
View full reviewModule collection pulls in unrelated files (
Project options are silently ignored for schema-file configs
🔒 Security:
|
Standalone workerd needs a Cap'n Proto config for anything, which is the
complaint self-hosters raise most often, and a config error ends the
process at the first problem. This adds a front end that synthesizes the
config in-process.
workerd run app.jsserves one JavaScript, TypeScriptor Python file with no config: files beside it are available to relative
imports, the compatibility date defaults to the newest this release
supports, and
--watchreloads on edits.workerd serve wrangler.jsoncreads a Wrangler config (main, compatibility date and flags, vars, Durable
Objects with migrations, service bindings, dev.port), persists Durable
Objects under
.workerd-state, and reports the bindings standaloneworkerd cannot provide.
--print-configprints the synthesized config asa schema file with
embeds of the project files, so a project cangraduate to a hand-written config.
workerd checkaccepts any config or abare source file, builds every service and compiles every Worker without
binding a socket, reports every error rather than the first, and exits 1
if there was one. Errors about an unknown service name add a "Did you
mean" hint.
The config synthesis lives in the CLI crate (cli/project.rs); check is a
third command of the Rust server next to serve and test. The Wrangler
half overlaps with #8051, which also bundles with esbuild and rejects
unknown fields; whichever lands first, the other should be rebased so
run, check and --print-config share one Wrangler reader. wrangler.toml
and node_modules resolution are not covered here.