@fungi.computer/cloudflare-worker-bundler
Experimental: this package is under active development and its API may change without notice. Not recommended for production use.
Bundles and serves full-stack applications on Cloudflare's Worker Loader binding (closed beta). It dynamically generates Workers with real npm dependencies, or builds complete apps with client-side bundles and static asset serving.
Runtime requirement
This package only runs inside the Cloudflare Workers runtime (workerd) —
both in production and in wrangler dev. It bundles via an esbuild-wasm
WebAssembly.Module import that only the Workers module loader can resolve.
It will not work under plain Node.js, including a default-pool
Vitest/Jest test; test code that depends on it needs
@cloudflare/vitest-pool-workers.
The ./assets entry (see below) is the exception: it has no bundler
dependency and runs anywhere.
Fungi fork
This package is a Fungi fork of
@cloudflare/worker-bundler
0.2.3 (commit d424945), distributed under the MIT License. Changes from
upstream, made by Fungi Computer:
src/assets.ts: a new./assetsentry that exports asset serving (handleAssetRequest,buildAssetManifest,buildAssets,createMemoryStorage,inferContentType,isTextContentType) without the esbuild/Sucrase bundler graph.src/index.tsre-exports the same names.src/file-system.ts: importsDurableObjectStoragefrom@cloudflare/workers-types, now a dependency, so the published declarations type-check without ambient Workers types.scripts/build.ts: builds the./assetsentry and drops the upstream monorepo declaration-formatting step.src/index.ts,src/app.ts,src/asset-handler.ts: three expressions rewritten without a redundant spread so the fork passes oxlint's correctness rules.- Only the Node-runnable upstream tests (
asset-handler,redos) are kept.
See NOTICE for the full attribution text.
Install
npm install @fungi.computer/cloudflare-worker-bundler
Quick start
Bundle a Worker — provide source code and dependencies, the bundler handles the rest:
import { createWorker } from "@fungi.computer/cloudflare-worker-bundler";
const worker = env.LOADER.get("my-worker", async () => {
const { mainModule, modules } = await createWorker({
files: {
"src/index.ts": `
import { Hono } from 'hono';
const app = new Hono();
app.get('/', (c) => c.text('Hello from Hono!'));
export default app;
`,
"package.json": JSON.stringify({ dependencies: { hono: "^4.0.0" } })
}
});
return { mainModule, modules, compatibilityDate: "2026-01-01" };
});
await worker.getEntrypoint().fetch(request);
Serve static assets from the standalone ./assets entry (no bundler graph
required):
import {
handleAssetRequest,
buildAssets
} from "@fungi.computer/cloudflare-worker-bundler/assets";
const { manifest, storage } = await buildAssets({
"/index.html": "<h1>Hello</h1>"
});
export default {
async fetch(request) {
const assetResponse = await handleAssetRequest(request, manifest, storage);
if (assetResponse) return assetResponse;
return new Response("API");
}
};
createApp bundles a server Worker, client-side JavaScript, and static
assets together in one call; see the
upstream README
for createApp, the full createWorker/createApp option tables, the
FileSystem interface (InMemoryFileSystem, DurableObjectKVFileSystem,
DurableObjectRawFileSystem), the in-process TypeScript language service
(./typescript subpath), asset configuration (HTML/not-found handling,
redirects, headers, caching), and known limitations — none of that changed in
this fork beyond the ./assets entry point described above.
Where it's used
Oyster uses this fork to bundle
and serve Worker apps, and uses the ./assets entry to serve static assets
without pulling in the bundler.
License
MIT. This package carries the upstream Cloudflare copyright and license unchanged — see LICENSE and NOTICE.