Skip to content

[wrangler-bundler] new package: esbuild-based dev server extracted from wrangler dev#13892

Draft
penalosa wants to merge 2 commits into
mainfrom
penalosa/wrangler-bundler
Draft

[wrangler-bundler] new package: esbuild-based dev server extracted from wrangler dev#13892
penalosa wants to merge 2 commits into
mainfrom
penalosa/wrangler-bundler

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

Adds @cloudflare/wrangler-bundler — a thin (~150-line) adapter on top of wrangler's unstable_DevEnv API, exposing an esbuild-based dev server via a cf-wrangler delegate binary. Targets projects that can't migrate to Vite (the recommended path remains @cloudflare/vite-plugin).

The package ships a cf-wrangler binary that dispatches on a leading subcommand verb. Today the only verb is dev (long-running esbuild + Miniflare + workerd). Future verbs (build, deploy, …) will follow the same shape. A parent process invokes <pkgRoot>/bin/cf-wrangler dev [argv] with stdio inherited; SIGINT/SIGTERM are forwarded to devEnv.teardown().

Scope is deliberately limited to local-only sessions for v1:

  • --remote, --routes, --host, --upstream-protocol, --tunnel, --env are rejected at parse time with messages pointing at wrangler dev.
  • The auth hook is a stub that throws if a remote-bindings codepath invokes it (i.e. the user has remote = true on a binding).
  • Pages/Sites, multi-worker dev, container image-uri pulling, and hotkey UI are out of scope.
  • --fast-path (one-shot mode) is gated behind a not-yet-implemented error.

Dev-registry path comes from miniflare's getDefaultDevRegistryPath rather than workers-utils' getRegistryPath to sidestep the latter's xdg-app-paths CJS-shim breakage in pure-ESM consumers. Both default to $XDG_CONFIG_HOME/.wrangler/registry, so multi-session compat with wrangler dev is preserved on the default path.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: this is a new, prerelease, internal-tracked package ("workers-sdk": { "prerelease": true }, no public bin consumers yet). Integration coverage will land out-of-package via a parent process that spawns the cf-wrangler binary against a fixture project; that harness is being built separately and will gate the package leaving prerelease.
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: package is prerelease and not yet publicly advertised. Public docs will land alongside the first non-prerelease tag.

…ted from wrangler dev

Adds @cloudflare/wrangler-bundler, a ~150-line adapter on top of
wrangler's unstable_DevEnv API (rather than a fork of wrangler
internals) for projects that can't migrate to Vite.

The package ships a 'cf-wrangler' delegate binary that dispatches on
a leading subcommand verb. Today the only verb is 'dev'
(long-running esbuild + Miniflare + workerd dev server); future verbs
('build', 'deploy', etc.) follow the same shape. A parent process
invokes <pkgRoot>/bin/cf-wrangler dev [argv] with stdio inherited and
SIGINT/SIGTERM forwarded; unknown verbs exit 2 with a descriptive
error.

Inside, runDev constructs an unstable_DevEnv, wires SIGINT/SIGTERM to
teardown, and blocks on the 'teardown' event (mirroring the flow in
wrangler's own dev.ts:296-303).

Scope is deliberately limited to local-only sessions: --remote,
--routes, --host, --upstream-protocol, --tunnel, and --env (service
environments) are rejected at parse time; the auth hook is a stub
that throws if remote-binding codepaths invoke it. Pages/Sites,
multi-worker dev, and container image-uri pulling are out of scope
for v1. One-shot fast-path mode (--fast-path) is gated behind a
not-yet-implemented error.

Dev-registry path comes from miniflare's getDefaultDevRegistryPath
rather than workers-utils' getRegistryPath to sidestep the latter's
xdg-app-paths CJS-shim breakage in pure-ESM consumers. Both default
to $XDG_CONFIG_HOME/.wrangler/registry, so multi-session compat with
'wrangler dev' is preserved on the default path.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: d50ad3e

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/wrangler-bundler Minor

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
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 12, 2026

No labels, and no changeset. The changeset bot has flagged this. But that's between the author and the changeset policy — not a code review issue I should flag.

After thoroughly reviewing all the code, I find no actionable logic bugs, security issues, backward compatibility violations, or incorrect API behavior. The code is clean, well-documented, and correctly mirrors wrangler's own patterns. The signal handling is correct, the argv parsing properly rejects unsupported flags, the collectKeyValues/collectPlainTextVars implementations match wrangler's behavior, and the DevEnv lifecycle management follows the same pattern as wrangler's own dev command.

LGTM

github run

@github-actions
Copy link
Copy Markdown
Contributor

✅ All changesets look good

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