From 1b693232d273745820f7b1f485832f9fe70995e7 Mon Sep 17 00:00:00 2001 From: kzc Date: Mon, 15 May 2017 12:10:44 -0400 Subject: [PATCH] Update README.md --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index a6eeb83a..711ec39b 100644 --- a/README.md +++ b/README.md @@ -755,6 +755,39 @@ var result = uglifyJS.minify(fs.readFileSync("input.js", "utf8"), { }); ``` +### Using native Uglify AST with `minify()` +``` +// example: parse only, produce native Uglify AST + +var result = UglifyJS.minify(code, { + parse: {}, + compress: false, + mangle: false, + output: { + ast: true, + code: false // optional - faster if false + } +}); + +// result.ast contains native Uglify AST +``` +``` +// example: accept native Uglify AST input and then compress and mangle +// to produce both code and native AST. + +var result = UglifyJS.minify(ast, { + compress: {}, + mangle: {}, + output: { + ast: true, + code: true // optional - faster if false + } +}); + +// result.ast contains native Uglify AST +// result.code contains the minified code in string form. +``` + ### ESTree / SpiderMonkey AST UglifyJS has its own abstract syntax tree format; for