terser 5.5.0 → 5.5.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/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## v5.4.1
3
+ ## v5.5.1
4
+
5
+ - Fixed object properties with unicode surrogates on safari.
6
+
7
+ ## v5.5.0
4
8
 
5
9
  - Fixed crash when inlining uninitialized variable into template string.
6
10
  - The sourcemap for dist was removed for being too large.
@@ -482,12 +482,14 @@ function is_identifier_char(ch) {
482
482
  return UNICODE.ID_Continue.test(ch);
483
483
  }
484
484
 
485
+ const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
486
+
485
487
  function is_basic_identifier_string(str) {
486
- return /^[a-z_$][a-z0-9_$]*$/i.test(str);
488
+ return BASIC_IDENT.test(str);
487
489
  }
488
490
 
489
491
  function is_identifier_string(str, allow_surrogates) {
490
- if (/^[a-z_$][a-z0-9_$]*$/i.test(str)) {
492
+ if (BASIC_IDENT.test(str)) {
491
493
  return true;
492
494
  }
493
495
  if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
@@ -6824,7 +6826,7 @@ function OutputStream(options) {
6824
6826
  let printed_comments = new Set();
6825
6827
 
6826
6828
  var to_utf8 = options.ascii_only ? function(str, identifier) {
6827
- if (options.ecma >= 2015) {
6829
+ if (options.ecma >= 2015 && !options.safari10) {
6828
6830
  str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
6829
6831
  var code = get_full_char_code(ch, 0).toString(16);
6830
6832
  return "\\u{" + code + "}";
@@ -8364,7 +8366,10 @@ function OutputStream(options) {
8364
8366
  var prop = self.property;
8365
8367
  var print_computed = RESERVED_WORDS.has(prop)
8366
8368
  ? output.option("ie8")
8367
- : !is_identifier_string(prop, output.option("ecma") >= 2015);
8369
+ : !is_identifier_string(
8370
+ prop,
8371
+ output.option("ecma") >= 2015 || output.option("safari10")
8372
+ );
8368
8373
 
8369
8374
  if (self.optional) output.print("?.");
8370
8375
 
@@ -8534,7 +8539,7 @@ function OutputStream(options) {
8534
8539
  var print_string = RESERVED_WORDS.has(key)
8535
8540
  ? output.option("ie8")
8536
8541
  : (
8537
- output.option("ecma") < 2015
8542
+ output.option("ecma") < 2015 || output.option("safari10")
8538
8543
  ? !is_basic_identifier_string(key)
8539
8544
  : !is_identifier_string(key, true)
8540
8545
  );
@@ -8553,7 +8558,10 @@ function OutputStream(options) {
8553
8558
  var allowShortHand = output.option("shorthand");
8554
8559
  if (allowShortHand &&
8555
8560
  self.value instanceof AST_Symbol &&
8556
- is_identifier_string(self.key, output.option("ecma") >= 2015) &&
8561
+ is_identifier_string(
8562
+ self.key,
8563
+ output.option("ecma") >= 2015 || output.option("safari10")
8564
+ ) &&
8557
8565
  get_name(self.value) === self.key &&
8558
8566
  !RESERVED_WORDS.has(self.key)
8559
8567
  ) {
@@ -8562,7 +8570,10 @@ function OutputStream(options) {
8562
8570
  } else if (allowShortHand &&
8563
8571
  self.value instanceof AST_DefaultAssign &&
8564
8572
  self.value.left instanceof AST_Symbol &&
8565
- is_identifier_string(self.key, output.option("ecma") >= 2015) &&
8573
+ is_identifier_string(
8574
+ self.key,
8575
+ output.option("ecma") >= 2015 || output.option("safari10")
8576
+ ) &&
8566
8577
  get_name(self.value.left) === self.key
8567
8578
  ) {
8568
8579
  print_property_name(self.key, self.quote, output);
package/lib/output.js CHANGED
@@ -239,7 +239,7 @@ function OutputStream(options) {
239
239
  let printed_comments = new Set();
240
240
 
241
241
  var to_utf8 = options.ascii_only ? function(str, identifier) {
242
- if (options.ecma >= 2015) {
242
+ if (options.ecma >= 2015 && !options.safari10) {
243
243
  str = str.replace(/[\ud800-\udbff][\udc00-\udfff]/g, function(ch) {
244
244
  var code = get_full_char_code(ch, 0).toString(16);
245
245
  return "\\u{" + code + "}";
@@ -1779,7 +1779,10 @@ function OutputStream(options) {
1779
1779
  var prop = self.property;
1780
1780
  var print_computed = RESERVED_WORDS.has(prop)
1781
1781
  ? output.option("ie8")
1782
- : !is_identifier_string(prop, output.option("ecma") >= 2015);
1782
+ : !is_identifier_string(
1783
+ prop,
1784
+ output.option("ecma") >= 2015 || output.option("safari10")
1785
+ );
1783
1786
 
1784
1787
  if (self.optional) output.print("?.");
1785
1788
 
@@ -1949,7 +1952,7 @@ function OutputStream(options) {
1949
1952
  var print_string = RESERVED_WORDS.has(key)
1950
1953
  ? output.option("ie8")
1951
1954
  : (
1952
- output.option("ecma") < 2015
1955
+ output.option("ecma") < 2015 || output.option("safari10")
1953
1956
  ? !is_basic_identifier_string(key)
1954
1957
  : !is_identifier_string(key, true)
1955
1958
  );
@@ -1968,7 +1971,10 @@ function OutputStream(options) {
1968
1971
  var allowShortHand = output.option("shorthand");
1969
1972
  if (allowShortHand &&
1970
1973
  self.value instanceof AST_Symbol &&
1971
- is_identifier_string(self.key, output.option("ecma") >= 2015) &&
1974
+ is_identifier_string(
1975
+ self.key,
1976
+ output.option("ecma") >= 2015 || output.option("safari10")
1977
+ ) &&
1972
1978
  get_name(self.value) === self.key &&
1973
1979
  !RESERVED_WORDS.has(self.key)
1974
1980
  ) {
@@ -1977,7 +1983,10 @@ function OutputStream(options) {
1977
1983
  } else if (allowShortHand &&
1978
1984
  self.value instanceof AST_DefaultAssign &&
1979
1985
  self.value.left instanceof AST_Symbol &&
1980
- is_identifier_string(self.key, output.option("ecma") >= 2015) &&
1986
+ is_identifier_string(
1987
+ self.key,
1988
+ output.option("ecma") >= 2015 || output.option("safari10")
1989
+ ) &&
1981
1990
  get_name(self.value.left) === self.key
1982
1991
  ) {
1983
1992
  print_property_name(self.key, self.quote, output);
package/lib/parse.js CHANGED
@@ -315,12 +315,14 @@ function is_identifier_char(ch) {
315
315
  return UNICODE.ID_Continue.test(ch);
316
316
  }
317
317
 
318
+ const BASIC_IDENT = /^[a-z_$][a-z0-9_$]*$/i;
319
+
318
320
  function is_basic_identifier_string(str) {
319
- return /^[a-z_$][a-z0-9_$]*$/i.test(str);
321
+ return BASIC_IDENT.test(str);
320
322
  }
321
323
 
322
324
  function is_identifier_string(str, allow_surrogates) {
323
- if (/^[a-z_$][a-z0-9_$]*$/i.test(str)) {
325
+ if (BASIC_IDENT.test(str)) {
324
326
  return true;
325
327
  }
326
328
  if (!allow_surrogates && /[\ud800-\udfff]/.test(str)) {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://terser.org",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "5.5.0",
7
+ "version": "5.5.1",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },