Repository navigation
Accept wrangler.json(c) as a config - #8051
Conversation
`workerd serve wrangler.jsonc` translates a wrangler config into a Config: name, main, compatibility_date/flags, vars, durable_objects and migrations. main is bundled with esbuild the way wrangler does it (WORKERD_ESBUILD, else node_modules/.bin/esbuild, else PATH), or scanned as plain modules under "no_bundle". DO storage goes in .wrangler/state/workerd. --watch reloads on changes to the config or to any bundled input. Unsupported fields are an error.
|
💬 Approved with comments — The earlier WARNING about the default bind address is fixed: it is now localhost:8787. Only two INFO notes remain, one about watch scope after a failed build and one about README defaults. Findings: 2 info Not opened by the correctness review: 6 changed files it was meant to read
The decision is advisory: this comment never approves, blocks or requests changes on the pull request. ⚡ Performance: 💬 1 infoOne earlier INFO is still open: per-file watches after a failed build under --watch. Recommendation: 💬 Optional Nits
View full review
Impact:
Fix: skip common output directories, or watch directories instead of single files. 📝 Documentation: 💬 1 infoThe README's wrangler section still does not give the listen address or the Durable Object state directory. Recommendation: 💬 Optional Nits
View full review
Adding both tells users where the server is reachable and where persistent state is written. ✅ All other checks passed🔒 Security: ✅ LGTMThe previous WARNING is resolved:
Checked and fine:
📖 AGENTS.md: ✅ LGTMThe root 📋 Code Quality: ✅ LGTMThe only code changed since the last review is the default listen address, now Reviewed commit: |
|
Since last review: 2 resolved, 0 still open, 0 new. Reviewed commit: 976e5474 · github run |
- Bundle into .wrangler/tmp in the project, not a predictable path in the shared temp dir. - Key a Durable Object's storage by the name it was created under, so renamed_classes keeps its data. - files() no longer follows symlinks, so a cycle cannot recurse. - Test bundling, success and failure, against a stub esbuild. - Mention wrangler configs in the README.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8051 +/- ##
==========================================
- Coverage 69.38% 69.25% -0.13%
==========================================
Files 696 697 +1
Lines 181864 182210 +346
Branches 29213 29215 +2
==========================================
+ Hits 126185 126191 +6
- Misses 38612 38950 +338
- Partials 17067 17069 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Within a migration, apply deleted_classes, then renamed_classes, then new classes, as wrangler does, so a class can be deleted and re-created in one migration. Reject deleting or renaming a class that does not exist, and creating one that already does.
|
I guess one thing we need to think about is that wrangler will be replaced by |
- Never reuse a Durable Object storage key: a class created under a name an earlier class was keyed by (deleted, or renamed away) gets <name>~<n> and starts empty, as in production. Previously a renamed class and a new class under its old name shared storage. - Name the DO disk service after the worker, so a worker named wrangler-do-storage no longer collides with it. - Watch main before bundling, so creating a missing main reloads. - Serialize the tests that spawn processes, so the stub esbuild cannot fail with ETXTBSY. - Test the DO binding, the uniqueKey a renamed class keeps, and that deletes apply before renames. - List $schema among the README's supported fields.
|
The generated output of |
- Reject renaming a Durable Object class onto a name that exists. - Test that bundling watches inputs only the metafile names. - Module doc: name storage directories by key and list $schema; the root AGENTS.md mentions wrangler configs.
|
@ryanking13 good point
This out of scope for this PR, as it would need Node.js execution - something workerd cannot provide now. That said, we shouldn't let that block DX improvements to workerd. |
jasnell
left a comment
There was a problem hiding this comment.
LGTM but having at least one sample that uses wrangler.jsonc instead of the capnp would be helpful.
A TypeScript Worker with a SQLite-backed Durable Object, bundled with esbuild. A unit test parses its config, so it cannot drift from what the loader accepts.
A missing wrangler config was reported as a config error, so --watch waited for it to change but never watched it. Report it as a usage error, as for a missing .capnp config.
A wrangler config's server listened on every interface (*:8787). wrangler dev listens on localhost; do the same, so a dev server is not reachable from the network unless --socket-addr says so.
Lets workerd take a
wrangler.json/wrangler.jsoncdirectly instead of aconfig.capnp. This is a developer-experience change: existing Workers projects run under workerd unchanged.name,main,compatibility_date,compatibility_flags,vars,durable_objects.bindings,migrations(new, sqlite, renamed and deleted classes) andno_bundle. Any other field is rejected bydeny_unknown_fields, so a config never silently half-works.requirebanner for CJS dependencies. If esbuild is missing, the error says how to fix it.*:8787. DO storage goes in.wrangler/state/workerd, matching wrangler's layout.--watch: reloads on the config file and on the inputs listed in esbuild's metafile. After a failed build it watches the project's sources, so fixing the error reloads.Does not support: KV, R2, D1, service bindings,
defineandrules.