.version('0.1.0', '-v, --version')
.option('-s, --signature <str>', 'function signature for --wrap', 'async (_require, _pathname, _root)')
.option('-b, --bare-returns', 'allow return in top level code', false)
- .option('-o, --output <astring|uglify>', 'use astring or UglifyJS for output', 'astring')
- .option('-i, --indent <n>', 'indent per level (astring only)', '2')
+ .option('-o, --output <ast|astring|uglify>', 'output AST, or via astring/UglifyJS', 'astring')
+ .option('-i, --indent <n>', 'indent per level (ast/astring only)', '2')
.option('-j, --initial-indent <n>', 'initial indent (astring only)', '0')
.option('-c, --compress', 'compress the logic (UglifyJS only)', true)
.option('-m, --mangle', 'mangle symbol names (UglifyJS only)', true)
{
bare_returns: commander.bareReturns,
output: commander.output,
+ ast_options: {
+ indent: parseInt(commander.indent)
+ },
astring_options: {
indent: ' '.repeat(parseInt(commander.indent)),
startingIndentLevel: parseInt(commander.initialIndent)
bare_returns: true,
ecma_version: 'latest', // or 11, 12, 13, etc
output: 'astring',
+ ast_options: {indent: 2},
astring_options: {indent: ' ', startingIndentLevel: 0},
uglify_options: {compress: true, mangle: true}
},
}
)
)
+ if (options.output === 'ast')
+ return JSON.stringify(ast, null, options.ast_options.indent)
if (options.output === 'astring')
return astring.generate(ast, options.astring_options)
let render = uglify_js.minify(