You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support loading cloudflare.config.ts when cf runs on Bun #252
Version:cf 1.0.0-beta.14 (same on beta.13), Bun 1.4.2, Node 24.21.0, linux-arm64
What happens
When cf runs on the Bun runtime in a directory that has a cloudflare.config.ts, every command fails, including account-level API commands that don't need the project:
┌ Error
│ cloudflare.config.ts loading is not supported on Bun. Please use Node.js
│ v22.18.0 or higher.
└
The docs say this is expected (Programmatic configuration: "Bun is not supported: when cf runs on Bun, loading the file fails"). This is a request to support it.
Repro
mkdir cf-bun &&cd cf-bun
echo'{ "name": "cf-bun", "private": true, "type": "module" }'> package.json
echo'export default { accountId: process.env.CLOUDFLARE_ACCOUNT_ID };'> cloudflare.config.ts
export CLOUDFLARE_ACCOUNT_ID=<account id>
CF=$(readlink -f "$(command -v cf)")
node "$CF" turnstile widgets list # works
bun "$CF" turnstile widgets list # fails with the error above
Scope, from the same machine:
Without a cloudflare.config.ts in the directory or any parent, bun "$CF" … works. With one in a parent directory it fails, since cf looks for the nearest config upwards, so running it on Bun anywhere inside a project fails.
bunx cf … works, because the bin/cf shebang runs Node rather than Bun.
So it breaks only when cf itself runs on Bun: bun --bun, Bun-only environments such as oven/bun images or CI runners without Node, or bun invoking the bin directly.
Why it matters
cf init --package-manager bun creates Bun projects, but the config those projects get can't be loaded by Bun. A Bun-first repository needs Node installed just to read its own config. Because most commands load the config (#207), it isn't limited to cf dev/cf build/cf deploy; account and resource commands run inside the project fail too.
Possible approaches
Load cloudflare.config.ts with Bun's native TypeScript import when process.versions.bun is set. Bun runs .ts modules directly, so the Node ≥ 22.18 type-stripping path isn't needed there.
Additional downstream case for the coordination requested when #256 was closed: Trigon runs cf 1.0.0-beta.14, @cloudflare/config 0.26.0 and Bun 1.4.2 on Windows. Our temporary adapter imports and validates the project config through Bun, emits Build Output v0, and invokes cf --prebuilt from a channel-specific directory outside the config's parent chain. Account/resource activation uses the documented HTTP API through separately scoped credentials because of the related #207 config-loading dependency.
We would like to retire the config-loader bypass once Bun config loading is supported. #256 already proposes the matching native-import approach, so we are not opening a duplicate. Could a maintainer confirm the preferred implementation location and whether #256 can be coordinated/reopened? In particular, the eventual regression should cover Windows file URLs and config paths with spaces, mode/function configs, upward lookup, and account-level commands from a project directory. We have not built or validated #256's head; the current adapter remains temporary.
We don't plan to add support for loading cloudflare.config.ts when using Bun. We believe that Bun compatibility issues should be fixed in Bun. If Bun adds support for registerHooks from node:module then we can reassess. Tracking issue: oven-sh/bun#27369.
New downstream availability update: the validated prebuilt adapter is now reusable outside Trigon on our fork branch, signed head 972f9ef57f545117d9be4aeb0413bd4a3d592cdf. Setup, source and regression instructions target Bun 1.4.2, @cloudflare/config 0.28.1, @cloudflare/build-output-utils 0.9.5 and cf 1.0.0-beta.14.
The standalone regression creates real Build Output v0 and validates it, rejects invalid configuration before output creation, and refuses to replace an existing output directory. It only imports a trusted config and writes caller-supplied compiled artifacts; it neither uploads nor obtains credentials. Callers retain their compilation/WASM, account, adoption and deployment checks.
There is also a separate account-scoped activation adapter with controlled-response tests and no external mutations. #207 is now closed by #372; our pinned beta.14 predates that fix, so its eventual removal is separate from the loader limitation here.
Validation limitation is documented in both examples: the exact upstream pnpm check could not run because the frozen dependency install rejected ten locked @oxc-parser/binding-*@0.76.0 entries as trust downgrades. We did not relax those protections, and do not claim a full cf source-suite pass.
We respect the decision to leave module-hook compatibility to oven-sh/bun#27369. These are downstream examples, not a repeat of #256 or a new request for Bun support. I can prepare an atomic PR if maintainers later want either example upstream.
Activity
iki commentedon Oct 16, 2026
Additional downstream case for the coordination requested when #256 was closed: Trigon runs cf 1.0.0-beta.14, @cloudflare/config 0.26.0 and Bun 1.4.2 on Windows. Our temporary adapter imports and validates the project config through Bun, emits Build Output v0, and invokes cf --prebuilt from a channel-specific directory outside the config's parent chain. Account/resource activation uses the documented HTTP API through separately scoped credentials because of the related #207 config-loading dependency.
We would like to retire the config-loader bypass once Bun config loading is supported. #256 already proposes the matching native-import approach, so we are not opening a duplicate. Could a maintainer confirm the preferred implementation location and whether #256 can be coordinated/reopened? In particular, the eventual regression should cover Windows file URLs and config paths with spaces, mode/function configs, upward lookup, and account-level commands from a project directory. We have not built or validated #256's head; the current adapter remains temporary.
jamesopstad commentedon Oct 20, 2026
We don't plan to add support for loading
cloudflare.config.tswhen using Bun. We believe that Bun compatibility issues should be fixed in Bun. If Bun adds support forregisterHooksfromnode:modulethen we can reassess. Tracking issue: oven-sh/bun#27369.iki commentedon Oct 27, 2026
New downstream availability update: the validated prebuilt adapter is now reusable outside Trigon on our fork branch, signed head
972f9ef57f545117d9be4aeb0413bd4a3d592cdf. Setup, source and regression instructions target Bun 1.4.2, @cloudflare/config 0.28.1, @cloudflare/build-output-utils 0.9.5 and cf 1.0.0-beta.14.The standalone regression creates real Build Output v0 and validates it, rejects invalid configuration before output creation, and refuses to replace an existing output directory. It only imports a trusted config and writes caller-supplied compiled artifacts; it neither uploads nor obtains credentials. Callers retain their compilation/WASM, account, adoption and deployment checks.
There is also a separate account-scoped activation adapter with controlled-response tests and no external mutations. #207 is now closed by #372; our pinned beta.14 predates that fix, so its eventual removal is separate from the loader limitation here.
Validation limitation is documented in both examples: the exact upstream
pnpm checkcould not run because the frozen dependency install rejected ten locked @oxc-parser/binding-*@0.76.0 entries as trust downgrades. We did not relax those protections, and do not claim a full cf source-suite pass.We respect the decision to leave module-hook compatibility to oven-sh/bun#27369. These are downstream examples, not a repeat of #256 or a new request for Bun support. I can prepare an atomic PR if maintainers later want either example upstream.