terser 5.0.0 → 5.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.1.0
4
+
5
+ - `import.meta` is now supported
6
+ - Typescript typings have been improved
7
+
3
8
  ## v5.0.0
4
9
 
5
10
  - `in` operator now taken into account during property mangle.
@@ -12,6 +17,7 @@
12
17
  - BREAKING: `minify()` is now async and rejects a promise instead of returning an error.
13
18
  - BREAKING: Internal AST is no longer exposed, so that it can be improved without releasing breaking changes.
14
19
  - BREAKING: Lowest supported node version is 10
20
+ - BREAKING: There are no more warnings being emitted
15
21
  - Module is now distributed as a dual package - You can `import` and `require()` too.
16
22
  - Inline improvements were made
17
23
 
@@ -1338,7 +1338,7 @@ function parse($TEXT, options) {
1338
1338
  }
1339
1339
  return function_(AST_Defun, false, true, is_export_default);
1340
1340
  }
1341
- if (S.token.value == "import" && !is_token(peek(), "punc", "(")) {
1341
+ if (S.token.value == "import" && !is_token(peek(), "punc", "(") && !is_token(peek(), "punc", ".")) {
1342
1342
  next();
1343
1343
  var node = import_();
1344
1344
  semicolon();
@@ -2386,6 +2386,9 @@ function parse($TEXT, options) {
2386
2386
  if (is("operator", "new")) {
2387
2387
  return new_(allow_calls);
2388
2388
  }
2389
+ if (is("operator", "import")) {
2390
+ return import_meta();
2391
+ }
2389
2392
  var start = S.token;
2390
2393
  var peeked;
2391
2394
  var async = is("name", "async")
@@ -2763,6 +2766,7 @@ function parse($TEXT, options) {
2763
2766
 
2764
2767
  function import_() {
2765
2768
  var start = prev();
2769
+
2766
2770
  var imported_name;
2767
2771
  var imported_names;
2768
2772
  if (is("name")) {
@@ -2797,6 +2801,17 @@ function parse($TEXT, options) {
2797
2801
  });
2798
2802
  }
2799
2803
 
2804
+ function import_meta() {
2805
+ var start = S.token;
2806
+ expect_token("operator", "import");
2807
+ expect_token("punc", ".");
2808
+ expect_token("name", "meta");
2809
+ return subscripts(new AST_ImportMeta({
2810
+ start: start,
2811
+ end: prev()
2812
+ }), false);
2813
+ }
2814
+
2800
2815
  function map_name(is_import) {
2801
2816
  function make_symbol(type) {
2802
2817
  return new type({
@@ -4199,6 +4214,10 @@ var AST_Import = DEFNODE("Import", "imported_name imported_names module_name", {
4199
4214
  },
4200
4215
  });
4201
4216
 
4217
+ var AST_ImportMeta = DEFNODE("ImportMeta", null, {
4218
+ $documentation: "A reference to import.meta",
4219
+ });
4220
+
4202
4221
  var AST_Export = DEFNODE("Export", "exported_definition exported_value is_default exported_names module_name", {
4203
4222
  $documentation: "An `export` statement",
4204
4223
  $propdoc: {
@@ -4978,6 +4997,7 @@ AST_Function: AST_Function,
4978
4997
  AST_Hole: AST_Hole,
4979
4998
  AST_If: AST_If,
4980
4999
  AST_Import: AST_Import,
5000
+ AST_ImportMeta: AST_ImportMeta,
4981
5001
  AST_Infinity: AST_Infinity,
4982
5002
  AST_IterationStatement: AST_IterationStatement,
4983
5003
  AST_Jump: AST_Jump,
@@ -5760,6 +5780,11 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
5760
5780
  start: my_start_token(M),
5761
5781
  end: my_end_token(M)
5762
5782
  });
5783
+ } else if (M.meta.name === "import" && M.property.name === "meta") {
5784
+ return new AST_ImportMeta({
5785
+ start: my_start_token(M),
5786
+ end: my_end_token(M)
5787
+ });
5763
5788
  }
5764
5789
  },
5765
5790
  Identifier: function(M) {
@@ -6051,6 +6076,20 @@ def_transform(AST_PrefixedTemplateString, function(self, tw) {
6051
6076
  };
6052
6077
  });
6053
6078
 
6079
+ def_to_moz(AST_ImportMeta, function To_Moz_MetaProperty() {
6080
+ return {
6081
+ type: "MetaProperty",
6082
+ meta: {
6083
+ type: "Identifier",
6084
+ name: "import"
6085
+ },
6086
+ property: {
6087
+ type: "Identifier",
6088
+ name: "meta"
6089
+ }
6090
+ };
6091
+ });
6092
+
6054
6093
  def_to_moz(AST_Sequence, function To_Moz_SequenceExpression(M) {
6055
6094
  return {
6056
6095
  type: "SequenceExpression",
@@ -7990,6 +8029,9 @@ function OutputStream(options) {
7990
8029
  self.module_name.print(output);
7991
8030
  output.semicolon();
7992
8031
  });
8032
+ DEFPRINT(AST_ImportMeta, function(self, output) {
8033
+ output.print("import.meta");
8034
+ });
7993
8035
 
7994
8036
  DEFPRINT(AST_NameMapping, function(self, output) {
7995
8037
  var is_import = output.parent() instanceof AST_Import;
@@ -8717,6 +8759,8 @@ AST_Import.prototype.shallow_cmp = mkshallow({
8717
8759
  imported_names: "exist"
8718
8760
  });
8719
8761
 
8762
+ AST_ImportMeta.prototype.shallow_cmp = pass_through;
8763
+
8720
8764
  AST_Export.prototype.shallow_cmp = mkshallow({
8721
8765
  exported_definition: "exist",
8722
8766
  exported_value: "exist",
@@ -9879,6 +9923,8 @@ AST_Import.prototype._size = function () {
9879
9923
  return size;
9880
9924
  };
9881
9925
 
9926
+ AST_ImportMeta.prototype._size = () => 11;
9927
+
9882
9928
  AST_Export.prototype._size = function () {
9883
9929
  let size = 7 + (this.is_default ? 8 : 0);
9884
9930