@bakery-framework/core

中文文档
2.4.4发布于 2026/11/14SEE LICENSE IN LICENSEES Module零依赖构建来源已验证近 30 天下载 2722

Bakery framework core: handlers, router, config, session, caches, logger, compiler.

原始使用文档
文档目录4 节
  1. Usage
  2. JSX setup
  3. Notes
  4. License

@bakery-framework/core

The core of Bakery: request handling, routing, sessions, caching and the server-side JSX runtime.

Bun only. This package ships TypeScript source with no build step, and the runtime depends on Bun APIs throughout. It will not run on Node.

bun add @bakery-framework/core @bakery-framework/cli

@bakery-framework/cli owns the bakery binary that actually starts a server: core on its own is the library it starts.

Usage

// server.config.ts
import { defineConfig } from '@bakery-framework/core'

export default defineConfig({
  root: 'src',
  port: 3000,
})

Every file under root is a route. A .tsx file is a page, a .ts file under api/ is an endpoint:

// src/api/hello.ts
import { defineRoute, response } from '@bakery-framework/core'

export default defineRoute(async req => {
  return response.json.success('ok', { method: req.method })
})

JSX setup

Pages are rendered server-side through Bakery's own createElement, so an app's tsconfig.json must set the classic runtime locally:

{
  "extends": "@bakery-framework/core/tsconfig.server.json",
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "createElement",
    "jsxFragmentFactory": "Fragment"
  }
}

extends alone is not enough. Bun's runtime does not follow extends into a package specifier, so without the three options repeated here every .tsx route fails with Cannot find module 'react/jsx-dev-runtime', while tsc stays perfectly happy, because it does follow the extends.

The fastest way to get a correct setup is to let the scaffolder write one:

bun create bakery my-app

Notes

  • No runtime dependencies.
  • An unconfigured app gets an on-by-default per-IP rate limit (100 burst, 10 req/s). The startup banner says so; rateLimit: false turns it off.
  • The export map is curated: only the subpaths it names can be imported, and everything else is private. If you need something that is not exposed, open an issue rather than reaching for a deep path: it will not resolve.

Full documentation lives in the repository.

License

MIT with the Commons Clause v1.0. See LICENSE. In short: use,

Not an OSI-approved license. The Commons Clause removes the right to sell the software: meaning to charge for a product or service whose value derives substantially from it, hosting and support included. Everything else the MIT license grants is unchanged: use it, modify it, ship it inside your own product. If your organization only permits OSI-approved dependencies, this will not pass that check. modify and distribute freely; selling the software itself is not granted.

版本与发布记录

@bakery-framework/core 共发布 49 个版本,首次发布于 2026/08/10;过去 12 个月发布了 49 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.4.4latest2026/11/14今天
2.5.0-alpha.2alpha2026/11/067 天前
2.4.32026/11/067 天前
2.5.0-alpha.12026/10/2519 天前
2.4.22026/10/2519 天前
2.5.0-alpha.02026/10/2420 天前

其他发布通道:rc → 2.0.0-rc.5,alpha → 2.5.0-alpha.2。

关于 @bakery-framework/core 的常见问题

@bakery-framework/core 是什么?

Bakery framework core: handlers, router, config, session, caches, logger, compiler.

如何安装 @bakery-framework/core?

在项目目录运行 npm install @bakery-framework/core,或使用 pnpm add / yarn add / bun add。

@bakery-framework/core 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/bakery-framework__core 是否存在。

@bakery-framework/core 支持 ESM 还是 CommonJS?

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

@bakery-framework/core 可以商用吗?

@bakery-framework/core 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@bakery-framework/core 的下载量有多少?

根据 npm 官方下载统计,@bakery-framework/core 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,722 次,日均约 91 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bakery-framework/core 还在维护吗?

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