@grafana/levitate

中文文档
0.18.0发布于 2026/09/29Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 8万

A tool for helping to understand APIs exported and consumed by NPM packages (or any TypeScript code).

原始使用文档
文档目录3 节
  1. Usage
  2. Ignore specific exports changes
  3. Contributing

🔮 Levitate

npm version npm downloads CI prettier TypeScript

A tool for helping to understand APIs exported and consumed by NPM packages (or any TypeScript code).

Usage

Compare exports of different package versions

# Compare exports of different versions of a package
npx @grafana/levitate compare \
    --prev @grafana/[email protected] \
    --current @grafana/ui@canary

List imports

# List the imports used by a program
npx @grafana/levitate list-imports \
    --path <PATH-TO-A-PACKAGE>/module.ts \
    --filters "@common/pages" "@grafana/data" \
    --verbose

List exports

# List the exports of a compiled package
npx @grafana/levitate list-exports \
    --path <PATH-TO-A-PACKAGE>/index.d.ts

Check compatibility between a module and a package

To check the compatibility of code using a specific version of a package (e.g.: @grafana/[email protected]) against another version of the same package (e.g. @grafana/[email protected]).

# Check if the current module.ts usage of @grafana/data is
# compatible with the latest version of it
npx @grafana/levitate is-compatible \
    --path <PATH-TO-A-PACKAGE>/module.ts \
    --target "@grafana/data@latest"

Ignore specific exports changes

To ignore changes (add, change, remove) from specific export names you can create a .levignore.js file in the same directory where you invoke levitate.

The format of this file should be as follows:

module.exports = {
  removals: [
    // each entry is a regex
    /Sample\.ignoreThisOne/,
    /Sample\.ignoreThisOneToo/,
    /Sample.*\b/,
    'Sample.ignoreThisOneToo', // strings are converted to regex to match exact
  ],
  changes: [
    //...
  ],
  additions: [
    //...
  ],
};

Note:

  • Levitate will ignore symbols matching the regexes in any of the packages it inspects. If several packages export the same symbol name, they all will be ignored.
  • This only affects the compare and is-compatible commands. It doesn't affect the list-imports or list-exports commands.
  • You should locate your .levignore.js file in the same directory where you invoke levitate.

Contributing

If you are interested in contributing to the Levitate project please read the Contributing guide.

版本与发布记录

@grafana/levitate 共发布 43 个版本,首次发布于 2021/12/14;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.18.0latest2026/09/291 个月前
0.17.32026/05/275 个月前
0.17.22025/11/011 年前
0.17.12025/06/181.4 年前
0.17.02025/06/171.4 年前
0.16.42025/06/121.4 年前

关于 @grafana/levitate 的常见问题

@grafana/levitate 是什么?

A tool for helping to understand APIs exported and consumed by NPM packages (or any TypeScript code).

如何安装 @grafana/levitate?

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

@grafana/levitate 支持 TypeScript 吗?

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

@grafana/levitate 支持 ESM 还是 CommonJS?

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

@grafana/levitate 需要什么版本的 Node.js?

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

@grafana/levitate 可以商用吗?

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

@grafana/levitate 的下载量有多少?

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

@grafana/levitate 还在维护吗?

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