mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-02 20:00:05 +02:00
update packages to latest version
This commit is contained in:
65
node_modules/terser/README.md
generated
vendored
65
node_modules/terser/README.md
generated
vendored
@@ -5,7 +5,7 @@
|
||||
[![Travis Build][travis-image]][travis-url]
|
||||
[![Opencollective financial contributors][opencollective-contributors]][opencollective-url]
|
||||
|
||||
A JavaScript parser and mangler/compressor toolkit for ES6+.
|
||||
A JavaScript mangler/compressor toolkit for ES6+.
|
||||
|
||||
*note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/fabiosantoscode"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="patron" width="100px" height="auto"></a>. Check out [PATRONS.md](https://github.com/terser/terser/blob/master/PATRONS.md) for our first-tier patrons.
|
||||
|
||||
@@ -21,8 +21,8 @@ Find the changelog in [CHANGELOG.md](https://github.com/terser/terser/blob/maste
|
||||
[npm-url]: https://npmjs.org/package/terser
|
||||
[downloads-image]: https://img.shields.io/npm/dm/terser.svg
|
||||
[downloads-url]: https://npmjs.org/package/terser
|
||||
[travis-image]: https://travis-ci.com/terser/terser.svg?branch=master
|
||||
[travis-url]: https://travis-ci.com/terser/terser
|
||||
[travis-image]: https://app.travis-ci.com/terser/terser.svg?branch=master
|
||||
[travis-url]: https://app.travis-ci.com/github/terser/terser
|
||||
[opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
|
||||
[opencollective-url]: https://opencollective.com/terser
|
||||
|
||||
@@ -60,6 +60,12 @@ in sequence and apply any compression options. The files are parsed in the
|
||||
same global scope, that is, a reference from a file to some
|
||||
variable/function declared in another file will be matched properly.
|
||||
|
||||
Command line arguments that take options (like --parse, --compress, --mangle and
|
||||
--format) can take in a comma-separated list of default option overrides. For
|
||||
instance:
|
||||
|
||||
terser input.js --compress ecma=2015,computed_props=false
|
||||
|
||||
If no input file is specified, Terser will read from STDIN.
|
||||
|
||||
If you wish to pass your options before the input files, separate the two with
|
||||
@@ -121,8 +127,8 @@ a double dash to prevent input files being used as option arguments:
|
||||
as JSON to STDOUT respectively.
|
||||
--comments [filter] Preserve copyright comments in the output. By
|
||||
default this works like Google Closure, keeping
|
||||
JSDoc-style comments that contain "@license" or
|
||||
"@preserve". You can optionally pass one of the
|
||||
JSDoc-style comments that contain e.g. "@license",
|
||||
or start with "!". You can optionally pass one of the
|
||||
following arguments to this flag:
|
||||
- "all" to keep all comments
|
||||
- `false` to omit comments in the output
|
||||
@@ -530,6 +536,11 @@ try {
|
||||
- `ecma` (default `undefined`) - pass `5`, `2015`, `2016`, etc to override
|
||||
`compress` and `format`'s `ecma` options.
|
||||
|
||||
- `enclose` (default `false`) - pass `true`, or a string in the format
|
||||
of `"args[:values]"`, where `args` and `values` are comma-separated
|
||||
argument names and values, respectively, to embed the output in a big
|
||||
function with the configurable arguments and values.
|
||||
|
||||
- `parse` (default `{}`) — pass an object if you wish to specify some
|
||||
additional [parse options](#parse-options).
|
||||
|
||||
@@ -569,7 +580,7 @@ try {
|
||||
of class names. Pass a regular expression to only keep class names matching that regex.
|
||||
|
||||
- `keep_fnames` (default: `false`) - pass `true` to prevent discarding or mangling
|
||||
of function names. Pass a regular expression to only keep class names matching that regex.
|
||||
of function names. Pass a regular expression to only keep function names matching that regex.
|
||||
Useful for code relying on `Function.prototype.name`. If the top level minify option
|
||||
`keep_classnames` is `undefined` it will be overridden with the value of the top level
|
||||
minify option `keep_fnames`.
|
||||
@@ -602,6 +613,7 @@ try {
|
||||
// source map options
|
||||
},
|
||||
ecma: 5, // specify one of: 5, 2015, 2016, etc.
|
||||
enclose: false, // or specify true, or "args:values"
|
||||
keep_classnames: false,
|
||||
keep_fnames: false,
|
||||
ie8: false,
|
||||
@@ -885,13 +897,19 @@ If you happen to need the source map as a raw object, set `sourceMap.asObject` t
|
||||
See also: the `keep_classnames` [compress option](#compress-options).
|
||||
|
||||
- `keep_fnames` (default `false`) -- Pass `true` to not mangle function names.
|
||||
Pass a regular expression to only keep class names matching that regex.
|
||||
Pass a regular expression to only keep function names matching that regex.
|
||||
Useful for code relying on `Function.prototype.name`. See also: the `keep_fnames`
|
||||
[compress option](#compress-options).
|
||||
|
||||
- `module` (default `false`) -- Pass `true` an ES6 modules, where the toplevel
|
||||
scope is not the global scope. Implies `toplevel`.
|
||||
|
||||
- `nth_identifier` (default: an internal mangler that weights based on character
|
||||
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
||||
ordinal into the nth most favored (usually shortest) identifier.
|
||||
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
||||
use character frequency analysis of the source code.
|
||||
|
||||
- `reserved` (default `[]`) -- Pass an array of identifiers that should be
|
||||
excluded from mangling. Example: `["foo", "bar"]`.
|
||||
|
||||
@@ -938,6 +956,12 @@ await minify(code, { mangle: { toplevel: true } }).code;
|
||||
- `false` -- `obj["prop"]` is mangled.
|
||||
- `true` -- `obj.prop` is mangled unless there is `obj["prop"]` elsewhere in the code.
|
||||
|
||||
- `nth_identifer` (default: an internal mangler that weights based on character
|
||||
frequency analysis) -- Pass an object with a `get(n)` function that converts an
|
||||
ordinal into the nth most favored (usually shortest) identifier.
|
||||
Optionally also provide `reset()`, `sort()`, and `consider(chars, delta)` to
|
||||
use character frequency analysis of the source code.
|
||||
|
||||
- `regex` (default: `null`) — Pass a [RegExp literal or pattern string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to only mangle property matching the regular expression.
|
||||
|
||||
- `reserved` (default: `[]`) — Do not mangle property names listed in the
|
||||
@@ -965,8 +989,8 @@ as "output options".
|
||||
statement.
|
||||
|
||||
- `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
|
||||
that contain "@license", "@preserve" or start with `!`, pass `true` or
|
||||
`"all"` to preserve all comments, `false` to omit comments in the output,
|
||||
that contain "@license", "@copyright", "@preserve" or start with `!`, pass `true`
|
||||
or `"all"` to preserve all comments, `false` to omit comments in the output,
|
||||
a regular expression string (e.g. `/^!/`) or a function.
|
||||
|
||||
- `ecma` (default `5`) -- set desired EcmaScript standard version for output.
|
||||
@@ -1038,9 +1062,9 @@ as "output options".
|
||||
### Keeping copyright notices or other comments
|
||||
|
||||
You can pass `--comments` to retain certain comments in the output. By
|
||||
default it will keep JSDoc-style comments that contain "@preserve",
|
||||
"@license" or "@cc_on" (conditional compilation for IE). You can pass
|
||||
`--comments all` to keep all the comments, or a valid JavaScript regexp to
|
||||
default it will keep comments starting with "!" and JSDoc-style comments that
|
||||
contain "@preserve", "@copyright", "@license" or "@cc_on" (conditional compilation for IE).
|
||||
You can pass `--comments all` to keep all the comments, or a valid JavaScript regexp to
|
||||
keep only comments that match this regexp. For example `--comments /^!/`
|
||||
will keep comments like `/*! Copyright Notice */`.
|
||||
|
||||
@@ -1072,6 +1096,7 @@ You might want to try it on your own code; it should reduce the minified size.
|
||||
Some examples of the optimizations made when this option is enabled:
|
||||
|
||||
- `new Array(1, 2, 3)` or `Array(1, 2, 3)` → `[ 1, 2, 3 ]`
|
||||
- `Array.from([1, 2, 3])` → `[1, 2, 3]`
|
||||
- `new Object()` → `{}`
|
||||
- `String(exp)` or `exp.toString()` → `"" + exp`
|
||||
- `new Object/RegExp/Function/Error/Array (...)` → we discard the `new`
|
||||
@@ -1293,6 +1318,22 @@ $ yarn
|
||||
|
||||
In the terser CLI we use [source-map-support](https://npmjs.com/source-map-support) to produce good error stacks. In your own app, you're expected to enable source-map-support (read their docs) to have nice stack traces that will help you write good issues.
|
||||
|
||||
## Obtaining the source code given to Terser
|
||||
|
||||
Because users often don't control the call to `await minify()` or its arguments, Terser provides a `TERSER_DEBUG_DIR` environment variable to make terser output some debug logs. If you're using a bundler or a project that includes a bundler and are not sure what went wrong with your code, pass that variable like so:
|
||||
|
||||
```
|
||||
$ TERSER_DEBUG_DIR=/path/to/logs command-that-uses-terser
|
||||
$ ls /path/to/logs
|
||||
terser-debug-123456.log
|
||||
```
|
||||
|
||||
If you're not sure how to set an environment variable on your shell (the above example works in bash), you can try using cross-env:
|
||||
|
||||
```
|
||||
> npx cross-env TERSER_DEBUG_DIR=/path/to/logs command-that-uses-terser
|
||||
```
|
||||
|
||||
# README.md Patrons:
|
||||
|
||||
*note*: You can support this project on patreon: <a target="_blank" rel="nofollow" href="https://www.patreon.com/fabiosantoscode"><img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" alt="patron" width="100px" height="auto"></a>. Check out [PATRONS.md](https://github.com/terser/terser/blob/master/PATRONS.md) for our first-tier patrons.
|
||||
|
Reference in New Issue
Block a user