[C3] Support template substitution in wrangler config files#11520
Conversation
🦋 Changeset detectedLatest commit: c9f28a0 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
fd037c7 to
13f666c
Compare
83e8243 to
c320e96
Compare
petebacondarwin
left a comment
There was a problem hiding this comment.
Great! To be honest, if we are going in this direction we should just get rid of the <TBD> placeholders. All of this is internal API and we have full control over it. Keeping TBD around just adds additional complexity and is confusing.
Doesn't c3 support external templates? |
7ecfdb2 to
329dd1c
Compare
bfdbdac to
72133c2
Compare
a6dca46 to
c9f28a0
Compare
This PR adds template substitution for the wrangler config files.
<WORKER_NAME>is replaced with the worker name (from the project).<COMPATIBILITY_DATE>is replaced with the latest workerd dateThis in in addition to how
<TBD>is currently replaced by a context depend value (could be either the worker name or the compatibility date)Notes:
<WORKER_NAME>is needed to unblock Open Next (in a follow up PR)<COMPATIBILITY_DATE>is not currently used but will be used to make substitution clearer, see "Future work" belowFor
.json/.jsonconly the string values are considered.For
.tomlit uses a simple string replace - which should be ok if we use uncommon key format.Note / Future work:
We currently use this pattern for wrangler config / package.json:
{ "name": "<TBD>", "main": "src/entry.py", "compatibility_date": "<TBD>", "compatibility_flags": ["python_workers"], "observability": { "enabled": true, }, }IMO we should replace that with the mechanism of this PR for clarity, i.e.
{ "name": "<WORKER_NAME>", "main": "src/entry.py", "compatibility_date": "<COMPATIBILITY_DATE>", "compatibility_flags": ["python_workers"], "observability": { "enabled": true, }, }(We should keep the current logic for backward compatibility but update it and the templates)