'
diff --git a/html-minifier/html-minifier.d.ts b/html-minifier/html-minifier.d.ts
new file mode 100644
index 0000000000..9557de8902
--- /dev/null
+++ b/html-minifier/html-minifier.d.ts
@@ -0,0 +1,115 @@
+// Type definitions for HTMLMinifier v1.1.1
+// Project: https://github.com/kangax/html-minifier
+// Definitions by: Tanguy Krotoff
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+///
+
+declare module 'html-minifier' {
+ import * as UglifyJS from 'uglify-js';
+ import * as CleanCSS from 'clean-css';
+ import * as RelateUrl from 'relateurl';
+
+ namespace HTMLMinifier {
+ function minify(text: string, options?: Options): string;
+
+ interface Options {
+ // Strip HTML comments
+ removeComments?: boolean;
+
+ // Strip HTML comments from scripts and styles
+ removeCommentsFromCDATA?: boolean;
+
+ // Remove CDATA sections from script and style elements
+ removeCDATASectionsFromCDATA?: boolean;
+
+ // Collapse white space that contributes to text nodes in a document tree
+ collapseWhitespace?: boolean;
+
+ // Always collapse to 1 space (never remove it entirely). Must be used in conjunction with collapseWhitespace=true
+ conservativeCollapse?: boolean;
+
+ // Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace=true
+ collapseInlineTagWhitespace?: boolean;
+
+ // Always collapse to 1 line break (never remove it entirely) when whitespace between tags include a line break. Must be used in conjunction with collapseWhitespace=true
+ preserveLineBreaks?: boolean;
+
+ // Omit attribute values from boolean attributes
+ collapseBooleanAttributes?: boolean;
+
+ // Remove quotes around attributes when possible
+ removeAttributeQuotes?: boolean;
+
+ // Remove attributes when value matches default
+ removeRedundantAttributes?: boolean;
+
+ // Prevents the escaping of the values of attributes.
+ preventAttributesEscaping?: boolean;
+
+ // Replaces the doctype with the short (HTML5) doctype
+ useShortDoctype?: boolean;
+
+ // Remove all attributes with whitespace-only values
+ removeEmptyAttributes?: boolean;
+
+ // Remove type="text/javascript" from script tags. Other type attribute values are left intact.
+ removeScriptTypeAttributes?: boolean;
+
+ // Remove type="text/css" from style and link tags. Other type attribute values are left intact.
+ removeStyleLinkTypeAttributes?: boolean;
+
+ // Remove unrequired tags
+ removeOptionalTags?: boolean;
+
+ // Remove all elements with empty contents
+ removeEmptyElements?: boolean;
+
+ // Toggle linting
+ lint?: boolean;
+
+ // Keep the trailing slash on singleton elements
+ keepClosingSlash?: boolean;
+
+ // Treat attributes in case sensitive manner (useful for custom HTML tags.)
+ caseSensitive?: boolean;
+
+ // Minify Javascript in script elements and on* attributes (uses UglifyJS)
+ minifyJS?: boolean | UglifyJS.MinifyOptions;
+
+ // Minify CSS in style elements and style attributes (uses clean-css)
+ minifyCSS?: boolean | CleanCSS.Options;
+
+ // Minify URLs in various attributes (uses relateurl)
+ minifyURLs?: boolean | RelateUrl.Options;
+
+ // Array of regex'es that allow to ignore certain comments, when matched
+ ignoreCustomComments?: Array;
+
+ // Array of regex'es that allow to ignore certain fragments, when matched (e.g. , {{ ... }}, etc.)
+ ignoreCustomFragments?: Array;
+
+ // Array of strings corresponding to types of script elements to process through minifier (e.g. text/ng-template, text/x-handlebars-template, etc.)
+ processScripts?: Array;
+
+ // Specify a maximum line length. Compressed output will be split by newlines at valid HTML split-points
+ maxLineLength?: number;
+
+ // Arrays of regex'es that allow to support custom attribute assign expressions (e.g. '')
+ customAttrAssign?: Array;
+
+ // Arrays of regex'es that allow to support custom attribute surround expressions (e.g. )
+ customAttrSurround?: Array;
+
+ // Regex that specifies custom attribute to strip newlines from (e.g. /ng\-class/)
+ customAttrCollapse?: RegExp;
+
+ // Type of quote to use for attribute values (' or ")
+ quoteCharacter?: string;
+ }
+ }
+
+ export = HTMLMinifier;
+}
diff --git a/relateurl/relateurl-tests.ts b/relateurl/relateurl-tests.ts
new file mode 100644
index 0000000000..89a647d06e
--- /dev/null
+++ b/relateurl/relateurl-tests.ts
@@ -0,0 +1,20 @@
+///
+
+import * as RelateUrl from 'relateurl';
+
+var from = "http://www.domain.com/asdf/";
+var to = "http://www.domain.com/asdf/asdf";
+var to1 = "http://www.domain.com/asdf/asdf1";
+var to2 = "http://www.domain.com/asdf/asdf1";
+var to3 = "http://www.domain.com/asdf/asdf1";
+var options = {site: "http://www.domain.com/asdf2/"};
+var customOptions = {output: RelateUrl.ABSOLUTE};
+
+// Single Instance
+var result = RelateUrl.relate(from, to, options);
+
+// Reusable Instances
+var instance = new RelateUrl(from, options);
+var result1 = instance.relate(to1);
+var result2 = instance.relate(to2, customOptions);
+var result3 = instance.relate(to3);
diff --git a/relateurl/relateurl.d.ts b/relateurl/relateurl.d.ts
new file mode 100644
index 0000000000..9f24e59b9e
--- /dev/null
+++ b/relateurl/relateurl.d.ts
@@ -0,0 +1,125 @@
+// Type definitions for relateurl v0.2.6
+// Project: https://github.com/stevenvachon/relateurl
+// Definitions by: Tanguy Krotoff
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module 'relateurl' {
+ namespace RelateUrl {
+ interface Options {
+ /**
+ * Type: Object
+ * Default value: {ftp:21, http:80, https:443}
+ *
+ * Extend the list with any ports you need. Any URLs containing these default ports will have them removed. Example: http://example.com:80/ will become http://example.com/.
+ */
+ defaultPorts?: Object;
+
+ /**
+ * Type: Array
+ * Default value: ["index.html"]
+ *
+ * Extend the list with any resources you need. Works with options.removeDirectoryIndexes.
+ */
+ directoryIndexes?: Array;
+
+ /**
+ * Type: Boolean
+ * Default value: false
+ *
+ * This will, for example, consider any domains containing http://www.example.com/ to be related to any that contain http://example.com/.
+ */
+ ignore_www?: boolean;
+
+ /**
+ * Type: constant or String
+ * Choices: RelateUrl.ABSOLUTE,RelateUrl.PATH_RELATIVE,RelateUrl.ROOT_RELATIVE,RelateUrl.SHORTEST
+ * Choices: "absolute","pathRelative","rootRelative","shortest"
+ * Default value: RelateUrl.SHORTEST
+ *
+ * RelateUrl.ABSOLUTE will produce an absolute URL. Overrides options.schemeRelative with a value of false.
+ * RelateUrl.PATH_RELATIVE will produce something like ../child-of-parent/etc/.
+ * RelateUrl.ROOT_RELATIVE will produce something like /child-of-root/etc/.
+ * RelateUrl.SHORTEST will choose whichever is shortest between root- and path-relative.
+ */
+ output?: string;
+
+ /**
+ * Type: Array
+ * Default value: ["data","javascript","mailto"]
+ *
+ * Extend the list with any additional schemes. Example: javascript:something will not be modified.
+ */
+ rejectedSchemes?: Array;
+
+ /**
+ * Type: Boolean
+ * Default value: false
+ *
+ * Remove user authentication information from the output URL.
+ */
+ removeAuth?: boolean;
+
+ /**
+ * Type: Boolean
+ * Default value: true
+ *
+ * Remove any resources that match any found in options.directoryIndexes.
+ */
+ removeDirectoryIndexes?: boolean;
+
+ /**
+ * Type: Boolean
+ * Default value: false
+ *
+ * Remove empty query variables. Example: http://domain.com/?var1&var2=&var3=asdf will become http://domain.com/?var3=adsf. This does not apply to unrelated URLs (with other protocols, auths, hosts and/or ports).
+ */
+ removeEmptyQueries?: boolean;
+
+ /**
+ * Type: Boolean
+ * Default value: true
+ *
+ * Remove trailing slashes from root paths. Example: http://domain.com/?var will become http://domain.com?var while http://domain.com/dir/?var will not be modified.
+ */
+ removeRootTrailingSlash?: boolean;
+
+ /**
+ * Type: Boolean
+ * Default value: true
+ *
+ * Output URLs relative to the scheme. Example: http://example.com/ will become //example.com/.
+ */
+ schemeRelative?: boolean;
+
+ /**
+ * Type: String
+ * Default value: undefined
+ *
+ * An options-based version of the from argument. If both are specified, from takes priority.
+ */
+ site?: string;
+
+ /**
+ * Type: Boolean
+ * Default value: true
+ *
+ * Passed to Node's url.parse.
+ */
+ slashesDenoteHost?: boolean;
+ }
+ }
+
+ class RelateUrl {
+ static ABSOLUTE: string;
+ static PATH_RELATIVE: string;
+ static ROOT_RELATIVE: string;
+ static SHORTEST: string;
+
+ static relate(from: string, to: string, options?: RelateUrl.Options): string;
+
+ constructor(from: string, options?: RelateUrl.Options);
+ relate(to: string, options?: RelateUrl.Options): string;
+ }
+
+ export = RelateUrl;
+}
diff --git a/uglify-js/uglify-js-tests.ts b/uglify-js/uglify-js-tests.ts
new file mode 100644
index 0000000000..23b935dec2
--- /dev/null
+++ b/uglify-js/uglify-js-tests.ts
@@ -0,0 +1,73 @@
+///
+///
+
+import * as UglifyJS from 'uglify-js';
+import * as fs from 'fs';
+
+var result = UglifyJS.minify("/path/to/file.js");
+console.log(result.code); // minified output
+// if you need to pass code instead of file name
+var result = UglifyJS.minify("var b = function () {};", {fromString: true});
+
+var result = UglifyJS.minify([ "file1.js", "file2.js", "file3.js" ]);
+console.log(result.code);
+
+var result = UglifyJS.minify([ "file1.js", "file2.js", "file3.js" ], {
+ outSourceMap: "out.js.map"
+});
+console.log(result.code); // minified output
+console.log(result.map);
+
+var result = UglifyJS.minify([ "file1.js", "file2.js", "file3.js" ], {
+ outSourceMap: "out.js.map",
+ sourceRoot: "http://example.com/src"
+});
+
+var result = UglifyJS.minify("compiled.js", {
+ inSourceMap: "compiled.js.map",
+ outSourceMap: "minified.js.map"
+});
+// same as before, it returns `code` and `map`
+
+const my_source_map_string = 'sourceMap';
+var result = UglifyJS.minify("compiled.js", {
+ inSourceMap: JSON.parse(my_source_map_string),
+ outSourceMap: "minified.js.map"
+});
+
+var toplevel_ast = UglifyJS.parse(code, {});
+
+var toplevel: UglifyJS.AST_Toplevel = null;
+const files = ['file1', 'file2'];
+files.forEach(function(file){
+ var code = fs.readFileSync(file, "utf8");
+ toplevel = UglifyJS.parse(code, {
+ filename: file,
+ toplevel: toplevel
+ });
+});
+
+toplevel.figure_out_scope()
+
+var compressor = UglifyJS.Compressor({});
+var compressed_ast = toplevel.transform(compressor);
+
+compressed_ast.figure_out_scope();
+compressed_ast.compute_char_frequency();
+compressed_ast.mangle_names();
+
+var stream = UglifyJS.OutputStream({});
+compressed_ast.print(stream);
+var code = stream.toString(); // this is your minified code
+
+var code = compressed_ast.print_to_string({});
+
+var source_map = UglifyJS.SourceMap({});
+var stream = UglifyJS.OutputStream({
+ //...
+ source_map: source_map
+});
+compressed_ast.print(stream);
+
+var code = stream.toString();
+var map = source_map.toString(); // json output for your source map
diff --git a/uglify-js/uglify-js.d.ts b/uglify-js/uglify-js.d.ts
new file mode 100644
index 0000000000..b9c22bc6ed
--- /dev/null
+++ b/uglify-js/uglify-js.d.ts
@@ -0,0 +1,430 @@
+// Type definitions for UglifyJS 2 v2.6.1
+// Project: https://github.com/mishoo/UglifyJS2
+// Definitions by: Tanguy Krotoff
+// Definitions: https://github.com/borisyankov/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;
+}
diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts
index 5bf5050b82..be4c22328e 100644
--- a/webpack/webpack.d.ts
+++ b/webpack/webpack.d.ts
@@ -3,7 +3,11 @@
// Definitions by: Qubo
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
declare module "webpack" {
+ import * as UglifyJS from 'uglify-js';
+
namespace webpack {
interface Configuration {
context?: string;
@@ -426,7 +430,7 @@ declare module "webpack" {
new(preferEntry: boolean): Plugin;
}
interface UglifyJsPluginStatic {
- new(options?: any): Plugin;
+ new(options?: UglifyJS.MinifyOptions): Plugin;
}
interface CommonsChunkPluginStatic {
new(chunkName: string, filenames?: string|string[]): Plugin;