Skip to content

[wrangler] Preserve tree-shaking across workspace package boundaries - #15406

Merged
james-elicx merged 3 commits into
mainfrom
codex/reduce-wrangler-miniflare-bundles
Sep 1, 2026
Merged

[wrangler] Preserve tree-shaking across workspace package boundaries#15406
james-elicx merged 3 commits into
mainfrom
codex/reduce-wrangler-miniflare-bundles

Conversation

@james-elicx

@james-elicx james-elicx commented Aug 28, 2026

Copy link
Copy Markdown
Member

Fixes no linked issue.

Wrangler currently bundles several workspace packages after they have already been bundled, which prevents effective tree-shaking. Miniflare similarly imports the broad workers-utils entry point for a small set of helpers.

This change aliases selected workspace packages to source during the Wrangler monorepo build, and adds granular workers-utils leaf exports used by Miniflare and its transitive CLI/container helpers. Published dependency installation remains unchanged.

Bundle measurements

Measurements use equivalent source-map-disabled builds.

Package Size Before After Saving
Wrangler Raw 20,552,867 B 14,089,515 B 6,463,352 B / 31.4%
Gzip 3,609,518 B 2,518,952 B 1,090,566 B / 30.2%
Miniflare Raw 4,843,954 B 3,732,681 B 1,111,273 B / 22.9%
Gzip 1,034,164 B 844,666 B 189,498 B / 18.3%
Total Raw 25,396,821 B 17,822,196 B 7,574,625 B / 29.8%
Gzip 4,643,682 B 3,363,618 B 1,280,064 B / 27.6%

The workers-utils contribution to Miniflare falls from 1,023,602 B to 19,327 B.

Validation

  • Wrangler full suite: 5,070 passed, 3 skipped, 9 todo
  • workers-utils: 950 passed
  • cli-shared-helpers: 42 passed, 1 skipped
  • containers-shared: 71 passed
  • Focused changed Miniflare tests: 18 passed
  • All affected package type checks and workers-utils type tests passed
  • Targeted formatting and lint checks passed
  • Filtered builds and built Wrangler/Miniflare API smoke checks passed
  • Miniflare full suite: 84 of 85 files and 1,197 tests passed; the remaining Hyperdrive proxy test is blocked by the host OpenSSL rejecting its test CA with ERR_SSL_CA_MD_TOO_WEAK, unrelated to this change

  • 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: this is an internal build and import refactor with no user-facing behavior or API change.

Note

This is a contribution from an AI agent: Codex.

@james-elicx james-elicx added the ci:no-changeset-required Skip pull request checks for a valid changeset label Aug 28, 2026
@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: dc60d45

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

This PR includes changesets to release 12 packages
Name Type
@cloudflare/workers-utils Patch
miniflare Patch
wrangler Patch
@cloudflare/autoconfig Patch
@cloudflare/cli-shared-helpers Patch
@cloudflare/deploy-helpers Patch
@cloudflare/remote-bindings Patch
@cloudflare/runtime-types Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-plugin Patch
@cloudflare/workers-auth Patch
@cloudflare/pages-shared 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 Aug 28, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: dc60d45

@james-elicx james-elicx removed the ci:no-changeset-required Skip pull request checks for a valid changeset label Aug 28, 2026
@james-elicx james-elicx changed the title [wrangler] Reduce Wrangler and Miniflare bundle sizes Aug 28, 2026
@james-elicx
james-elicx marked this pull request as ready for review August 28, 2026 15:36
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team August 28, 2026 15:37
@workers-devprod

workers-devprod commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/cloudchamber
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/containers-shared/src/build.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/images.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/inspect.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/knobs.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/login.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/registry.ts: [@cloudflare/cloudchamber]
  • packages/containers-shared/src/utils.ts: [@cloudflare/cloudchamber]

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review
Comment thread .changeset/lean-bundles-shake.md Outdated
Comment thread packages/workers-utils/package.json
Co-authored-by: Ben <4991309+NuroDev@users.noreply.github.com>
@james-elicx
james-elicx enabled auto-merge (squash) September 1, 2026 12:56

@NuroDev NuroDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codeowners Bypass

@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

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Sep 1, 2026
@james-elicx
james-elicx merged commit b3f2628 into main Sep 1, 2026
62 checks passed
@james-elicx
james-elicx deleted the codex/reduce-wrangler-miniflare-bundles branch September 1, 2026 13:19
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants