Remove getLocalWorkerdCompatibilityDate from workers-utils and re-export supportedCompatibilityDate from miniflare instead#12387
Conversation
🦋 Changeset detectedLatest commit: c9ccae5 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 |
|
Claude finished @dario-piotrowicz's task —— View job Changeset ReviewReviewing changesets for this PR... Tasks:
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
|
@dario-piotrowicz could you please take a look at #11910 - looks like both PR handle the same thing? |
I commented there, I think there's little benefit in merging #11910 since that doesn't solve the pnpm issue |
|
This all feels very convoluted 😢. Especially where we have to try to import wrangler in the workers-utils package. |
But that's a temporary solution / workaround, in a followup PR I am planning to remove the function from
I think that that would be quite clean and clear, no? |
|
Can we not just do that in one go here in this PR? |
I wanted to go this way because I think it's safer (and I didn't think it'd introduce too much complexity), I'm happy to do all of that in one go if that's the preference 🙂 |
2d8af12 to
c4a0c37
Compare
getLocalWorkerdCompatibiltyDate to miniflaregetLocalWorkerdCompatibiltyDate to miniflare
c2d82c4 to
40a4b0a
Compare
|
@petebacondarwin PR updated to remove the extra complexity 🙂 |
Co-authored-by: Victor Berchet <victor@suumit.com>
Co-authored-by: Victor Berchet <victor@suumit.com>
petebacondarwin
left a comment
There was a problem hiding this comment.
Bunch of comments - I think mostly nits - so marking as approved.
|
|
||
| ### `supportedCompatibilityDate` | ||
|
|
||
| Exported value containing the latest [compatibility date](https://developers.cloudflare.com/workers/platform/compatibility-dates/) supported by the locally installed `workerd` package. If the `workerd` package's compatibility date is in the future, the value contains today's date instead. The value is a string in the `YYYY-MM-DD` format (e.g. `"2025-09-27"`). |
There was a problem hiding this comment.
I think it is worth explaining the logic for compat dates again here...
Each workerd release exposes a supported compat date that it guarantees can be used with this version of the package. This date is up to 7 days after the release date of the version.
Normally thissupportedCompatibilityDateis equal to the value exported by workerd, but if this supported compat date is in the future (because the workerd package was released in the last 7 days) then the value of this export is today.
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
| // supportedCompatibilityDate is already a YYYY-MM-DD string, which sorts | ||
| // lexicographically as a date. Compare directly against today's date. | ||
| const todayDate = formatCompatibilityDate(new Date()); | ||
| expect(supportedCompatibilityDate <= todayDate).toBe(true); |
There was a problem hiding this comment.
| expect(supportedCompatibilityDate <= todayDate).toBe(true); | |
| expect(supportedCompatibilityDate).toBeLessThanOrEqual(todayDate); |
|
Closing in favour of #13051 |
Fixes https://jira.cfdata.org/browse/DEVX-2446
This PR removes the
getLocalWorkerdCompatibilityDateutility from the@cloudflare/worker-utilspackage and makes sure that the miniflare'ssupportedCompatibilityDateis exposed by the package. The same variable is then re-exported by wrangler.This value is then also used by C3 ensuring that the compatibility date can be reliably retrieved when using pnpm.
getLocalWorkerdCompatibilityDatedocumentation in the wrangler programmatic API page cloudflare-docs#28082A picture of a cute animal (not mandatory, but encouraged)