Skip to content

[workers-utils] Share getWorkerZone and toApiComplianceRegion with the Vite and Vitest plugins - #16880

Merged
edmundhung merged 4 commits into
mainfrom
edmundhung/share-worker-zone-helpers
Nov 17, 2026
Merged

edmundhung merged 4 commits into
mainfrom
edmundhung/share-worker-zone-helpers

Conversation

@edmundhung

@edmundhung edmundhung commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Part of RM-31812. The base of a stack: #16877 and #16798 build on this.

Moves getWorkerZone() and toApiComplianceRegion(), which the Vite and Vitest plugins each copy, into @cloudflare/workers-utils, so a fix reaches both and the test harness can adopt them in its own PR. @cloudflare/config's Wrangler conversion also uses the shared toApiComplianceRegion(); its output is unchanged.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal refactor with no user-facing change

@edmundhung edmundhung added the ci:no-changeset-required Skip pull request checks for a valid changeset label Nov 12, 2026
@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7b75496

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@cloudflare/workers-utils Minor
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/containers-shared Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch
@cloudflare/workers-auth Patch

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

@ask-bonk

ask-bonk Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16880

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16880

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16880

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16880

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16880

create-cloudflare

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

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16880

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16880

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16880

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16880

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16880

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 7b75496

edmundhung added a commit that referenced this pull request Nov 13, 2026
…ainer image preparation

With #16880 underneath, the shared conversion replaces this file's own copy.
edmundhung added a commit that referenced this pull request Nov 13, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
@edmundhung
edmundhung added this pull request to stack #16885 November 13, 2026 00:51
edmundhung added a commit that referenced this pull request Nov 13, 2026
…ainer image preparation

With #16880 underneath, the shared conversion replaces this file's own copy.
edmundhung added a commit that referenced this pull request Nov 13, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
@edmundhung edmundhung removed the ci:no-changeset-required Skip pull request checks for a valid changeset label Nov 13, 2026
@edmundhung
edmundhung force-pushed the edmundhung/share-worker-zone-helpers branch from 4fc3246 to 36bac57 Compare November 13, 2026 10:40
edmundhung added a commit that referenced this pull request Nov 13, 2026
…ainer image preparation

With #16880 underneath, the shared conversion replaces this file's own copy.
edmundhung added a commit that referenced this pull request Nov 13, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
@edmundhung
edmundhung marked this pull request as ready for review November 13, 2026 12:14
@workers-devprod
workers-devprod requested review from a team and cjol and removed request for a team November 13, 2026 12:14
@workers-devprod

workers-devprod commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 1d43bd9c.

This review, of 36bac57f

✅ Approved — No issues found: the helpers are moved without changing what they do, the import path resolves, and the moved code has tests at the shared layer.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Low risk. The changeset covers the new exports from @cloudflare/workers-utils.


🔒 Security: ✅ LGTM

Moving two pure helpers adds no new trust boundary, secret handling or authentication path.


📖 AGENTS.md: ✅ LGTM

Follows the repository guidance to put shared behavior in the lowest suitable shared package and to test it at that layer.


📋 Code Quality: ✅ LGTM

The shared getWorkerZone() and toApiComplianceRegion() behave the same as the copies they replace, and every call site matches the new signatures.


⚡ Performance: ✅ LGTM

No performance impact.


📝 Documentation: ✅ LGTM

The JSDoc on the new exported functions is accurate.


Reviewed commit: 36bac57f

@edmundhung
edmundhung requested review from a team and NuroDev and removed request for a team and cjol November 16, 2026 10:22
…e Vite and Vitest plugins

Move the two helpers that the Vite and Vitest plugins each copied into
@cloudflare/workers-utils, so a fix reaches every tool. getWorkerZone sits
next to getZoneFromRoute and takes a structural config type that input,
loaded and Build Output Worker configs all satisfy, since workers-utils
can't depend on @cloudflare/config. toApiComplianceRegion goes in the
/compliance subpath, and @cloudflare/config's Wrangler conversion uses it
too, with the same output.
…anceRegion exports

containers-shared depends on workers-utils at runtime and, with #16877, imports
toApiComplianceRegion from it, so a release needs a workers-utils version that
has the new exports.
@edmundhung
edmundhung force-pushed the edmundhung/share-worker-zone-helpers branch from 36bac57 to 1d43bd9 Compare November 17, 2026 10:39

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of c7b1f670.

This review, of 1d43bd9c

✅ Approved — No issues found: the helpers move into workers-utils with the same behavior, all call sites match the new signatures, the moved code has tests in workers-utils, and a changeset covers the new exports.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Release risk is low. The minor changeset for @cloudflare/workers-utils documents the new exports, which downstream packages need in a published version.


🔒 Security: ✅ LGTM

This pull request moves two pure helpers. It adds no new trust boundary, no secret handling and no authentication path.


📖 AGENTS.md: ✅ LGTM

The change follows the repository guidance: shared behavior goes in the lowest suitable shared package and is tested at that layer.


📋 Code Quality: ✅ LGTM

The shared getWorkerZone() and toApiComplianceRegion() behave the same as the copies they replace, and every call site matches the new signatures. Using fetchTrigger?.pattern === undefined as the guard gives the same result for fetch triggers. convert.ts produces the same output as before. The imports removed from the Vite and Vitest plugins are no longer used there.


⚡ Performance: ✅ LGTM

The helpers are pure and run once per config conversion, not in a hot path, so there is no performance impact.


📝 Documentation: ✅ LGTM

The JSDoc on the new exported functions is accurate.


Reviewed commit: 1d43bd9c

Drop the sentence about the Vite and Vitest plugins sharing the helpers, which
describes the refactor rather than anything a reader of the changelog gains.

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 7b754967.

This review, of c7b1f670

✅ Approved — No issues found. The shared helpers behave the same as the copies they replace, every call site matches the new signatures, workers-utils has tests for the moved code, and the reworded changeset describes the new exports accurately.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Release risk is low. The minor changeset for @cloudflare/workers-utils documents the new exports. Downstream packages need those exports in a published version.


🔒 Security: ✅ LGTM

This pull request moves two pure helpers. It adds no new trust boundary, no secret handling and no authentication path.


📖 AGENTS.md: ✅ LGTM

The change follows the repository guidance: shared behavior goes in the lowest suitable shared package, and it is tested at that layer.


📋 Code Quality: ✅ LGTM

The shared getWorkerZone() and toApiComplianceRegion() behave the same as the copies they replace, and every call site matches the new signatures.

  • For fetch triggers, the fetchTrigger?.pattern === undefined guard gives the same result as the old type !== "fetch" check.
  • convert.ts produces the same output as before.
  • The imports removed from the Vite and Vitest plugins are no longer used there.

⚡ Performance: ✅ LGTM

The helpers are pure functions that run once per config conversion, not on a hot path, so the move has no performance impact.


📝 Documentation: ✅ LGTM

The JSDoc on the new exported functions is accurate. The changeset now describes only what the new exports do.


Reviewed commit: c7b1f670

The changeset now says what getWorkerZone() returns, not how one caller uses
it.

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — No issues found. The only change since the last review is a changeset reword, and the new wording accurately describes what the exports do.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Release risk is low. The minor changeset for @cloudflare/workers-utils documents the new exports, which downstream packages will need in a published version.


🔒 Security: ✅ LGTM

This pull request moves two pure helpers. It adds no new trust boundary, secret handling or authentication path.


📖 AGENTS.md: ✅ LGTM

The change follows the repository guidance: shared behavior goes in the lowest suitable shared package, and it is tested at that layer.


📋 Code Quality: ✅ LGTM

The shared getWorkerZone() and toApiComplianceRegion() behave the same as the copies they replace, and every call site matches the new signatures.

  • For fetch triggers, the fetchTrigger?.pattern === undefined guard gives the same result as the old type !== "fetch" check.
  • convert.ts produces the same output as before.
  • The @cloudflare/workers-utils/compliance subpath is already exported.
  • getWorkerZone() has tests in packages/workers-utils/tests/route-utils.test.ts.

⚡ Performance: ✅ LGTM

The helpers are pure functions that run once per config conversion, so the move has no performance impact.


📝 Documentation: ✅ LGTM

The JSDoc on the new exports is accurate. The changeset describes only what the new exports do.


Reviewed commit: 7b754967

@edmundhung
edmundhung enabled stacked auto-merge (squash) November 17, 2026 10:56
@edmundhung
edmundhung merged commit d04e667 into main Nov 17, 2026
84 checks passed
@edmundhung
edmundhung deleted the edmundhung/share-worker-zone-helpers branch November 17, 2026 11:04
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 17, 2026
edmundhung added a commit that referenced this pull request Nov 17, 2026
…ainer image preparation

With #16880 underneath, the shared conversion replaces this file's own copy.
edmundhung added a commit that referenced this pull request Nov 17, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
edmundhung added a commit that referenced this pull request Nov 17, 2026
…ainer image preparation

With #16880 underneath, the shared conversion replaces this file's own copy.
edmundhung added a commit that referenced this pull request Nov 17, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
edmundhung added a commit that referenced this pull request Nov 18, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
edmundhung added a commit that referenced this pull request Nov 18, 2026
…ompliance helpers

#16877 and #16880 move these into containers-shared and workers-utils, so the
harness calls prepareContainerImagesForCfConfig(), getWorkerZone() and
toApiComplianceRegion() instead of keeping its own copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants