# @goto-bus-stop/common-shake 中文文档

规范地址：https://npmcn.com/package/%40goto-bus-stop/common-shake/

版本：2\.4\.1
npm 元数据更新时间：2024-01-04T12:58:57.376Z
中文译文更新时间：2026-11-16T20:32:11.752Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40goto-bus-stop/common-shake
原文对照：https://npmcn.com/package/%40goto-bus-stop/common-shake/?lang=original
项目主页：https://github.com/goto-bus-stop/common-shake#readme
源码仓库：https://github.com/goto-bus-stop/common-shake

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：29.7 kB，8 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- 运行依赖：3 个
- 首次发布：2018-04-11T10:33:44.741Z
- 最新版本发布：2024-01-04T12:58:57.217Z
- 近 30 天下载量：95841（2026-10-17 至 2026-11-15，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

普通JS 树摇 (叉子)

## 安装

```sh
npm install @goto-bus-stop/common-shake
```

也可以使用：`pnpm add @goto-bus-stop/common-shake`、`yarn add @goto-bus-stop/common-shake`、`bun add @goto-bus-stop/common-shake`

## README

# @go-bus-stop/common-shake (英语)

[![NPM version](https://badge.fury.io/js/%40goto-bus-stop%2Fcommon-shake.svg)](http://badge.fury.io/js/%40goto-bus-stop%2Fcommon-shake) [![Build Status](https://secure.travis-ci.org/goto-bus-stop/common-shake.svg)](http://travis-ci.org/goto-bus-stop/common-shake)

> 这是叉子 [倒数/平缓](https://github.com/indutny/common-shake), (中文(简体) ), 待处理 [3号](https://github.com/indutny/common-shake/pull/3)。 。 。 .

* * *

见 [网络包- 常见震动](https://github.com/indutny/webpack-common-shake) 页:1 [网络软件包](https://webpack.github.io/) 插件 . 见 [常态变化](https://github.com/browserify/common-shakeify) (单位:千美元) [浏览器](https://browserify.org/) 插件 .

## 使用量

```js
const acorn = require('acorn');
const Analyzer = require('@goto-bus-stop/common-shake').Analyzer;

const a = new Analyzer();

a.run(acorn.parse(`
  'use strict';
  const lib = require('./a.js');
  exports.a = lib.a;
`, { locations: true }), 'index.js');

a.run(acorn.parse(`
  'use strict';
  exports.a = 42;
`, { locations: true }), 'a.js');

a.resolve('index.js', './a.js', 'a.js');
console.log(a.isSuccess(), a.bailouts);
// true false

console.log(a.getModule('index.js').getInfo());
// { bailouts: false, declarations: [ 'a' ], uses: [] }

console.log(a.getModule('a.js').getInfo());
// { bailouts: false, declarations: [ 'a' ], uses: [ 'a' ] }

const module = a.getModule('a.js');
a.getDeclarations().forEach((decl) => {
  console.log(module.isUsed(decl.name) ? 'used' : 'not used');
  console.log(decl.name, decl.ast);
});

// If you want to mark all exported values of module as used:
a.getModule('root').forceExport();
```

## 图维兹

用于调试和检查目的: [点](http://www.graphviz.org/content/dot-language) 格式可以是 使用下列 API 生成的模块等级:

```js
const Graph = require('@goto-bus-stop/common-shake').Graph;
const graph = new Graph('/path/to/working/dir');

console.log(graph.generate(analyzer.getModules()));
```

## 自由主义

这个软件根据麻省理工学院的许可证获得许可.

2017年,版权由费多尔·Indutny提供.

特此免费准许任何人获得 本软件和相关文档文件的复制件 “软件”,在软件中不受限制地处理,包括 不限制使用、复制、修改、合并、出版、, 软件的分发、分版和/或销售,并允许 提供软件的人 下列条件:

上述版权通知和本许可通知应当包括: 软件的所有副本或大部分.

软件被提供"AS IS", 没有任何恐惧, EXPRESS ,包括但不局限于 紧迫性,特别是目的和非目的的证明。 内 对于任何索赔, 都不得使用任何连锁电话或警察电话, 转让或其他责任,以契约、条约或 产生于、出自或与溶剂有关的 在软件中使用或其他交易.

## 常见问题

### @goto-bus-stop/common-shake 是什么？

普通JS 树摇 \(叉子\)

### 如何安装 @goto-bus-stop/common-shake？

在项目目录运行 npm install @goto-bus-stop/common-shake，或使用 pnpm add / yarn add / bun add。

### @goto-bus-stop/common-shake 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/goto-bus-stop\_\_common-shake 是否存在。

### @goto-bus-stop/common-shake 支持 ESM 还是 CommonJS？

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

### @goto-bus-stop/common-shake 可以商用吗？

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

### @goto-bus-stop/common-shake 的下载量有多少？

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

### @goto-bus-stop/common-shake 还在维护吗？

最新版本 2\.4\.1 发布于 2024/01/04（2 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/04/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

