diff --git a/build/lib/optimize.js b/build/lib/optimize.js index 1957b6dde3c21b11b9dc4a798c0bf56510642439..390538190a4b7ce096408e54eb23cc405a1494e2 100644 --- a/build/lib/optimize.js +++ b/build/lib/optimize.js @@ -10,6 +10,8 @@ var sourcemaps = require("gulp-sourcemaps"); var filter = require("gulp-filter"); var minifyCSS = require("gulp-cssnano"); var uglify = require("gulp-uglify"); +var composer = require("gulp-uglify/composer"); +var uglifyes = require("uglify-es"); var es = require("event-stream"); var concat = require("gulp-concat"); var VinylFile = require("vinyl"); @@ -201,12 +203,13 @@ function uglifyWithCopyrights() { return false; }; }; + var minify = composer(uglifyes); var input = es.through(); var output = input .pipe(flatmap(function (stream, f) { - return stream.pipe(uglify({ - preserveComments: preserveComments(f), + return stream.pipe(minify({ output: { + comments: preserveComments(f), // linux tfs build agent is crashing, does this help?§ max_line_len: 3200000 } diff --git a/build/lib/optimize.ts b/build/lib/optimize.ts index 2fb92c5ecdf62c8d759242ef43c68a7126594a6f..083ed0e5860fad797f6f6fead52f3e9e2f3c66b5 100644 --- a/build/lib/optimize.ts +++ b/build/lib/optimize.ts @@ -11,6 +11,8 @@ import * as sourcemaps from 'gulp-sourcemaps'; import * as filter from 'gulp-filter'; import * as minifyCSS from 'gulp-cssnano'; import * as uglify from 'gulp-uglify'; +import * as composer from 'gulp-uglify/composer'; +import * as uglifyes from 'uglify-es'; import * as es from 'event-stream'; import * as concat from 'gulp-concat'; import * as VinylFile from 'vinyl'; @@ -276,12 +278,13 @@ function uglifyWithCopyrights(): NodeJS.ReadWriteStream { }; }; + const minify = composer(uglifyes); const input = es.through(); const output = input .pipe(flatmap((stream, f) => { - return stream.pipe(uglify({ - preserveComments: preserveComments(f), + return stream.pipe(minify({ output: { + comments: preserveComments(f), // linux tfs build agent is crashing, does this help?§ max_line_len: 3200000 } diff --git a/build/lib/typings/gulp-uglify.d.ts b/build/lib/typings/gulp-uglify.d.ts deleted file mode 100644 index 2e5f41e80be6851b209e31542c0352d2baa9281d..0000000000000000000000000000000000000000 --- a/build/lib/typings/gulp-uglify.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Type definitions for gulp-uglify -// Project: https://github.com/terinjokes/gulp-uglify -// Definitions by: Christopher Haws -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module "gulp-uglify" { - import * as UglifyJS from 'uglify-js'; - - namespace GulpUglify { - interface Options { - /** - * Pass false to skip mangling names. - */ - mangle?: boolean; - - /** - * Pass if you wish to specify additional output options. The defaults are optimized for best compression. - */ - output?: UglifyJS.BeautifierOptions; - - /** - * Pass an object to specify custom compressor options. Pass false to skip compression completely. - */ - compress?: UglifyJS.CompressorOptions | boolean; - - /** - * A convenience option for options.output.comments. Defaults to preserving no comments. - * all - Preserve all comments in code blocks - * some - Preserve comments that start with a bang (!) or include a Closure Compiler directive (@preserve, @license, @cc_on) - * function - Specify your own comment preservation function. You will be passed the current node and the current comment and are expected to return either true or false. - */ - preserveComments?: string | ((node: any, comment: UglifyJS.Tokenizer) => boolean); - - warnings?: boolean; - } - - class GulpUglifyError { - cause: { - filename: string; - }; - } - } - - function GulpUglify(options?: GulpUglify.Options): NodeJS.ReadWriteStream; - - export = GulpUglify; -} \ No newline at end of file diff --git a/build/lib/typings/uglify-js.d.ts b/build/lib/typings/uglify-js.d.ts deleted file mode 100644 index 9ee5da6a4fdcdb840e8958e12f3c60f897ada925..0000000000000000000000000000000000000000 --- a/build/lib/typings/uglify-js.d.ts +++ /dev/null @@ -1,428 +0,0 @@ -// Type definitions for UglifyJS 2 v2.6.1 -// Project: https://github.com/mishoo/UglifyJS2 -// Definitions by: Tanguy Krotoff -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module 'uglify-js' { - import * as MOZ_SourceMap from 'source-map'; - - namespace UglifyJS { - interface Tokenizer { - /** - * The type of this token. - * Can be "num", "string", "regexp", "operator", "punc", "atom", "name", "keyword", "comment1" or "comment2". - * "comment1" and "comment2" are for single-line, respectively multi-line comments. - */ - type: string; - - /** - * The name of the file where this token originated from. Useful when compressing multiple files at once to generate the proper source map. - */ - file: string; - - /** - * The "value" of the token. - * That's additional information and depends on the token type: "num", "string" and "regexp" tokens you get their literal value. - * - For "operator" you get the operator. - * - For "punc" it's the punctuation sign (parens, comma, semicolon etc). - * - For "atom", "name" and "keyword" it's the name of the identifier - * - For comments it's the body of the comment (excluding the initial "//" and "/*". - */ - value: string; - - /** - * The line number of this token in the original code. - * 1-based index. - */ - line: number; - - /** - * The column number of this token in the original code. - * 0-based index. - */ - col: number; - - /** - * Short for "newline before", it's a boolean that tells us whether there was a newline before this node in the original source. It helps for automatic semicolon insertion. - * For multi-line comments in particular this will be set to true if there either was a newline before this comment, or * * if this comment contains a newline. - */ - nlb: boolean; - - /** - * This doesn't apply for comment tokens, but for all other token types it will be an array of comment tokens that were found before. - */ - comments_before: string[]; - } - - interface AST_Node { - // The first token of this node - start: AST_Node; - - // The last token of this node - end: AST_Node; - - transform(tt: TreeTransformer): AST_Toplevel; - } - - interface AST_Toplevel extends AST_Node { - // UglifyJS contains a scope analyzer which figures out variable/function definitions, references etc. - // You need to call it manually before compression or mangling. - // The figure_out_scope method is defined only on the AST_Toplevel node. - figure_out_scope(): void; - - // Get names that are optimized for GZip compression (names will be generated using the most frequent characters first) - compute_char_frequency(): void; - - mangle_names(): void; - - print(stream: OutputStream): void; - - print_to_string(options?: BeautifierOptions): string; - } - - interface MinifyOptions { - spidermonkey?: boolean; - outSourceMap?: string; - sourceRoot?: string; - inSourceMap?: string; - fromString?: boolean; - warnings?: boolean; - mangle?: Object; - output?: MinifyOutput, - compress?: Object; - } - - interface MinifyOutput { - code: string; - map: string; - } - - function minify(files: string | Array, options?: MinifyOptions): MinifyOutput; - - - interface ParseOptions { - // Default is false - strict?: boolean; - - // Input file name, default is null - filename?: string; - - // Default is null - toplevel?: AST_Toplevel; - } - - /** - * The parser creates a custom abstract syntax tree given a piece of JavaScript code. - * Perhaps you should read about the AST first. - */ - function parse(code: string, options?: ParseOptions): AST_Toplevel; - - - interface BeautifierOptions { - /** - * Start indentation on every line (only when `beautify`) - */ - indent_start?: number; - - /** - * Indentation level (only when `beautify`) - */ - indent_level?: number; - - /** - * Quote all keys in object literals? - */ - quote_keys?: boolean; - - /** - * Add a space after colon signs? - */ - space_colon?: boolean; - - /** - * Output ASCII-safe? (encodes Unicode characters as ASCII) - */ - ascii_only?: boolean; - - /** - * Escape " boolean; - - /** - * UglifyJS provides a TreeWalker object and every node has a walk method that given a walker will apply your visitor to each node in the tree. - * Your visitor can return a non-falsy value in order to prevent descending the current node. - */ - function TreeWalker(visitor: visitor): TreeWalker; - - - // TODO - interface TreeTransformer extends TreeWalker { - } - - /** - * The tree transformer is a special case of a tree walker. - * In fact it even inherits from TreeWalker and you can use the same methods, but initialization and visitor protocol are a bit different. - */ - function TreeTransformer(before: visitor, after: visitor): TreeTransformer; - } - - export = UglifyJS; -} \ No newline at end of file diff --git a/package.json b/package.json index 8c27b13e178e2e7241e371a0b28685ac309afc11..54f22b9c92f8366cbd2b15b84cd5a2f27648c06a 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "gulp-sourcemaps": "^1.11.0", "gulp-tsb": "^2.0.3", "gulp-tslint": "^7.0.1", - "gulp-uglify": "^2.0.0", + "gulp-uglify": "^3.0.0", "gulp-util": "^3.0.6", "gulp-vinyl-zip": "^1.2.2", "husky": "^0.13.1", @@ -107,7 +107,7 @@ "tslint": "^4.3.1", "typescript": "2.3.3", "typescript-formatter": "4.0.1", - "uglify-js": "2.4.8", + "uglify-es": "^3.0.18", "underscore": "^1.8.2", "vinyl": "^0.4.5", "vinyl-fs": "^2.4.3",