@fungi.computer/cloudflare-worker-bundler

中文文档
0.2.3-fungi.0发布于 2026/10/15MITTypeScriptES Module近 30 天下载 1.3万

Fork of @cloudflare/worker-bundler with an asset-serving entry free of the bundler graph

原始使用文档
文档目录6 节
  1. Runtime requirement
  2. Fungi fork
  3. Install
  4. Quick start
  5. Where it's used
  6. License

@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 ./assets entry that exports asset serving (handleAssetRequest, buildAssetManifest, buildAssets, createMemoryStorage, inferContentType, isTextContentType) without the esbuild/Sucrase bundler graph. src/index.ts re-exports the same names.
  • src/file-system.ts: imports DurableObjectStorage from @cloudflare/workers-types, now a dependency, so the published declarations type-check without ambient Workers types.
  • scripts/build.ts: builds the ./assets entry 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.

版本与发布记录

@fungi.computer/cloudflare-worker-bundler 共发布 2 个版本,首次发布于 2026/10/15;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.2.3-fungi.0latest2026/10/151 个月前
0.0.0-stage2026/10/151 个月前

关于 @fungi.computer/cloudflare-worker-bundler 的常见问题

@fungi.computer/cloudflare-worker-bundler 是什么?

Fork of @cloudflare/worker-bundler with an asset-serving entry free of the bundler graph

如何安装 @fungi.computer/cloudflare-worker-bundler?

在项目目录运行 npm install @fungi.computer/cloudflare-worker-bundler,或使用 pnpm add / yarn add / bun add。

@fungi.computer/cloudflare-worker-bundler 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fungi.computer/cloudflare-worker-bundler 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@fungi.computer/cloudflare-worker-bundler 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fungi.computer/cloudflare-worker-bundler 可以商用吗?

@fungi.computer/cloudflare-worker-bundler 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fungi.computer/cloudflare-worker-bundler 的下载量有多少?

根据 npm 官方下载统计,@fungi.computer/cloudflare-worker-bundler 在 2026/10/16 – 2026/11/14 这 30 天内被下载 12,581 次,日均约 419 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fungi.computer/cloudflare-worker-bundler 还在维护吗?

最新版本 0.2.3-fungi.0 发布于 2026/10/15(1 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/10/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。