Repository navigation
Public APIs for non-Vite bundler integrations #17042
workers-devprod
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Moved from #16984. Originally opened by Cherry on 2026-11-17.
I maintain rspack-plugin-cloudflare, an rspack equivalent of
@cloudflare/vite-plugin. Getting it to behave likewrangler devandwrangler deploymeans submodulingworkers-sdkand reaching into a lot of internals, and most of what we use from wrangler has no future now thatcfis taking over I think?Vite plugin v2 is the model I'd like to follow: it doesn't depend on wrangler at all, and
cfruns it forcf dev,cf buildandcf deploy. But many of the pieces it builds on are private or marked internal, so anyone doing the same for other ecosystem bundlers has to vendor or pin them like we do. I'd love a small public surface for this.What we rely on today
@cloudflare/workers-sharedis marked private (its last npm release was 0.17.5, in April 2025). We bundle the router and asset Workers and the_headers/_redirectsparsers from it. The Vite plugin bundles the same package from the workspace.AssetWorkerInnerand overridingunstable_exists/unstable_getByETagso assets come from rspack's output instead of a manifest. The Vite plugin overrides the same two methods to serve HTML from Vite.unstable_*exports:unstable_readConfig, plus the undocumentedunstable_getMiniflareWorkerOptions,unstable_getVarsForDevandunstable_resolveNamedTunnel, withwrangleras a peer dependency. The Vite plugin uses@cloudflare/config,@cloudflare/workers-utils, Miniflare'sresolveLocalBindingsand the private@cloudflare/remote-bindingsinstead.require, so the options wrangler generates match the Miniflare it ships. The Vite plugin depends on Miniflare directly and builds its own options.unsafe*Miniflare options and internals for HMR, routing and the dev registry:unsafeModuleFallbackService,CoreHeaders.ROUTE_OVERRIDE,kUnsafeEphemeralUniqueKey,unsafeDevRegistryPathand friends. The Vite plugin uses the same ones.@cloudflare/workers-utils(normalizeAndValidateConfig,convertConfigToBindings,printBindings,getNodeCompat,DEFAULT_MODULE_RULES,PATH_TO_DEPLOY_CONFIG,getDockerPath),@cloudflare/config(loadAndParseConfig,convertToWranglerConfig) and@cloudflare/containers-shared(container dev plans and image builds). Each one says in itspackage.jsonthat it's internal or not stable for external use.unenvandunenv-preset, to the versions from the matching wrangler release. Every sync is a release on our side.wrangler.jsonbefore writing the.wrangler/deploy/config.jsonredirect. The redirect is documented, but apart from "should not include any environments" the docs don't say what a generated config can contain.Remote bindings are the exception:
unstable_readConfigandmaybeStartOrUpdateRemoteProxySessionare both covered in the local development docs.Where
cffitsWe'd like to move straight to
cfrather than rebuild on anything wrangler-specific, but I can't find a way in for a third-party build tool yet:cf dev/cf build/cf deployrun a detected framework's command (that's how Vite projects work), or a dev server from a fixed list. Incf@1.0.0-rc.0that list is Wrangler plus Python and Rust dev servers, with no way to add to it.cf-wranglerdelegate binary and the Vite plugin an experimentalcf-viteone, but that contract is internal..cloudflare/output/v0/) has no public spec, and@cloudflare/build-output-utilssays it isn't stable for external use. Wrangler refuses to deploy a project that contains it, so there's no fallback either.cf deploy --prebuiltcould cover deploys if the format were documented.So for now we stay on the
.wrangler/deployredirect, which ties us to wrangler for deploys too.What would help
Most of this already exists inside workers-sdk, it just isn't published or stable.
@cloudflare/unenv-presetis a good example of a shared package we use as-is with no issues.cfdrive third-party build tools: a public version of the delegate contract (cf-wrangler/cf-vite) that any package can implement, plus a documented Build Output format to write.cloudflare.config.ts(orwrangler.*), and get a Worker's Miniflare options, external Workers and asset config.@cloudflare/config,workers-utilsand Miniflare'sresolveLocalBindingsare most of the way there.nodejs_compataliases and injects,define,aliasand module rules.Something like this (names are placeholders):
Bundling, HMR and the dev server would stay with each framework.
Links
src/assets.ts,src/dev-worker.ts,scripts/sync-upstream.tsworkspace:*deps and asset Worker overridecfruns your project@cloudflare/build-output-utilsworkers-devprod commented on 2026-11-17:
Automated triage
Issue assessment
enhancement(high)package:wrangler(high)package:workers-shared(medium)package:miniflare(medium)package:workers-utils(medium)Actionability and missing information
Feature request from the rspack-plugin-cloudflare maintainer for stable public APIs (config, local dev plan, asset workers, bundler contract, delegate and Build Output spec) to replace reliance on wrangler unstable exports and internal package internals; actionable, nothing material missing.
Reproduction reason: The report is a feature request for public APIs and stabilization of internals; it describes no current behavior defect to reproduce.
This summary was generated by an LLM and may contain errors. Please verify its findings.
Triage bot commands and options
Repository collaborators with write or admin access can trigger actions by commenting on this issue:
@workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.piyushraj44 commented on 2026-11-18:
Hi, I'd like to help with point 5, the bundler contract. I added a small
getBundlerContract({ compatibilityDate, compatibilityFlags })to@cloudflare/config. It returns the resolve conditions, thecloudflare:built-ins, the Node.js compat mode, thenavigator.userAgentdefine and the default module rules, all from the same helpers Wrangler and the Vite plugin use.Branch with tests: https://github.com/piyushraj44/workers-sdk/tree/feat/issue-16984
I'm not vouched yet, so would you be open to a PR for this?
All reactions