terser 4.3.9 → 4.4.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.

Potentially problematic release.


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

package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## v4.4.1
5
+
6
+ - Fixed a crash when `unsafe` was enabled.
7
+ - An issue has been fixed where `let` statements might be collapsed out of their scope.
8
+ - Some error messages have been improved by adding quotes around variable names.
9
+
10
+ ## v4.4.0
11
+
12
+ - Added `/*#__INLINE__*/` and `/*#__NOINLINE__*/` annotations for calls. If a call has one of these, it either forces or forbids inlining.
13
+
14
+ ## v4.3.11
15
+
16
+ - Fixed a problem where `window` was considered safe to access, even though there are situations where it isn't (Node.js, workers...)
17
+ - Fixed an error where `++` and `--` were considered side-effect free
18
+ - `Number(x)` now needs both `unsafe` and and `unsafe_math` to be compressed into `+x` because `x` might be a `BigInt`
19
+ - `keep_fnames` now correctly supports regexes when the function is in a variable declaration
20
+
21
+ ## v4.3.10
22
+
23
+ - Fixed syntax error when repeated semicolons were encountered in classes
24
+ - Fixed invalid output caused by the creation of empty sequences internally
25
+ - Scopes are now updated when scopes are inlined into them
26
+
3
27
  ## v4.3.9
4
28
  - Fixed issue with mangle's `keep_fnames` option, introduced when adding code to keep variable names of anonymous functions
5
29
 
package/README.md CHANGED
@@ -121,6 +121,7 @@ a double dash to prevent input files being used as option arguments:
121
121
  "@preserve". You can optionally pass one of the
122
122
  following arguments to this flag:
123
123
  - "all" to keep all comments
124
+ - `false` to omit comments in the output
124
125
  - a valid JS RegExp like `/foo/` or `/^!/` to
125
126
  keep only matching comments.
126
127
  Note that currently not *all* comments can be
@@ -320,7 +321,7 @@ var x={o:3,t:1,calc:function(){return this.t+this.o},bar_:2};console.log(x.calc(
320
321
  In order for this to be of any use, we avoid mangling standard JS names by
321
322
  default (`--mangle-props builtins` to override).
322
323
 
323
- A default exclusion file is provided in `tools/domprops.json` which should
324
+ A default exclusion file is provided in `tools/domprops.js` which should
324
325
  cover most standard JS and DOM properties defined in various browsers. Pass
325
326
  `--mangle-props domprops` to disable this feature.
326
327
 
@@ -975,8 +976,9 @@ can pass additional arguments that control the code output:
975
976
  `do`, `while` or `with` statements, even if their body is a single
976
977
  statement.
977
978
 
978
- - `comments` (default `false`) -- pass `true` or `"all"` to preserve all
979
- comments, `"some"` to preserve some comments, a regular expression string
979
+ - `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
980
+ that contain "@license" or "@preserve", pass `true` or `"all"` to preserve all
981
+ comments, `false` to omit comments in the output, a regular expression string
980
982
  (e.g. `/^!/`) or a function.
981
983
 
982
984
  - `ecma` (default `5`) -- set output printing mode. Set `ecma` to `6` or
@@ -1192,6 +1194,30 @@ var result = Terser.minify(ast, {
1192
1194
  // result.code contains the minified code in string form.
1193
1195
  ```
1194
1196
 
1197
+
1198
+ ### Annotations
1199
+
1200
+ Annotations in Terser are a way to tell it to treat a certain function call differently. The following annotations are available:
1201
+
1202
+ * `/*@__INLINE__*/` - forces a function to be inlined somewhere.
1203
+ * `/*@__NOINLINE__*/` - Makes sure the called function is not inlined into the call site.
1204
+ * `/*@__PURE__*/` - Marks a function call as pure. That means, it can safely be dropped.
1205
+
1206
+ You can use either a `@` sign at the start, or a `#`.
1207
+
1208
+ Here are some examples on how to use them:
1209
+
1210
+ ```javascript
1211
+ /*@__INLINE__*/
1212
+ function_always_inlined_here()
1213
+
1214
+ /*#__NOINLINE__*/
1215
+ function_cant_be_inlined_into_here()
1216
+
1217
+ const x = /*#__PURE__*/i_am_dropped_if_x_is_not_used()
1218
+ ```
1219
+
1220
+
1195
1221
  ### Working with Terser AST
1196
1222
 
1197
1223
  Traversal and transformation of the native AST can be performed through