@cyclonedx/cyclonedx-esbuild

中文文档
1.4.4发布于 2026/08/11Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 13.3万

由 Esbuilt 或 Bun 所建项目创建 CyproogleDX 软件软件单(SBOM).

中文使用文档
文档目录10 节
  1. 特征
  2. 所需资源
  3. 安装
  4. 使用量
  5. 插件使用( 构建和组件)
  6. CLI 工具
  7. 以角为单位使用
  8. 内部
  9. 发展和贡献
  10. 许可证

气旋DX SBOM 生成器 兴建 财务报告和审定财务报表 阿宝

shield_npm-version shield_gh-workflow-test shield_coverage shield_ossf-best-practices shield_license
shield_website shield_slack shield_groups shield_twitter-follow


创建 旋风DX 软件 材料单(SBOM) 兴建 或者说 阿宝。 。 。 .

本套件提供:

  • (单位:千美元) 用于 兴建- 兼容的捆绑机 - 与 兴建 财务报告和审定财务报表 阿宝
  • (单位:千美元) CLI 工具 从相容的建筑生成SBOMS 元文件

工具使用捆绑过程中产生的依赖关系信息创建目录 和依赖图(即为什么将一个组件纳入最后捆绑).
只有实际包含在最后捆绑中的依赖性(在 树摇页:1.

生成的 SBOM 文件如下 正式规格和标准, (中文(简体) ), 并可能具有属性 cdx:esbuild 命名空间分类学 财务报告和审定财务报表 cdx 命名空间分类学。 。 。 .

特征

  • 🔌 用于相容捆绑器的插件 (单位:千美元)兴建, (中文(简体) ), 阿宝(中文(简体) )
  • 🖥️ CLI 工具 从相容元文件生成 SBOMS
  • QQ 支持多个 旋风DX光谱版本 (1.2、1.3、1.4、1.5、1.6、1.7)
  • 从捆绑的项目中提取组件和依赖性
  • 📝 许可证证据的收集
  • ✅ 验证 生成 SBOMS 对抗气旋DX 计划
  • 🔄 可复制产出 选项,用于一致的 SBOM 生成
  • 与 类型脚本, (中文(简体) ), 角质和其他现代框架

所需资源

下列运行时间之一:

  • 节点.js >= 20.18
  • 阿宝 >= 1.3.6

某些特征需要可选(同级)依赖性——见 package.json 用于版本限制.

  • 兴建 —— 使用有 esbuilt 的插件时需要
  • 页:1, (中文(简体) ), ajv 格式 打开 ajv-formats-草案2019 ——SBOM JSON结果验证所需

安装

使用您首选的软件包管理器并安装为 dev- dependency :

npm install --save-dev @cyclonedx/cyclonedx-esbuild
pnpm add --save-dev @cyclonedx/cyclonedx-esbuild
yarn add --dev @cyclonedx/cyclonedx-esbuild
bun add --dev @cyclonedx/cyclonedx-esbuild

使用量

插件使用( 构建和组件)

该插件与 相容的捆绑机。 。 。 .
由于 Bun 提供了与 esbuild 兼容的插件 API,因此同一插件可以在两种环境中使用.

插件选项配置( C)

名称类型默认说明
specVersion{string}
其中一个: "1.2", (中文(简体) ), "1.3", (中文(简体) ), "1.4", (中文(简体) ), "1.5", (中文(简体) ), "1.6", (中文(简体) ), "1.7"
"1.6"[CycloneDX- spec] 的哪个版本要使用.
支持的值取决于安装的依赖性 旋风DX-javascript-图书馆。 。 。 .
输出文件{string}"bom.json"输出文件路径 .
组图文集{boolean}false搜索组件中的许可证文件,并将其作为许可证证据.
这个特征是实验性的.
可复制{boolean}false是否要多走一英里, 使输出可复制 .
这需要更多的资源,并可能导致时间价值和随机价值的损失.
mc 类型{string}"application"设置主组件类型 .
见 有效数值列表。 。 。 .
验证{boolean | undefined}undefined输出前验证生成的 BOM .
如果不符合要求,则取消验证.
日志级别{string | undefined}undefined控制插件的动词。 接受由 兴起的 logLevel 或 Bun 中的相应设置.
如果没有设定,插件将继承 logLevel 从构建配置。 如果该值也是未定义的,它会回到 "warning"。 。 。 .

插件示例: 新建

// build.js
const esbuild = require('esbuild');
const { cyclonedxEsbuildPlugin } = require('@cyclonedx/cyclonedx-esbuild');

/** @type {import('@cyclonedx/cyclonedx-esbuild').CycloneDxEsbuildPluginOptions} */
const cyclonedxEsbuildPluginOptions = {
  specVersion: '1.7',
  outputFile: 'bom.json'
}

esbuild.build({
  // ...
  plugins: [
    cyclonedxEsbuildPlugin(cyclonedxEsbuildPluginOptions),
  ]
});

参见实例: 与建设一体化。 。 。 .

插件示例: Bun

自兹 阿宝插件 API 简约基于 兴建's, 此插件也可以用于 阿宝 使用内置捆绑器(Bun v1.3.6+)的项目.

// build.ts
import { cyclonedxEsbuildPlugin } from "@cyclonedx/cyclonedx-esbuild"

await Bun.build({
  // ...
  metafile: true, // required for `cyclonedxEsbuildPlugin` to work with Bun
  plugins: [
    cyclonedxEsbuildPlugin({
      outputFile: "bom.json",
      // ...
    }),
  ],
})

export {}

参见实例: 与 Bun 合并。 。 。 .

CLI 工具

用于生成 SBOMS 的命令行接口 建立元文件。 。 。 .

CLI 调用

调用 CLI 取决于所使用的安装方法 .
以下是各种软件包管理器和设置的例子:

npm exec -- cyclonedx-esbuild --help
pnpm exec cyclonedx-esbuild --help
yarn exec cyclonedx-esbuild --help

CLI 帮助页面

Usage: cyclonedx-esbuild [options] <metafile>

Create CycloneDX Software Bill of Materials (SBOM) from esbuild-compatible metafile.

Arguments:
  metafile                          Path to esbuild-compatible metafile

Options:
  --bwd, --build-working-dir <dir>  Working dir used in the build process.
                                    (default: current working dir)
  --gather-license-texts            Search for license files in components and include them as license evidence.
                                    This feature is experimental. 
                                    (default: false)
  --sv, --spec-version <version>    Which version of CycloneDX spec to use. 
                                    (choices: "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", default: "1.6")
  --output-reproducible             Whether to go the extra mile and make the output reproducible.
                                    This requires more resources, and might result in loss of time- and random-based-values. 
                                    (env: BOM_REPRODUCIBLE)
  -o, --output-file <file>          Path to the output file.
                                    Set to "-" to write to STDOUT.
                                    (default: write to STDOUT)
  --validate                        Validate resulting BOM before outputting.
                                    Validation is skipped, if requirements not met.
  --no-validate                     Disable validation of resulting BOM.
  --mc-type <type>                  Type of the main component.
                                    (choices: "application", "firmware", "library", default: "application")
  -v, --verbose                     Increase the verbosity of messages.
                                    Use multiple times to increase the verbosity even more.
  -V, --version                     output the version number
  -h, --help                        display help for command

以角为单位使用

对于 角质 使用 兴建 (Angular 17+),您可以从构建数据生成SBOMS.

// package.json
{
  "scripts": {
    "build:app": "ng build --stats-json",
    "build:sbom": "cyclonedx-esbuild --gather-license-texts --output-reproducible -o dist/bom.json dist/stats.json",
    "build": "npm run build:app && npm run build:sbom"
  }
}

例如: 与Angular20的融合。 。 。 .

内部

这种工具利用 旋风DX库 生成实际数据结构.

除了班级 CycloneDxEsbuildPlugin 和接口 CycloneDxEsbuildPluginOptions, (中文(简体) ),
这个 兴建 插件和此工具确实 没有 披露任何额外的 公开 API或类 - 所有代码都是为了内部的,在版本升级时可能会不经任何通知而更改.

但是,CLI是稳定的,你可以称之为程序上的:

const { execFileSync } = require('child_process')
const { constants: { MAX_LENGTH: BUFFER_MAX_LENGTH } } = require('buffer')
const sbom = JSON.parse(execFileSync(process.execPath, [
    '../path/to/this/package/bin/cyclonedx-esbuild-cli.js',
    '--spec-version', '1.7',
    '--output-file', '-'
    // additional CLI args
], { stdio: ['ignore', 'pipe', 'ignore'], encoding: 'buffer', maxBuffer: BUFFER_MAX_LENGTH }))

发展和贡献

随意打开问题,错误报告或调取请求.
见 捐款 详细文件.

许可证

根据Apache 2.0许可证的规定,允许修改和再分配.
见 自由主义 完整许可证存档.

版本与发布记录

@cyclonedx/cyclonedx-esbuild 共发布 22 个版本,首次发布于 2025/11/13;过去 12 个月发布了 22 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.4.4latest2026/08/112 个月前
1.4.32026/08/103 个月前
1.4.3-rc.1unstable-prerelease2026/08/103 个月前
1.4.3-rc.02026/07/283 个月前
1.4.22026/07/024 个月前
1.4.12026/06/304 个月前

关于 @cyclonedx/cyclonedx-esbuild 的常见问题

@cyclonedx/cyclonedx-esbuild 是什么?

由 Esbuilt 或 Bun 所建项目创建 CyproogleDX 软件软件单(SBOM).

如何安装 @cyclonedx/cyclonedx-esbuild?

在项目目录运行 npm install @cyclonedx/cyclonedx-esbuild,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cyclonedx-esbuild,可以用 npx cyclonedx-esbuild 直接运行。

@cyclonedx/cyclonedx-esbuild 支持 TypeScript 吗?

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

@cyclonedx/cyclonedx-esbuild 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cyclonedx/cyclonedx-esbuild 需要什么版本的 Node.js?

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

@cyclonedx/cyclonedx-esbuild 可以商用吗?

@cyclonedx/cyclonedx-esbuild 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cyclonedx/cyclonedx-esbuild 的下载量有多少?

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

@cyclonedx/cyclonedx-esbuild 还在维护吗?

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