terser 3.17.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of terser might be problematic. Click here for more details.

package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://github.com/fabiosantoscode/terser",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "3.17.0",
7
+ "version": "4.0.0",
8
8
  "engines": {
9
9
  "node": ">=6.0.0"
10
10
  },
@@ -33,7 +33,6 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "acorn": "^6.0.4",
36
- "cross-env": "^5.2.0",
37
36
  "csv": "^5.1.0",
38
37
  "escodegen": "^1.11.0",
39
38
  "eslint": "^4.19.1",
@@ -46,10 +45,12 @@
46
45
  "semver": "~5.6.0"
47
46
  },
48
47
  "scripts": {
49
- "test": "npm run prepare --silent && istanbul instrument dist/bundle.min.js > dist/bundle.instrumented.js && node test/run-tests.js",
48
+ "test": "npm run build -- --silent --input=main.tests.js && npm run minify && node test/run-tests.js",
50
49
  "lint": "eslint lib",
51
50
  "lint-fix": "eslint --fix lib",
52
- "prepare": "rimraf dist/* && rollup -c && cd dist && cross-env TERSER_NO_BUNDLE=1 ../bin/uglifyjs bundle.js -mc --source-map 'content=bundle.js.map,includeSources=true,url=bundle.min.js.map' -o bundle.min.js",
51
+ "build": "rimraf dist/* && rollup -c",
52
+ "minify": "cd dist && node ../bin/uglifyjsnobundle bundle.js -mc --source-map content=bundle.js.map,includeSources=true -o bundle.min.js",
53
+ "prepare": "npm run build && npm run minify",
53
54
  "postversion": "echo 'Remember to update the changelog!'"
54
55
  },
55
56
  "keywords": [
package/tools/node.js CHANGED
@@ -1,22 +1,19 @@
1
- var fs = require("fs");
1
+ import { minify } from "../lib/minify";
2
2
 
3
- var bundle_path = __dirname + "/../dist/bundle.js";
4
- var UglifyJS = require(bundle_path);
5
- module.exports = UglifyJS;
3
+ export function default_options() {
4
+ const defs = {};
6
5
 
7
- function infer_options(options) {
8
- var result = UglifyJS.minify("", options);
9
- return result.error && result.error.defs;
10
- }
6
+ Object.keys(infer_options({ 0: 0 })).forEach((component) => {
7
+ const options = infer_options({
8
+ [component]: {0: 0}
9
+ });
11
10
 
12
- UglifyJS.default_options = function() {
13
- var defs = {};
14
- Object.keys(infer_options({ 0: 0 })).forEach(function(component) {
15
- var options = {};
16
- options[component] = { 0: 0 };
17
- if (options = infer_options(options)) {
18
- defs[component] = options;
19
- }
11
+ if (options) defs[component] = options;
20
12
  });
21
13
  return defs;
22
- };
14
+ }
15
+
16
+ function infer_options(options) {
17
+ var result = minify("", options);
18
+ return result.error && result.error.defs;
19
+ }
package/tools/terser.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /// <reference lib="es2015" />
2
+
1
3
  import { RawSourceMap } from 'source-map';
2
4
 
3
5
  export type ECMA = 5 | 6 | 7 | 8 | 9;
@@ -15,12 +17,14 @@ export interface CompressOptions {
15
17
  booleans?: boolean;
16
18
  collapse_vars?: boolean;
17
19
  comparisons?: boolean;
20
+ computed_props?: boolean;
18
21
  conditionals?: boolean;
19
22
  dead_code?: boolean;
20
23
  defaults?: boolean;
21
24
  directives?: boolean;
22
25
  drop_console?: boolean;
23
26
  drop_debugger?: boolean;
27
+ ecma?: ECMA;
24
28
  evaluate?: boolean;
25
29
  expression?: boolean;
26
30
  global_defs?: object;
@@ -35,6 +39,7 @@ export interface CompressOptions {
35
39
  keep_fnames?: boolean | RegExp;
36
40
  keep_infinity?: boolean;
37
41
  loops?: boolean;
42
+ module?: boolean;
38
43
  negate_iife?: boolean;
39
44
  passes?: number;
40
45
  properties?: boolean;
@@ -83,7 +88,7 @@ export interface ManglePropertiesOptions {
83
88
  builtins?: boolean;
84
89
  debug?: boolean;
85
90
  keep_quoted?: boolean;
86
- regex?: RegExp;
91
+ regex?: RegExp | string;
87
92
  reserved?: string[];
88
93
  }
89
94
 
@@ -179,21 +184,6 @@ export class TreeTransformer extends TreeWalker {
179
184
 
180
185
  export function push_uniq<T>(array: T[], el: T): void;
181
186
 
182
- type DictEachCallback = (val: any, key: string) => any;
183
-
184
- export class Dictionary {
185
- static fromObject(obj: object): Dictionary;
186
- add(key: string, val: any): this;
187
- clone(): Dictionary;
188
- del(key: string): this;
189
- each(fn: DictEachCallback): void;
190
- get(key: string): any;
191
- has(key: string): boolean;
192
- map(fn: DictEachCallback): any[];
193
- set(key: string, val: any): this;
194
- size(): number;
195
- }
196
-
197
187
  export function minify(files: string | string[] | { [file: string]: string } | AST_Node, options?: MinifyOptions): MinifyOutput;
198
188
 
199
189
  export class AST_Node {