Skip to content

Conversation

@vicb
Copy link
Contributor

@vicb vicb commented Dec 4, 2025

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 date

This 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:

  • the new template substitution is applied before the legacy one to preserved backward compatibility.
  • <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" below

For .json/.jsonc only the string values are considered.
For .toml it 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)


  • Tests
    • Tests included/updated
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: c3

@vicb vicb requested a review from a team as a code owner December 4, 2025 10:17
@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: c320e96

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 4, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11520

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11520

miniflare

npm i https://pkg.pr.new/miniflare@11520

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11520

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11520

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11520

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11520

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11520

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11520

wrangler

npm i https://pkg.pr.new/wrangler@11520

commit: c320e96

@vicb vicb force-pushed the vicb/c3-substitution branch from fd037c7 to 13f666c Compare December 4, 2025 15:53
@vicb vicb changed the title [C3] Add template susbsitution [C3] Support template subsitution in wrangler config files Dec 4, 2025
@vicb vicb force-pushed the vicb/c3-substitution branch from 13f666c to 83e8243 Compare December 5, 2025 08:58
@vicb vicb force-pushed the vicb/c3-substitution branch from 83e8243 to c320e96 Compare December 5, 2025 10:25
@vicb vicb changed the title [C3] Support template subsitution in wrangler config files [C3] Support template substitution in wrangler config files Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants