@api3/commons

中文文档
2.0.0发布于 2026/08/31MITTypeScriptESM + CJS构建来源已验证近 30 天下载 4438

Common utilities, modules and configurations used in API3 projects.

原始使用文档
文档目录6 节
  1. Getting started
  2. Modules
  3. Using the package in universal context
  4. ESM and CommonJS
  5. Related repositories
  6. For developers

commons

Common utilities, modules and configurations used in API3 projects.

The commons library is meant to stop "reinventing the wheel". It holds the canonical implementations that can be imported in other packages. This way we ensure that all package use the same logic, simplify bug fixes and avoid code duplication. The package is cross platform and can be used in Node.js and browser.

The commons library is a collection of multiple modules, with each module having its own README that you can refer to.

Getting started

# Feel free to use your favorite package manager
pnpm i @api3/commons

Read the documentation and sources of each module how to use it in the project.

Modules

Using the package in universal context

Some modules may be used only in both browser and Node.js context and some are Node.js only. To support this requirement, we use different entrypoints for each context. Note, there is no support for browser-only modules.

The bundler or Node.js picks up the right entrypoint automatically, but bear in mind that only a subset of modules is available when using universal modules. If you use TypeScript, it may not pick up the correct types. You can set these manually, by adding the following to your tsconfig.json:

"compilerOptions": {
  "paths": {
    "@api3/commons": ["./node_modules/@api3/commons/dist/esm/universal-index.d.ts"]
  }
}

ESM and CommonJS

The package ships both module systems. dist/esm holds the ES modules and dist/cjs holds the CommonJS modules. Both come with type declarations. The bundler or Node.js picks the right one through the exports field, so import and require both work without any configuration on your side.

For developers

Please refer to the developer instructions for details.

版本与发布记录

@api3/commons 共发布 28 个版本,首次发布于 2023/10/09;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.0latest2026/08/312 个月前
1.3.02026/08/073 个月前
1.2.02026/02/208 个月前
1.1.22026/01/0110 个月前
1.0.12025/08/011.3 年前
1.0.02025/07/311.3 年前

关于 @api3/commons 的常见问题

@api3/commons 是什么?

Common utilities, modules and configurations used in API3 projects.

如何安装 @api3/commons?

在项目目录运行 npm install @api3/commons,或使用 pnpm add / yarn add / bun add。

@api3/commons 支持 TypeScript 吗?

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

@api3/commons 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@api3/commons 需要什么版本的 Node.js?

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

@api3/commons 可以商用吗?

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

@api3/commons 的下载量有多少?

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

@api3/commons 还在维护吗?

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