From 324587f76980114e030c59165a60bd285ca05be0 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Mon, 26 Apr 2021 04:23:52 +0800 Subject: upgrade AST<->ESTree translation (#4870) fixes #968 --- bin/uglifyjs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'bin/uglifyjs') diff --git a/bin/uglifyjs b/bin/uglifyjs index 682c6a5a..325dacdd 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -235,7 +235,7 @@ if (options.mangle && options.mangle.properties) { }); } } -if (output == "ast") options.output = { +if (output == "ast" || output == "spidermonkey") options.output = { ast: true, code: false, }; @@ -313,9 +313,11 @@ function run() { if (options.parse.acorn) { files = convert_ast(function(toplevel, name) { return require("acorn").parse(files[name], { + ecmaVersion: "latest", locations: true, program: toplevel, - sourceFile: name + sourceFile: name, + sourceType: "module", }); }); } else if (options.parse.spidermonkey) { @@ -409,14 +411,7 @@ function run() { return value; }, 2)); } else if (output == "spidermonkey") { - print(JSON.stringify(UglifyJS.minify(result.code, { - compress: false, - mangle: false, - output: { - ast: true, - code: false - }, - }).ast.to_mozilla_ast(), null, 2)); + print(JSON.stringify(result.ast.to_mozilla_ast(), null, 2)); } else if (output) { fs.writeFileSync(output, result.code); if (result.map) fs.writeFileSync(output + ".map", result.map); -- cgit v1.2.3