@codecov/bundle-analyzer

中文文档
2.0.1发布于 2026/04/15MITTypeScriptESM + CJS近 30 天下载 8.6万

Official Codecov Bundle Analyzer

原始使用文档
文档目录5 节
  1. Installation
  2. Example - Custom Script
  3. Example - CLI
  4. Supported Platforms
  5. More information

Codecov by Sentry logo

Codecov Bundle Analyzer

The bundle analyzer is an importable library and CLI for Codecov bundle analysis. It is designed for users who operate without a standard bundler that is otherwise supported by Codecov's bundler plugins.

[!NOTE] The plugin does not support code coverage, see our docs to set up coverage today!

Installation

Using npm:

npm install @codecov/bundle-analyzer --save-dev

Using yarn:

yarn add @codecov/bundle-analyzer --dev

Using pnpm:

pnpm add @codecov/bundle-analyzer --save-dev

Example - Custom Script

This example shows how the package can be imported as a library.

// analyze.js
const { createAndUploadReport } = require("@codecov/bundle-analyzer");

const buildDirs = ["/path/to/build"];

const coreOpts = {
  dryRun: true,
  uploadToken: "your-upload-token",
  retryCount: 3,
  apiUrl: "https://api.codecov.io",
  bundleName: "@codecov/example-bundle-analyzer-cjs",
  enableBundleAnalysis: true,
  debug: true,
};

const bundleAnalyzerOpts = {
  beforeReportUpload: async (original) => original,
  ignorePatterns: ["*.map"],
  normalizeAssetsPattern: "[name]-[hash].js",
};

createAndUploadReport(buildDirs, coreOpts, bundleAnalyzerOpts)
  .then((reportAsJson) =>
    console.log(`Report successfully generated and uploaded: ${reportAsJson}`),
  )
  .catch((error) =>
    console.error("Failed to generate or upload report:", error),
  );

Example - CLI

This example shows how the package can be used as a CLI.

npx @codecov/bundle-analyzer ./dist --bundle-name=my-identifier --upload-token=abcd --dry-run

[OPTIONAL] - A config file can be passed for any extended options matching those described here.

npx @codecov/bundle-analyzer ./dist --bundle-name=my-identifier --upload-token=abcd --dry-run --config-file=./config.json
// config.json
{
  "gitService": "github",
  "oidc": {
    "useGitHubOIDC": false
  }
}

Supported Platforms

The CLI tool supports the following operating systems:

  • macOS
  • Linux

More information

版本与发布记录

@codecov/bundle-analyzer 共发布 14 个版本,首次发布于 2024/09/17;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.0.1latest2026/04/156 个月前
2.0.02026/04/156 个月前
1.9.12025/05/201.5 年前
1.9.02025/02/111.7 年前
1.8.02025/01/201.8 年前
1.7.02024/12/311.9 年前

关于 @codecov/bundle-analyzer 的常见问题

@codecov/bundle-analyzer 是什么?

Official Codecov Bundle Analyzer

如何安装 @codecov/bundle-analyzer?

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

@codecov/bundle-analyzer 支持 TypeScript 吗?

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

@codecov/bundle-analyzer 支持 ESM 还是 CommonJS?

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

@codecov/bundle-analyzer 需要什么版本的 Node.js?

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

@codecov/bundle-analyzer 可以商用吗?

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

@codecov/bundle-analyzer 的下载量有多少?

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

@codecov/bundle-analyzer 还在维护吗?

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