terser 5.0.0-beta.2 → 5.2.1

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.
package/lib/ast.js CHANGED
@@ -527,7 +527,7 @@ var AST_PrefixedTemplateString = DEFNODE("PrefixedTemplateString", "template_str
527
527
  $documentation: "A templatestring with a prefix, such as String.raw`foobarbaz`",
528
528
  $propdoc: {
529
529
  template_string: "[AST_TemplateString] The template string",
530
- prefix: "[AST_SymbolRef|AST_PropAccess] The prefix, which can be a symbol such as `foo` or a dotted expression such as `String.raw`."
530
+ prefix: "[AST_Node] The prefix, which will get called."
531
531
  },
532
532
  _walk: function(visitor) {
533
533
  return visitor._visit(this, function () {
@@ -864,6 +864,10 @@ var AST_Import = DEFNODE("Import", "imported_name imported_names module_name", {
864
864
  },
865
865
  });
866
866
 
867
+ var AST_ImportMeta = DEFNODE("ImportMeta", null, {
868
+ $documentation: "A reference to import.meta",
869
+ });
870
+
867
871
  var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name", {
868
872
  $documentation: "An `export` statement",
869
873
  $propdoc: {
@@ -904,11 +908,12 @@ var AST_Export = DEFNODE("Export", "exported_definition exported_value is_defaul
904
908
 
905
909
  /* -----[ OTHER ]----- */
906
910
 
907
- var AST_Call = DEFNODE("Call", "expression args _annotations", {
911
+ var AST_Call = DEFNODE("Call", "expression args optional _annotations", {
908
912
  $documentation: "A function call expression",
909
913
  $propdoc: {
910
914
  expression: "[AST_Node] expression to invoke as function",
911
915
  args: "[AST_Node*] array of arguments",
916
+ optional: "[boolean] whether this is an optional call (IE ?.() )",
912
917
  _annotations: "[number] bitfield containing information about the call"
913
918
  },
914
919
  initialize() {
@@ -952,11 +957,13 @@ var AST_Sequence = DEFNODE("Sequence", "expressions", {
952
957
  },
953
958
  });
954
959
 
955
- var AST_PropAccess = DEFNODE("PropAccess", "expression property", {
960
+ var AST_PropAccess = DEFNODE("PropAccess", "expression property optional", {
956
961
  $documentation: "Base class for property access expressions, i.e. `a.foo` or `a[\"foo\"]`",
957
962
  $propdoc: {
958
963
  expression: "[AST_Node] the “container” expression",
959
- property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node"
964
+ property: "[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node",
965
+
966
+ optional: "[boolean] whether this is an optional property access (IE ?.)"
960
967
  }
961
968
  });
962
969
 
@@ -989,6 +996,21 @@ var AST_Sub = DEFNODE("Sub", null, {
989
996
  },
990
997
  }, AST_PropAccess);
991
998
 
999
+ var AST_Chain = DEFNODE("Chain", "expression", {
1000
+ $documentation: "A chain expression like a?.b?.(c)?.[d]",
1001
+ $propdoc: {
1002
+ expression: "[AST_Call|AST_Dot|AST_Sub] chain element."
1003
+ },
1004
+ _walk: function (visitor) {
1005
+ return visitor._visit(this, function() {
1006
+ this.expression._walk(visitor);
1007
+ });
1008
+ },
1009
+ _children_backwards(push) {
1010
+ push(this.expression);
1011
+ },
1012
+ });
1013
+
992
1014
  var AST_Unary = DEFNODE("Unary", "operator expression", {
993
1015
  $documentation: "Base class for unary expressions",
994
1016
  $propdoc: {
@@ -1610,6 +1632,7 @@ export {
1610
1632
  AST_Call,
1611
1633
  AST_Case,
1612
1634
  AST_Catch,
1635
+ AST_Chain,
1613
1636
  AST_Class,
1614
1637
  AST_ClassExpression,
1615
1638
  AST_ClassProperty,
@@ -1642,6 +1665,7 @@ export {
1642
1665
  AST_Hole,
1643
1666
  AST_If,
1644
1667
  AST_Import,
1668
+ AST_ImportMeta,
1645
1669
  AST_Infinity,
1646
1670
  AST_IterationStatement,
1647
1671
  AST_Jump,
package/lib/cli.js CHANGED
@@ -84,6 +84,7 @@ export async function run_cli({ program, packageJson, fs, path }) {
84
84
  options[name] = program[name];
85
85
  }
86
86
  });
87
+
87
88
  if ("ecma" in program) {
88
89
  if (program.ecma != (program.ecma | 0)) fatal("ERROR: ecma must be an integer");
89
90
  const ecma = program.ecma | 0;
@@ -313,7 +314,7 @@ export async function run_cli({ program, packageJson, fs, path }) {
313
314
  }
314
315
  } else if (program.output) {
315
316
  fs.writeFileSync(program.output, result.code);
316
- if (options.sourceMap.url !== "inline" && result.map) {
317
+ if (options.sourceMap && options.sourceMap.url !== "inline" && result.map) {
317
318
  fs.writeFileSync(program.output + ".map", result.map);
318
319
  }
319
320
  } else {