rollup-plugin-uglify
Advanced tools
Comparing version 2.0.1 to 3.0.0
31
index.js
@@ -1,21 +0,22 @@ | ||
const minify = require('uglify-js').minify; | ||
const minify = require("uglify-es").minify; | ||
function uglify(userOptions, minifier) { | ||
if (minifier === undefined) { | ||
minifier = minify; | ||
if (minifier === undefined) { | ||
minifier = minify; | ||
} | ||
const options = Object.assign({ sourceMap: true }, userOptions); | ||
return { | ||
name: "uglify", | ||
transformBundle(code) { | ||
const result = minifier(code, options); | ||
if (result.error) { | ||
throw result.error; | ||
} | ||
return result; | ||
} | ||
const options = Object.assign({ sourceMap: true }, userOptions); | ||
return { | ||
name: 'uglify', | ||
transformBundle(code) { | ||
const result = minifier(code, options); | ||
if (result.error) { | ||
throw result.error; | ||
} | ||
return result; | ||
} | ||
}; | ||
}; | ||
} | ||
module.exports = uglify; |
{ | ||
"name": "rollup-plugin-uglify", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Rollup plugin to minify generated bundle", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "jest --coverage", | ||
"test": "jest", | ||
"prepublish": "yarn test" | ||
@@ -27,8 +27,9 @@ }, | ||
"dependencies": { | ||
"uglify-js": "^3.0.9" | ||
"uglify-es": "^3.3.7" | ||
}, | ||
"devDependencies": { | ||
"jest": "^20.0.3", | ||
"rollup": "^0.41.6" | ||
"jest": "^22.1.4", | ||
"prettier": "^1.10.2", | ||
"rollup": "^0.54.1" | ||
} | ||
} |
@@ -36,27 +36,4 @@ # rollup-plugin-uglify [![Travis Build Status][travis-img]][travis] | ||
`minifier` – default: `require('uglify-js').minify`, type: `function`. Module to use as a minifier. You can use other versions (or forks) of UglifyJS instead default one. | ||
`minifier` – default: `require('uglify-es').minify`, type: `function`. Module to use as a minifier. You can use other versions (or forks) of UglifyJS instead default one. | ||
## Warning | ||
[UglifyJS](https://github.com/mishoo/UglifyJS2), which this plugin is based on, does not support the ES2015 module syntax. Thus using this plugin with Rollup's default bundle format (`'es'`) will not work and error out. | ||
To work around this you can tell `rollup-plugin-uglify` to use the UglifyJS [unstable es version](https://github.com/mishoo/UglifyJS2) by passing its `minify` function to minify your code. | ||
```js | ||
import { rollup } from 'rollup'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { minify } from 'uglify-es'; | ||
rollup({ | ||
entry: 'main.js', | ||
plugins: [ | ||
uglify({}, minify) | ||
] | ||
}); | ||
``` | ||
To install the experimental version of UglifyJS: | ||
``` | ||
npm i uglify-es -D | ||
``` | ||
## Examples | ||
@@ -83,2 +60,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): | ||
```js | ||
uglify({ | ||
output: { | ||
comments: 'all' | ||
} | ||
}); | ||
``` | ||
See [UglifyJS documentation](https://github.com/mishoo/UglifyJS2#keeping-comments-in-the-output) for further reference. | ||
@@ -85,0 +72,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3870
3
74
+ Addeduglify-es@^3.3.7
+ Addedcommander@2.14.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addeduglify-es@3.3.10(transitive)
- Removeduglify-js@^3.0.9
- Removeduglify-js@3.19.3(transitive)