Rollup plugin to minify generated bundle
Installations
npm install rollup-plugin-terser
Developer Guide
Typescript
Yes
Module System
CommonJS, ESM
Score
69.1
Supply Chain
96.8
Quality
77.7
Maintenance
100
Vulnerability
99.6
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
TrySound
Download Statistics
Total Downloads
750,613,243
Last Day
228,978
Last Week
2,583,549
Last Month
14,921,437
Last Year
202,989,131
GitHub Statistics
611 Stars
86 Commits
55 Forks
3 Watching
2 Branches
16 Contributors
Bundle Size
674.75 kB
Minified
189.94 kB
Minified + Gzipped
Package Meta Information
Latest Version
7.0.2
Package Id
rollup-plugin-terser@7.0.2
Size
3.56 kB
Publised On
04 Sept 2020
Total Downloads
Cumulative downloads
Total Downloads
750,613,243
Last day
-65.2%
228,978
Compared to previous day
Last week
-27.5%
2,583,549
Compared to previous week
Last month
-11.5%
14,921,437
Compared to previous month
Last year
-6.3%
202,989,131
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
Dev Dependencies
4
rollup-plugin-terser
Rollup plugin to minify generated es bundle. Uses terser under the hood.
Install
1yarn add rollup-plugin-terser --dev 2# Or with npm: 3npm i rollup-plugin-terser --save-dev
Note: this package requires rollup@0.66 and higher (including rollup@2.0.0)
Usage
1import { rollup } from "rollup"; 2import { terser } from "rollup-plugin-terser"; 3 4rollup({ 5 input: "main.js", 6 plugins: [terser()], 7});
Why named export?
- Module is a namespace. Default export often leads to function/component per file dogma and makes code less maintainable.
- Interop with commonjs is broken in many cases or hard to maintain.
- Show me any good language with default exports. It's historical javascriptism.
Options
⚠️ Caveat: any function used in options object cannot rely on its surrounding scope, since it is executed in an isolated context.
1terser(options);
options
- terser API options
Note: some terser options are set by the plugin automatically:
module: true
is set whenformat
isesm
ores
toplevel: true
is set whenformat
iscjs
options.numWorkers: number
Amount of workers to spawn. Defaults to the number of CPUs minus 1.
Examples
Using as output plugin
1// rollup.config.js 2import { terser } from "rollup-plugin-terser"; 3 4export default { 5 input: "index.js", 6 output: [ 7 { file: "lib.js", format: "cjs" }, 8 { file: "lib.min.js", format: "cjs", plugins: [terser()] }, 9 { file: "lib.esm.js", format: "esm" }, 10 ], 11};
Comments
If you'd like to preserve comments (for licensing for example), then you can specify a function to do this like so:
1terser({ 2 output: { 3 comments: function (node, comment) { 4 var text = comment.value; 5 var type = comment.type; 6 if (type == "comment2") { 7 // multiline comment 8 return /@preserve|@license|@cc_on/i.test(text); 9 } 10 }, 11 }, 12});
Alternatively, you can also choose to keep all comments (e.g. if a licensing header has already been prepended by a previous rollup plugin):
1terser({ 2 output: { 3 comments: "all", 4 }, 5});
See Terser documentation for further reference.
License
MIT © Bogdan Chadkin
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 6/30 approved changesets -- score normalized to 2
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 6 are checked with a SAST tool
Reason
27 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More