diff options
author | kzc <kzc@users.noreply.github.com> | 2017-05-19 22:49:35 -0400 |
---|---|---|
committer | Alex Lam S.L <alexlamsl@gmail.com> | 2017-05-20 10:49:35 +0800 |
commit | 5bf8d7e9490155ed6fabea5f1140a87a1e9b596e (patch) | |
tree | cafd406f4e389117855cff2edf43faf6998c3e08 | |
parent | 1df9d06f4a6b9116216d8420f5b2ec67f576a301 (diff) | |
download | tracifyjs-5bf8d7e9490155ed6fabea5f1140a87a1e9b596e.tar.gz tracifyjs-5bf8d7e9490155ed6fabea5f1140a87a1e9b596e.zip |
document 3.x minify() does not throw errors (#1975)
-rw-r--r-- | README.md | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -307,7 +307,7 @@ Example: ```javascript var result = UglifyJS.minify("var b = function() {};"); console.log(result.code); // minified output -console.log(result.error); // runtime error +console.log(result.error); // runtime error, if present ``` You can also compress multiple files: @@ -335,6 +335,12 @@ var result = UglifyJS.minify({"foo.js" : "if (0) else console.log(1);"}); console.log(JSON.stringify(result.error)); // {"message":"Unexpected token: keyword (else)","filename":"foo.js","line":1,"col":7,"pos":7} ``` +Note: unlike `uglify-js@2.x`, the `3.x` API does not throw errors. To +achieve a similar effect one could do the following: +```javascript +var result = UglifyJS.minify("if (0) else console.log(1);"); +if (result.error) throw result.error; +``` ## Minify options |