@cocos/rollup-plugin-terser

中文文档
0.4.5发布于 2024/11/12MITTypeScriptESM + CJS近 30 天下载 2522

Generate minified bundle

原始使用文档
文档目录6 节
  1. Requirements
  2. Install
  3. Usage
  4. Options
  5. maxWorkers
  6. Meta

npm size libera manifesto

@rollup/plugin-terser

🍣 A Rollup plugin to generate a minified bundle with terser.

Requirements

This plugin requires an LTS Node version (v14.0.0+) and Rollup v2.0+.

Install

Using npm:

npm install @rollup/plugin-terser --save-dev

Usage

Create a rollup.config.js configuration file and import the plugin:

import terser from '@rollup/plugin-terser';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [terser()]
};

Then call rollup either via the CLI or the API.

Options

The plugin accepts a terser Options object as input parameter, to modify the default behaviour.

In addition to the terser options, it is also possible to provide the following options:

maxWorkers

Type: Number
Default: undefined

Instructs the plugin to use a specific amount of cpu threads.

import terser from '@rollup/plugin-terser';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [
    terser({
      maxWorkers: 4
    })
  ]
};

Meta

CONTRIBUTING

LICENSE (MIT)

版本与发布记录

@cocos/rollup-plugin-terser 共发布 2 个版本,首次发布于 2024/11/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.4.5latest2024/11/122 年前
0.4.42024/11/072 年前

关于 @cocos/rollup-plugin-terser 的常见问题

@cocos/rollup-plugin-terser 是什么?

Generate minified bundle

如何安装 @cocos/rollup-plugin-terser?

在项目目录运行 npm install @cocos/rollup-plugin-terser,或使用 pnpm add / yarn add / bun add。

@cocos/rollup-plugin-terser 支持 TypeScript 吗?

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

@cocos/rollup-plugin-terser 支持 ESM 还是 CommonJS?

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

@cocos/rollup-plugin-terser 需要什么版本的 Node.js?

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

@cocos/rollup-plugin-terser 可以商用吗?

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

@cocos/rollup-plugin-terser 的下载量有多少?

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

@cocos/rollup-plugin-terser 还在维护吗?

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