12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #!/usr/bin/env node
- /*
- ES6-capable adaptive minifier
-
- Part of Zombie Navigator
- Copyright © 2016 Zombie Navigator Developers
- */
- !function () {
- 'use strict';
-
- Error.stackTraceLimit = Infinity;
-
- var esprima = require('esprima');
- var escodegen = require('escodegen');
- var UglifyJS = require('uglify-js');
-
- var code = '';
- process.stdin.on('data', function (data) {
- code += data;
- });
- process.stdin.on('end', function (err) {
- try {
- console.log(UglifyJS.minify(code, {
- mangle: {
- toplevel: true
- , screw_ie8: true
- }
- , fromString: true
- }).code);
- return;
- } catch (e) {
- //console.warn(e);
- }
-
-
- // UglifyJS failed, just remove spaces
-
- var tree = esprima.parse(code, {
-
- });
- //console.log('error:' + err);
- console.log(escodegen.generate(tree, {
- format: {
- json: false,
- renumber: false,
- hexadecimal: false,
- quotes: 'single',
- escapeless: false,
- compact: true,
- parentheses: true,
- semicolons: false,
- safeConcatenation: true
- },
- moz: {
- starlessGenerator: false,
- parenthesizedComprehensionBlock: false,
- comprehensionExpressionStartsWithAssignment: false
- },
- parse: null,
- comment: false
- }));
- });
- process.stdin.resume();
-
- }();
- // vim: set ts=4 noet ai ft=javascript
|