[wrangler-bundler] new package: esbuild-based dev server extracted from wrangler dev#13892
[wrangler-bundler] new package: esbuild-based dev server extracted from wrangler dev#13892penalosa wants to merge 2 commits into
Conversation
…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 detectedLatest commit: d50ad3e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
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 LGTM |
|
✅ All changesets look good |
Adds
@cloudflare/wrangler-bundler— a thin (~150-line) adapter on top of wrangler'sunstable_DevEnvAPI, exposing an esbuild-based dev server via acf-wranglerdelegate binary. Targets projects that can't migrate to Vite (the recommended path remains@cloudflare/vite-plugin).The package ships a
cf-wranglerbinary that dispatches on a leading subcommand verb. Today the only verb isdev(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 todevEnv.teardown().Scope is deliberately limited to local-only sessions for v1:
--remote,--routes,--host,--upstream-protocol,--tunnel,--envare rejected at parse time with messages pointing atwrangler dev.remote = trueon a binding).--fast-path(one-shot mode) is gated behind a not-yet-implemented error.Dev-registry path comes from miniflare's
getDefaultDevRegistryPathrather than workers-utils'getRegistryPathto sidestep the latter'sxdg-app-pathsCJS-shim breakage in pure-ESM consumers. Both default to$XDG_CONFIG_HOME/.wrangler/registry, so multi-session compat withwrangler devis preserved on the default path."workers-sdk": { "prerelease": true }, no publicbinconsumers yet). Integration coverage will land out-of-package via a parent process that spawns thecf-wranglerbinary against a fixture project; that harness is being built separately and will gate the package leaving prerelease.