From: Alex Lam S.L Date: Sat, 15 Apr 2017 20:04:28 +0000 (+0800) Subject: update README (#1813) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=251ff1d1af3209af99d37007691acd5a3b771cfb;p=UglifyJS.git update README (#1813) - mention major version bump - remove reference to internal API --- diff --git a/README.md b/README.md index 42d2e87d..672c2f3b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ -UglifyJS 2 -========== +UglifyJS +======== [![Build Status](https://travis-ci.org/mishoo/UglifyJS2.svg)](https://travis-ci.org/mishoo/UglifyJS2) UglifyJS is a JavaScript parser, minifier, compressor or beautifier toolkit. #### Note: +- `uglify-js 3.x` is incompatible with the [`2.x` branch](https://github.com/mishoo/UglifyJS2/tree/v2.x). - release versions of `uglify-js` only support ECMAScript 5 (ES5). If you wish to minify ES2015+ (ES6+) code then please use the [harmony](#harmony) development branch. - Node 7 has a known performance regression and runs `uglify-js` twice as slow. @@ -34,7 +35,7 @@ Usage uglifyjs [input files] [options] -UglifyJS2 can take multiple input files. It's recommended that you pass the +UglifyJS can take multiple input files. It's recommended that you pass the input files first, then pass the options. UglifyJS will parse input files in sequence and apply any compression options. The files are parsed in the same global scope, that is, a reference from a file to some @@ -117,7 +118,7 @@ The available options are: --keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name. --name-cache File to hold mangled name mappings. - --self Build UglifyJS2 as a library (implies --wrap UglifyJS) + --self Build UglifyJS as a library (implies --wrap UglifyJS) --source-map [options] Enable source map/specify source map options: `base` Path to compute relative paths from input files. `content` Input source map, useful if you're compressing @@ -148,7 +149,7 @@ goes to STDOUT. ## Source map options -UglifyJS2 can generate a source map file, which is highly useful for +UglifyJS can generate a source map file, which is highly useful for debugging your compressed JavaScript. To get a source map, pass `--source-map --output output.js` (source map will be written out to `output.js.map`). @@ -554,7 +555,7 @@ needs to be kept in the output) are comments attached to toplevel nodes. ## Support for the SpiderMonkey AST -UglifyJS2 has its own abstract syntax tree format; for +UglifyJS has its own abstract syntax tree format; for [practical reasons](http://lisperator.net/blog/uglifyjs-why-not-switching-to-spidermonkey-ast/) we can't easily change to using the SpiderMonkey AST internally. However, UglifyJS now has a converter which can import a SpiderMonkey AST. @@ -580,38 +581,6 @@ Acorn is really fast (e.g. 250ms instead of 380ms on some 650K code), but converting the SpiderMonkey tree that Acorn produces takes another 150ms so in total it's a bit more than just using UglifyJS's own parser. -### Using UglifyJS to transform SpiderMonkey AST - -Now you can use UglifyJS as any other intermediate tool for transforming -JavaScript ASTs in SpiderMonkey format. - -Example: - -```javascript -function uglify(ast, options, mangle) { - // Conversion from SpiderMonkey AST to internal format - var uAST = UglifyJS.AST_Node.from_mozilla_ast(ast); - - // Compression - uAST.figure_out_scope(); - uAST = UglifyJS.Compressor(options).compress(uAST); - - // Mangling (optional) - if (mangle) { - uAST.figure_out_scope(); - uAST.compute_char_frequency(); - uAST.mangle_names(); - } - - // Back-conversion to SpiderMonkey AST - return uAST.to_mozilla_ast(); -} -``` - -Check out -[original blog post](http://rreverser.com/using-mozilla-ast-with-uglifyjs/) -for details. - API Reference ------------- diff --git a/bin/uglifyjs b/bin/uglifyjs index 96eef27e..f31529b0 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -36,7 +36,7 @@ program.option("-d, --define [=value]", "Global definitions.", parse_js("d program.option("--ie8", "Support non-standard Internet Explorer 8."); program.option("--keep-fnames", "Do not mangle/drop function names. Useful for code relying on Function.prototype.name."); program.option("--name-cache ", "File to hold mangled name mappings."); -program.option("--self", "Build UglifyJS2 as a library (implies --wrap UglifyJS)"); +program.option("--self", "Build UglifyJS as a library (implies --wrap UglifyJS)"); program.option("--source-map [options]", "Enable source map/specify source map options.", parse_source_map()); program.option("--stats", "Display operations run time on STDERR.") program.option("--toplevel", "Compress and/or mangle variables in toplevel scope.");