From f451a7ad79165dda0d3f7fa7a56b3841eeba8174 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 7 Aug 2022 20:42:18 +0100 Subject: [PATCH] implement `--expression` (#5607) --- README.md | 8 ++--- bin/uglifyjs | 2 ++ lib/compress.js | 29 ++++++++++++++++ lib/minify.js | 20 +++++------ test/compress.js | 66 ++++++++++++++++++++++++------------ test/compress/directives.js | 23 ++++++++++--- test/compress/issue-281.js | 8 +++-- test/compress/issue-640.js | 10 ++++-- test/mocha/cli.js | 21 ++++++++++-- test/mocha/number-literal.js | 6 ++-- 10 files changed, 143 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 03ac0314..265a43c5 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,6 @@ a double dash to prevent input files being used as option arguments: modules and Userscripts that may be anonymous function wrapped (IIFE) by the .user.js engine `caller`. - `expression` Parse a single expression, rather than - a program (for parsing JSON). `spidermonkey` Assume input files are SpiderMonkey AST format (as JSON). -c, --compress [options] Enable compressor/specify compressor options: @@ -111,6 +109,8 @@ a double dash to prevent input files being used as option arguments: -d, --define [=value] Global definitions. -e, --enclose [arg[:value]] Embed everything in a big function, with configurable argument(s) & value(s). + --expression Parse a single expression, rather than a program + (for parsing JSON). --ie Support non-standard Internet Explorer. Equivalent to setting `ie: true` in `minify()` for `compress`, `mangle` and `output` options. @@ -504,6 +504,8 @@ if (result.error) throw result.error; - `compress` (default: `{}`) — pass `false` to skip compressing entirely. Pass an object to specify custom [compress options](#compress-options). +- `expression` (default: `false`) — parse as a single expression, e.g. JSON. + - `ie` (default: `false`) — enable workarounds for Internet Explorer bugs. - `keep_fargs` (default: `false`) — pass `true` to prevent discarding or mangling @@ -633,8 +635,6 @@ to be `false` and all symbol names will be omitted. - `bare_returns` (default: `false`) — support top level `return` statements -- `expression` (default: `false`) — parse as a single expression, e.g. JSON - - `html5_comments` (default: `true`) — process HTML comment as workaround for browsers which do not recognise `