Socket
Socket
Sign inDemoInstall

rollup-plugin-terser

Package Overview
Dependencies
31
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 2.0.0

38

index.js
const { codeFrameColumns } = require("@babel/code-frame");
const { minify } = require("terser");
const Worker = require("jest-worker").default;
function terser(userOptions) {
const options = Object.assign({ sourceMap: true }, userOptions);
function terser(userOptions = {}) {
if (userOptions.sourceMap != null) {
throw Error("sourceMap option is removed, use sourcemap instead");
}
const options = Object.assign({}, userOptions, {
sourceMap: userOptions.sourcemap !== false
});

@@ -10,12 +15,19 @@ return {

transformBundle(code) {
const result = minify(code, options);
if (result.error) {
const { message, line, col: column } = result.error;
console.error(
codeFrameColumns(code, { start: { line, column } }, { message })
);
throw result.error;
}
return result;
renderChunk(code) {
const worker = new Worker(require.resolve("./transform.js"));
return worker
.transform(code, options)
.then(result => {
worker.end();
return result;
})
.catch(error => {
worker.end();
const { message, line, col: column } = error;
console.error(
codeFrameColumns(code, { start: { line, column } }, { message })
);
throw error;
});
}

@@ -22,0 +34,0 @@ };

{
"name": "rollup-plugin-terser",
"version": "1.0.1",
"version": "2.0.0",
"description": "Rollup plugin to minify generated es bundle",

@@ -26,14 +26,18 @@ "main": "index.js",

"dependencies": {
"@babel/code-frame": "^7.0.0-beta.47",
"terser": "^3.7.5"
"@babel/code-frame": "^7.0.0",
"jest-worker": "^23.2.0",
"terser": "^3.8.2"
},
"peerDependencies": {
"rollup": ">=0.65.0 <1"
},
"devDependencies": {
"@babel/core": "^7.0.0-beta.47",
"@babel/preset-env": "^7.0.0-beta.47",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.3",
"jest": "^22.4.3",
"prettier": "^1.12.1",
"rollup": "^0.59.1"
"babel-jest": "^23.4.2",
"jest": "^23.5.0",
"prettier": "^1.14.2",
"rollup": "^0.65.0"
}
}

@@ -6,3 +6,3 @@ # rollup-plugin-terser [![Travis Build Status][travis-img]][travis]

[Rollup](https://github.com/rollup/rollup) plugin to minify generated es bundle.
[Rollup](https://github.com/rollup/rollup) plugin to minify generated es bundle. Uses [terser](https://github.com/fabiosantoscode/terser) under the hood.

@@ -33,4 +33,6 @@ ## Install

`options` – default: `{}`, type: `object`. [Terser API options](https://github.com/fabiosantoscode/terser#minify-options)
`options` - [terser API options](https://github.com/fabiosantoscode/terser#minify-options)
`options.sourcemap` - default: `true`, type: `boolean`. The only own option which is used to generate source maps and pass them to rollup.
## Examples

@@ -37,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc