Skip to content

[wrangler] Fix circular dependency build warning in cli.ts#14197

Draft
emily-shen wants to merge 1 commit into
mainfrom
fix/wrangler-circular-dep-warning
Draft

[wrangler] Fix circular dependency build warning in cli.ts#14197
emily-shen wants to merge 1 commit into
mainfrom
fix/wrangler-circular-dep-warning

Conversation

@emily-shen
Copy link
Copy Markdown
Contributor

@emily-shen emily-shen commented Jun 5, 2026

Import convertConfigBindingsToStartWorkerBindings directly from ./api/startDevWorker/utils instead of through the ./api barrel to break a circular chunk dependency that Rollup warns about during the DTS build.

The cycle was:

  1. api/index.ts re-exports from startDevWorker/utils.ts
  2. startDevWorker/utils.ts type-imports from ../../dev.ts
  3. dev.ts type-imports from ./api (back to step 1)

I think it was an explicit decision to export from "api/index.ts" but it seems a bit difficult to preserve that without making invasive changes that are probably going to give incoming refactors some bad merge conflicts...


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: build-only warning fix, no runtime behavior change
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal build fix

Open in Devin Review

@emily-shen emily-shen added the ci:no-changeset-required Skip pull request checks for a valid changeset label Jun 5, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 5, 2026

⚠️ No Changeset found

Latest commit: 1f697ba

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jun 5, 2026
@workers-devprod workers-devprod requested review from a team and edmundhung and removed request for a team June 5, 2026 13:53
@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Jun 5, 2026

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • packages/wrangler/src/cli.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/dev.ts: [@cloudflare/wrangler]

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Jun 5, 2026

The remaining ./api imports at lines 11-25 are still value imports (DevEnv, getPlatformProxy, etc.), and line 43 is type-only. So cli.ts still imports values from the ./api barrel — the barrel itself still re-exports from startDevWorker/utils at api/index.ts:20.

This is worth noting: the change only removes one value import from cli.ts, but cli.ts continues to import other values from ./api, and the barrel still re-exports the function. Whether this actually breaks the Rollup DTS chunk cycle depends on Rollup's chunking, which is plausible for the DTS build. The change is low-risk and behavior-preserving regardless. No actionable correctness issue.

The change is correct, minimal, behavior-preserving, and the public API surface is unchanged. No logic bugs, security issues, or compatibility concerns.

LGTM

github run

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

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 potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

@cloudflare/wrangler-bundler

npm i https://pkg.pr.new/@cloudflare/wrangler-bundler@14197

commit: 1f697ba

@emily-shen emily-shen force-pushed the fix/wrangler-circular-dep-warning branch from 9a42fb6 to 4614d73 Compare June 5, 2026 14:02
@petebacondarwin
Copy link
Copy Markdown
Contributor

petebacondarwin commented Jun 5, 2026

Would an alternative approach be to move AdditionalDevProps into src/api/StartDevWorker?

Or rather than "picking" from it in startDevWorker/utils.ts to define StartDevOptionsBindings, we just define the interface explicitly? And maybe even then extending StartDevOptionsBindings when defining the AdditionalDevProps interface?

@emily-shen emily-shen force-pushed the fix/wrangler-circular-dep-warning branch 3 times, most recently from d8ae66f to b3e805f Compare June 5, 2026 14:56
@emily-shen emily-shen marked this pull request as draft June 5, 2026 14:59
Break the circular dependency between src/api/index.ts and
src/api/startDevWorker/utils.ts by having internal modules import
directly from the source module instead of through the api barrel.

The cycle was: api/index.ts re-exports from startDevWorker/utils.ts,
which transitively depends (through types.ts, ConfigController, etc.)
on files that import back from the api barrel. Pointing those imports
at the actual source modules breaks every back-edge.
@emily-shen emily-shen force-pushed the fix/wrangler-circular-dep-warning branch from b3e805f to 1f697ba Compare June 5, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-changeset-required Skip pull request checks for a valid changeset

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants