rollup-plugin-uglify
Advanced tools
Comparing version 5.0.2 to 6.0.0
47
index.js
const { codeFrameColumns } = require("@babel/code-frame"); | ||
const Worker = require("jest-worker").default; | ||
const serialize = require("serialize-javascript"); | ||
@@ -9,6 +10,9 @@ function uglify(userOptions = {}) { | ||
const options = Object.assign({}, userOptions, { | ||
sourceMap: userOptions.sourcemap !== false, | ||
sourcemap: undefined | ||
}); | ||
const minifierOptions = serialize( | ||
Object.assign({}, userOptions, { | ||
sourceMap: userOptions.sourcemap !== false, | ||
sourcemap: undefined, | ||
numWorkers: undefined | ||
}) | ||
); | ||
@@ -18,19 +22,24 @@ return { | ||
renderStart() { | ||
this.worker = new Worker(require.resolve("./transform.js"), { | ||
numWorkers: userOptions.numWorkers | ||
}); | ||
}, | ||
renderChunk(code) { | ||
const worker = new Worker(require.resolve("./transform.js")); | ||
return this.worker.transform(code, minifierOptions).catch(error => { | ||
const { message, line, col: column } = error; | ||
console.error( | ||
codeFrameColumns(code, { start: { line, column } }, { message }) | ||
); | ||
throw error; | ||
}); | ||
}, | ||
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; | ||
}); | ||
generateBundle() { | ||
this.worker.end(); | ||
}, | ||
renderError() { | ||
this.worker.end(); | ||
} | ||
@@ -37,0 +46,0 @@ }; |
{ | ||
"name": "rollup-plugin-uglify", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "Rollup plugin to minify generated bundle", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "jest --runInBand", | ||
"prepublish": "yarn test" | ||
@@ -30,16 +30,17 @@ }, | ||
"jest-worker": "^23.2.0", | ||
"uglify-js": "^3.4.8" | ||
"serialize-javascript": "^1.5.0", | ||
"uglify-js": "^3.4.9" | ||
}, | ||
"peerDependencies": { | ||
"rollup": ">=0.65.0 <1" | ||
"rollup": ">=0.66.0 <1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/core": "^7.0.1", | ||
"@babel/preset-env": "^7.0.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^23.4.2", | ||
"jest": "^23.5.0", | ||
"babel-jest": "^23.6.0", | ||
"jest": "^23.6.0", | ||
"prettier": "^1.14.2", | ||
"rollup": "^0.65.0" | ||
"rollup": "^0.66.0" | ||
} | ||
} |
@@ -39,4 +39,11 @@ # rollup-plugin-uglify [![Travis Build Status][travis-img]][travis] | ||
`options.sourcemap` – default: `true`, type: `boolean`. The only own option which is used to generate source maps and pass them to rollup. | ||
`options.sourcemap: boolean` | ||
Generates source maps and passes them to rollup. Defaults to `true`. | ||
`options.numWorkers: number` | ||
Amount of workers to spawn. Defaults to the number of CPUs minus 1. | ||
## Examples | ||
@@ -43,0 +50,0 @@ |
const { minify } = require("uglify-js"); | ||
const transform = (code, options) => { | ||
const transform = (code, optionsString) => { | ||
const options = eval(`(${optionsString})`) | ||
const result = minify(code, options); | ||
@@ -5,0 +6,0 @@ if (result.error) { |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
5533
50
83
5
1
+ Addedserialize-javascript@^1.5.0
+ Addedserialize-javascript@1.9.1(transitive)
Updateduglify-js@^3.4.9