commit node_modules and generated files
This commit is contained in:
parent
6d7a135fea
commit
34b372292b
3379 changed files with 449603 additions and 2029 deletions
149
node_modules/terser-webpack-plugin/CHANGELOG.md
generated
vendored
Normal file
149
node_modules/terser-webpack-plugin/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [1.4.4](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.4.3...v1.4.4) (2020-06-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* security problem ([#257](https://github.com/webpack-contrib/terser-webpack-plugin/issues/257)) ([915e25b](https://github.com/webpack-contrib/terser-webpack-plugin/commit/915e25be50c08740ecb9878a7d004091ef17131d))
|
||||
|
||||
### [1.4.3](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.4.2...v1.4.3) (2019-12-11)
|
||||
|
||||
|
||||
### SECURITY
|
||||
|
||||
* update `serialize-javascript` to `2.1.2` version.
|
||||
|
||||
### [1.4.2](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.4.1...v1.4.2) (2019-12-06)
|
||||
|
||||
|
||||
### SECURITY
|
||||
|
||||
* update `serialize-javascript` to `2.1.1` version.
|
||||
|
||||
### [1.4.1](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.4.0...v1.4.1) (2019-07-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* removed unnecessary dependency ([#111](https://github.com/webpack-contrib/terser-webpack-plugin/issues/111)) ([bc19b72](https://github.com/webpack-contrib/terser-webpack-plugin/commit/bc19b72))
|
||||
|
||||
## [1.4.0](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.3.0...v1.4.0) (2019-07-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* generate higher quality SourceMaps ([#109](https://github.com/webpack-contrib/terser-webpack-plugin/issues/109)) ([9d777f0](https://github.com/webpack-contrib/terser-webpack-plugin/commit/9d777f0))
|
||||
|
||||
## [1.3.0](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.2.4...v1.3.0) (2019-05-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update terser to 4 version ([#97](https://github.com/webpack-contrib/terser-webpack-plugin/issues/97)) ([15d1595](https://github.com/webpack-contrib/terser-webpack-plugin/commit/15d1595))
|
||||
|
||||
|
||||
|
||||
### [1.2.4](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.2.3...v1.2.4) (2019-05-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* disable parallel on WSL due bugs ([#90](https://github.com/webpack-contrib/terser-webpack-plugin/issues/90)) ([d9533dd](https://github.com/webpack-contrib/terser-webpack-plugin/commit/d9533dd))
|
||||
* fallback for cache directory ([#86](https://github.com/webpack-contrib/terser-webpack-plugin/issues/86)) ([3cdd2ed](https://github.com/webpack-contrib/terser-webpack-plugin/commit/3cdd2ed))
|
||||
|
||||
|
||||
|
||||
<a name="1.2.3"></a>
|
||||
## [1.2.3](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.2.2...v1.2.3) (2019-02-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* invalidate cache after changing node version ([675edfd](https://github.com/webpack-contrib/terser-webpack-plugin/commit/675edfd))
|
||||
|
||||
|
||||
|
||||
<a name="1.2.2"></a>
|
||||
## [1.2.2](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.2.1...v1.2.2) (2019-02-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* cannot read property 'minify' of undefined ([#69](https://github.com/webpack-contrib/terser-webpack-plugin/issues/69)) ([0593d7c](https://github.com/webpack-contrib/terser-webpack-plugin/commit/0593d7c))
|
||||
|
||||
|
||||
|
||||
<a name="1.2.1"></a>
|
||||
## [1.2.1](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.2.0...v1.2.1) (2018-12-27)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* don't crash when no extracted comments ([#49](https://github.com/webpack-contrib/terser-webpack-plugin/issues/49)) ([efad586](https://github.com/webpack-contrib/terser-webpack-plugin/commit/efad586))
|
||||
|
||||
|
||||
|
||||
<a name="1.2.0"></a>
|
||||
# [1.2.0](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.1.0...v1.2.0) (2018-12-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `chunks` is a `Set` in webpack@5 ([#19](https://github.com/webpack-contrib/terser-webpack-plugin/issues/19)) ([df8c425](https://github.com/webpack-contrib/terser-webpack-plugin/commit/df8c425))
|
||||
* catch `work-farm` errors ([#35](https://github.com/webpack-contrib/terser-webpack-plugin/issues/35)) ([2bdcd38](https://github.com/webpack-contrib/terser-webpack-plugin/commit/2bdcd38))
|
||||
* dedupe extracted comments ([#40](https://github.com/webpack-contrib/terser-webpack-plugin/issues/40)) ([7f4a159](https://github.com/webpack-contrib/terser-webpack-plugin/commit/7f4a159))
|
||||
* more consistent cache ([#43](https://github.com/webpack-contrib/terser-webpack-plugin/issues/43)) ([36f5f3c](https://github.com/webpack-contrib/terser-webpack-plugin/commit/36f5f3c))
|
||||
* regenerate `contenthash` when assets was uglified ([#44](https://github.com/webpack-contrib/terser-webpack-plugin/issues/44)) ([7e6f8b1](https://github.com/webpack-contrib/terser-webpack-plugin/commit/7e6f8b1))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* `chunkFilter` option for filtering chunks ([#38](https://github.com/webpack-contrib/terser-webpack-plugin/issues/38)) ([7ffe57c](https://github.com/webpack-contrib/terser-webpack-plugin/commit/7ffe57c))
|
||||
* uglify `mjs` by default ([#39](https://github.com/webpack-contrib/terser-webpack-plugin/issues/39)) ([1644620](https://github.com/webpack-contrib/terser-webpack-plugin/commit/1644620))
|
||||
|
||||
|
||||
|
||||
<a name="1.1.0"></a>
|
||||
# [1.1.0](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.0.1...v1.1.0) (2018-09-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* extract comment conditions is case insensitivity ([19e1e43](https://github.com/webpack-contrib/terser-webpack-plugin/commit/19e1e43))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* full coverage schema options validation ([#8](https://github.com/webpack-contrib/terser-webpack-plugin/issues/8)) ([68e531e](https://github.com/webpack-contrib/terser-webpack-plugin/commit/68e531e))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.2"></a>
|
||||
## [1.0.2](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.0.1...v1.0.2) (2018-08-16)
|
||||
|
||||
|
||||
### Internal
|
||||
|
||||
* migrate from `@webpack-contrib/schema-utils` to `schema-utils` ([a5432da](https://github.com/webpack-contrib/terser-webpack-plugin/commit/a5432da))
|
||||
|
||||
<a name="1.0.1"></a>
|
||||
## [1.0.1](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v1.0.0...v1.0.1) (2018-08-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `cpus` length in a chroot environment (`os.cpus()`) ([#4](https://github.com/webpack-contrib/terser-webpack-plugin/issues/4)) ([9375646](https://github.com/webpack-contrib/terser-webpack-plugin/commit/9375646))
|
||||
|
||||
|
||||
|
||||
<a name="1.0.0"></a>
|
||||
# 1.0.0 (2018-08-02)
|
||||
|
||||
Initial publish release
|
||||
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
20
node_modules/terser-webpack-plugin/LICENSE
generated
vendored
Normal file
20
node_modules/terser-webpack-plugin/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
Copyright JS Foundation and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
731
node_modules/terser-webpack-plugin/README.md
generated
vendored
Normal file
731
node_modules/terser-webpack-plugin/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,731 @@
|
|||
<div align="center">
|
||||
<a href="https://github.com/webpack/webpack">
|
||||
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![node][node]][node-url]
|
||||
[![deps][deps]][deps-url]
|
||||
[![tests][tests]][tests-url]
|
||||
[![cover][cover]][cover-url]
|
||||
[![chat][chat]][chat-url]
|
||||
[![size][size]][size-url]
|
||||
|
||||
# terser-webpack-plugin
|
||||
|
||||
This plugin uses [terser](https://github.com/terser-js/terser) to minify your JavaScript.
|
||||
|
||||
> ℹ️ For `webpack@3` use [terser-webpack-plugin-legacy](https://www.npmjs.com/package/terser-webpack-plugin-legacy) package
|
||||
|
||||
## Getting Started
|
||||
|
||||
To begin, you'll need to install `terser-webpack-plugin`:
|
||||
|
||||
```console
|
||||
$ npm install terser-webpack-plugin --save-dev
|
||||
```
|
||||
|
||||
Then add the plugin to your `webpack` config. For example:
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [new TerserPlugin()],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
And run `webpack` via your preferred method.
|
||||
|
||||
## Options
|
||||
|
||||
### `test`
|
||||
|
||||
Type: `String|RegExp|Array<String|RegExp>`
|
||||
Default: `/\.m?js(\?.*)?$/i`
|
||||
|
||||
Test to match files against.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
test: /\.js(\?.*)?$/i,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `include`
|
||||
|
||||
Type: `String|RegExp|Array<String|RegExp>`
|
||||
Default: `undefined`
|
||||
|
||||
Files to include.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
include: /\/includes/,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `exclude`
|
||||
|
||||
Type: `String|RegExp|Array<String|RegExp>`
|
||||
Default: `undefined`
|
||||
|
||||
Files to exclude.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
exclude: /\/excludes/,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `chunkFilter`
|
||||
|
||||
Type: `Function<(chunk) -> boolean>`
|
||||
Default: `() => true`
|
||||
|
||||
Allowing to filter which chunks should be uglified (by default all chunks are uglified).
|
||||
Return `true` to uglify the chunk, `false` otherwise.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
chunkFilter: (chunk) => {
|
||||
// Exclude uglification for the `vendor` chunk
|
||||
if (chunk.name === 'vendor') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `cache`
|
||||
|
||||
Type: `Boolean|String`
|
||||
Default: `false`
|
||||
|
||||
Enable file caching.
|
||||
Default path to cache directory: `node_modules/.cache/terser-webpack-plugin`.
|
||||
|
||||
> ℹ️ If you use your own `minify` function please read the `minify` section for cache invalidation correctly.
|
||||
|
||||
#### `Boolean`
|
||||
|
||||
Enable/disable file caching.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
cache: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `String`
|
||||
|
||||
Enable file caching and set path to cache directory.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
cache: 'path/to/cache',
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `cacheKeys`
|
||||
|
||||
Type: `Function<(defaultCacheKeys, file) -> Object>`
|
||||
Default: `defaultCacheKeys => defaultCacheKeys`
|
||||
|
||||
Allows you to override default cache keys.
|
||||
|
||||
Default cache keys:
|
||||
|
||||
```js
|
||||
({
|
||||
terser: require('terser/package.json').version, // terser version
|
||||
'terser-webpack-plugin': require('../package.json').version, // plugin version
|
||||
'terser-webpack-plugin-options': this.options, // plugin options
|
||||
path: compiler.outputPath ? `${compiler.outputPath}/${file}` : file, // asset path
|
||||
hash: crypto
|
||||
.createHash('md4')
|
||||
.update(input)
|
||||
.digest('hex'), // source file hash
|
||||
});
|
||||
```
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
cache: true,
|
||||
cacheKeys: (defaultCacheKeys, file) => {
|
||||
defaultCacheKeys.myCacheKey = 'myCacheKeyValue';
|
||||
|
||||
return defaultCacheKeys;
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `parallel`
|
||||
|
||||
Type: `Boolean|Number`
|
||||
Default: `false`
|
||||
|
||||
Use multi-process parallel running to improve the build speed.
|
||||
Default number of concurrent runs: `os.cpus().length - 1`.
|
||||
|
||||
> ℹ️ Parallelization can speedup your build significantly and is therefore **highly recommended**.
|
||||
|
||||
#### `Boolean`
|
||||
|
||||
Enable/disable multi-process parallel running.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `Number`
|
||||
|
||||
Enable multi-process parallel running and set number of concurrent runs.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
parallel: 4,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `sourceMap`
|
||||
|
||||
Type: `Boolean`
|
||||
Default: `false`
|
||||
|
||||
Use source maps to map error message locations to modules (this slows down the compilation).
|
||||
If you use your own `minify` function please read the `minify` section for handling source maps correctly.
|
||||
|
||||
> ⚠️ **`cheap-source-map` options don't work with this plugin**.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
sourceMap: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `minify`
|
||||
|
||||
Type: `Function`
|
||||
Default: `undefined`
|
||||
|
||||
Allows you to override default minify function.
|
||||
By default plugin uses [terser](https://github.com/terser-js/terser) package.
|
||||
Useful for using and testing unpublished versions or forks.
|
||||
|
||||
> ⚠️ **Always use `require` inside `minify` function when `parallel` option enabled**.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
minify: (file, sourceMap) => {
|
||||
const extractedComments = [];
|
||||
|
||||
// Custom logic for extract comments
|
||||
|
||||
const { error, map, code, warnings } = require('uglify-module') // Or require('./path/to/uglify-module')
|
||||
.minify(file, {
|
||||
/* Your options for minification */
|
||||
});
|
||||
|
||||
return { error, map, code, warnings, extractedComments };
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `terserOptions`
|
||||
|
||||
Type: `Object`
|
||||
Default: [default](https://github.com/terser-js/terser#minify-options)
|
||||
|
||||
Terser minify [options](https://github.com/terser-js/terser#minify-options).
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
ecma: undefined,
|
||||
warnings: false,
|
||||
parse: {},
|
||||
compress: {},
|
||||
mangle: true, // Note `mangle.properties` is `false` by default.
|
||||
module: false,
|
||||
output: null,
|
||||
toplevel: false,
|
||||
nameCache: null,
|
||||
ie8: false,
|
||||
keep_classnames: undefined,
|
||||
keep_fnames: false,
|
||||
safari10: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `extractComments`
|
||||
|
||||
Type: `Boolean|String|RegExp|Function<(node, comment) -> Boolean|Object>|Object`
|
||||
Default: `false`
|
||||
|
||||
Whether comments shall be extracted to a separate file, (see [details](https://github.com/webpack/webpack/commit/71933e979e51c533b432658d5e37917f9e71595a)).
|
||||
By default extract only comments using `/^\**!|@preserve|@license|@cc_on/i` regexp condition and remove remaining comments.
|
||||
If the original file is named `foo.js`, then the comments will be stored to `foo.js.LICENSE`.
|
||||
The `terserOptions.output.comments` option specifies whether the comment will be preserved, i.e. it is possible to preserve some comments (e.g. annotations) while extracting others or even preserving comments that have been extracted.
|
||||
|
||||
#### `Boolean`
|
||||
|
||||
Enable/disable extracting comments.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `String`
|
||||
|
||||
Extract `all` or `some` (use `/^\**!|@preserve|@license|@cc_on/i` RegExp) comments.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: 'all',
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `RegExp`
|
||||
|
||||
All comments that match the given expression will be extracted to the separate file.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: /@extract/i,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `Function<(node, comment) -> Boolean>`
|
||||
|
||||
All comments that match the given expression will be extracted to the separate file.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: (astNode, comment) => {
|
||||
if (/@extract/i.test(comment.value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
#### `Object`
|
||||
|
||||
Allow to customize condition for extract comments, specify extracted file name and banner.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: {
|
||||
condition: /^\**!|@preserve|@license|@cc_on/i,
|
||||
filename: (file) => {
|
||||
return `${file}.LICENSE`;
|
||||
},
|
||||
banner: (licenseFile) => {
|
||||
return `License information can be found in ${licenseFile}`;
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
##### `condition`
|
||||
|
||||
Type: `Boolean|String|RegExp|Function<(node, comment) -> Boolean|Object>`
|
||||
|
||||
Condition what comments you need extract.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: {
|
||||
condition: 'some',
|
||||
filename: (file) => {
|
||||
return `${file}.LICENSE`;
|
||||
},
|
||||
banner: (licenseFile) => {
|
||||
return `License information can be found in ${licenseFile}`;
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
##### `filename`
|
||||
|
||||
Type: `String|Function<(string) -> String>`
|
||||
Default: `${file}.LICENSE`
|
||||
|
||||
The file where the extracted comments will be stored.
|
||||
Default is to append the suffix `.LICENSE` to the original filename.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: {
|
||||
condition: /^\**!|@preserve|@license|@cc_on/i,
|
||||
filename: 'extracted-comments.js',
|
||||
banner: (licenseFile) => {
|
||||
return `License information can be found in ${licenseFile}`;
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
##### `banner`
|
||||
|
||||
Type: `Boolean|String|Function<(string) -> String>`
|
||||
Default: `/*! For license information please see ${commentsFile} */`
|
||||
|
||||
The banner text that points to the extracted file and will be added on top of the original file.
|
||||
Can be `false` (no banner), a `String`, or a `Function<(string) -> String>` that will be called with the filename where extracted comments have been stored.
|
||||
Will be wrapped into comment.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
extractComments: {
|
||||
condition: true,
|
||||
filename: (file) => {
|
||||
return `${file}.LICENSE`;
|
||||
},
|
||||
banner: (commentsFile) => {
|
||||
return `My custom banner about license information ${commentsFile}`;
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### `warningsFilter`
|
||||
|
||||
Type: `Function<(warning, source) -> Boolean>`
|
||||
Default: `() => true`
|
||||
|
||||
Allow to filter [terser](https://github.com/terser-js/terser) warnings.
|
||||
Return `true` to keep the warning, `false` otherwise.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
warningsFilter: (warning, source) => {
|
||||
if (/Dropping unreachable code/i.test(warning)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (/filename\.js/i.test(source)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Cache And Parallel
|
||||
|
||||
Enable cache and multi-process parallel running.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
cache: true,
|
||||
parallel: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Preserve Comments
|
||||
|
||||
Extract all legal comments (i.e. `/^\**!|@preserve|@license|@cc_on/i`) and preserve `/@license/i` comments.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
output: {
|
||||
comments: /@license/i,
|
||||
},
|
||||
},
|
||||
extractComments: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Remove Comments
|
||||
|
||||
If you avoid building with comments, set **terserOptions.output.comments** to **false** as in this config:
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
output: {
|
||||
comments: false,
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Custom Minify Function
|
||||
|
||||
Override default minify function - use `uglify-js` for minification.
|
||||
|
||||
**webpack.config.js**
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
optimization: {
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
// Uncomment lines below for cache invalidation correctly
|
||||
// cache: true,
|
||||
// cacheKeys: (defaultCacheKeys) => {
|
||||
// delete defaultCacheKeys.terser;
|
||||
//
|
||||
// return Object.assign(
|
||||
// {},
|
||||
// defaultCacheKeys,
|
||||
// { 'uglify-js': require('uglify-js/package.json').version },
|
||||
// );
|
||||
// },
|
||||
minify: (file, sourceMap) => {
|
||||
// https://github.com/mishoo/UglifyJS2#minify-options
|
||||
const uglifyJsOptions = {
|
||||
/* your `uglify-js` package options */
|
||||
};
|
||||
|
||||
if (sourceMap) {
|
||||
uglifyJsOptions.sourceMap = {
|
||||
content: sourceMap,
|
||||
};
|
||||
}
|
||||
|
||||
return require('uglify-js').minify(file, uglifyJsOptions);
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please take a moment to read our contributing guidelines if you haven't yet done so.
|
||||
|
||||
[CONTRIBUTING](./.github/CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
||||
[npm]: https://img.shields.io/npm/v/terser-webpack-plugin.svg
|
||||
[npm-url]: https://npmjs.com/package/terser-webpack-plugin
|
||||
[node]: https://img.shields.io/node/v/terser-webpack-plugin.svg
|
||||
[node-url]: https://nodejs.org
|
||||
[deps]: https://david-dm.org/webpack-contrib/terser-webpack-plugin.svg
|
||||
[deps-url]: https://david-dm.org/webpack-contrib/terser-webpack-plugin
|
||||
[tests]: https://dev.azure.com/webpack-contrib/terser-webpack-plugin/_apis/build/status/webpack-contrib.terser-webpack-plugin?branchName=master
|
||||
[tests-url]: https://dev.azure.com/webpack-contrib/terser-webpack-plugin/_build/latest?definitionId=7&branchName=master
|
||||
[cover]: https://codecov.io/gh/webpack-contrib/terser-webpack-plugin/branch/master/graph/badge.svg
|
||||
[cover-url]: https://codecov.io/gh/webpack-contrib/terser-webpack-plugin
|
||||
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
|
||||
[chat-url]: https://gitter.im/webpack/webpack
|
||||
[size]: https://packagephobia.now.sh/badge?p=terser-webpack-plugin
|
||||
[size-url]: https://packagephobia.now.sh/result?p=terser-webpack-plugin
|
||||
126
node_modules/terser-webpack-plugin/dist/TaskRunner.js
generated
vendored
Normal file
126
node_modules/terser-webpack-plugin/dist/TaskRunner.js
generated
vendored
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _os = _interopRequireDefault(require("os"));
|
||||
|
||||
var _cacache = _interopRequireDefault(require("cacache"));
|
||||
|
||||
var _findCacheDir = _interopRequireDefault(require("find-cache-dir"));
|
||||
|
||||
var _workerFarm = _interopRequireDefault(require("worker-farm"));
|
||||
|
||||
var _serializeJavascript = _interopRequireDefault(require("serialize-javascript"));
|
||||
|
||||
var _isWsl = _interopRequireDefault(require("is-wsl"));
|
||||
|
||||
var _minify = _interopRequireDefault(require("./minify"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const worker = require.resolve('./worker');
|
||||
|
||||
class TaskRunner {
|
||||
constructor(options = {}) {
|
||||
const {
|
||||
cache,
|
||||
parallel
|
||||
} = options;
|
||||
this.cacheDir = cache === true ? (0, _findCacheDir.default)({
|
||||
name: 'terser-webpack-plugin'
|
||||
}) || _os.default.tmpdir() : cache; // In some cases cpus() returns undefined
|
||||
// https://github.com/nodejs/node/issues/19022
|
||||
|
||||
const cpus = _os.default.cpus() || {
|
||||
length: 1
|
||||
}; // WSL sometimes freezes, error seems to be on the WSL side
|
||||
// https://github.com/webpack-contrib/terser-webpack-plugin/issues/21
|
||||
|
||||
this.maxConcurrentWorkers = _isWsl.default ? 1 : parallel === true ? cpus.length - 1 : Math.min(Number(parallel) || 0, cpus.length - 1);
|
||||
}
|
||||
|
||||
run(tasks, callback) {
|
||||
/* istanbul ignore if */
|
||||
if (!tasks.length) {
|
||||
callback(null, []);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.maxConcurrentWorkers > 1) {
|
||||
const workerOptions = process.platform === 'win32' ? {
|
||||
maxConcurrentWorkers: this.maxConcurrentWorkers,
|
||||
maxConcurrentCallsPerWorker: 1
|
||||
} : {
|
||||
maxConcurrentWorkers: this.maxConcurrentWorkers
|
||||
};
|
||||
this.workers = (0, _workerFarm.default)(workerOptions, worker);
|
||||
|
||||
this.boundWorkers = (options, cb) => {
|
||||
try {
|
||||
this.workers((0, _serializeJavascript.default)(options), cb);
|
||||
} catch (error) {
|
||||
// worker-farm can fail with ENOMEM or something else
|
||||
cb(error);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.boundWorkers = (options, cb) => {
|
||||
try {
|
||||
cb(null, (0, _minify.default)(options));
|
||||
} catch (error) {
|
||||
cb(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let toRun = tasks.length;
|
||||
const results = [];
|
||||
|
||||
const step = (index, data) => {
|
||||
toRun -= 1;
|
||||
results[index] = data;
|
||||
|
||||
if (!toRun) {
|
||||
callback(null, results);
|
||||
}
|
||||
};
|
||||
|
||||
tasks.forEach((task, index) => {
|
||||
const enqueue = () => {
|
||||
this.boundWorkers(task, (error, data) => {
|
||||
const result = error ? {
|
||||
error
|
||||
} : data;
|
||||
|
||||
const done = () => step(index, result);
|
||||
|
||||
if (this.cacheDir && !result.error) {
|
||||
_cacache.default.put(this.cacheDir, (0, _serializeJavascript.default)(task.cacheKeys), JSON.stringify(data)).then(done, done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (this.cacheDir) {
|
||||
_cacache.default.get(this.cacheDir, (0, _serializeJavascript.default)(task.cacheKeys)).then(({
|
||||
data
|
||||
}) => step(index, JSON.parse(data)), enqueue);
|
||||
} else {
|
||||
enqueue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exit() {
|
||||
if (this.workers) {
|
||||
_workerFarm.default.end(this.workers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = TaskRunner;
|
||||
5
node_modules/terser-webpack-plugin/dist/cjs.js
generated
vendored
Normal file
5
node_modules/terser-webpack-plugin/dist/cjs.js
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const plugin = require('./index');
|
||||
|
||||
module.exports = plugin.default;
|
||||
356
node_modules/terser-webpack-plugin/dist/index.js
generated
vendored
Normal file
356
node_modules/terser-webpack-plugin/dist/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,356 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _crypto = _interopRequireDefault(require("crypto"));
|
||||
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
|
||||
var _sourceMap = require("source-map");
|
||||
|
||||
var _webpackSources = require("webpack-sources");
|
||||
|
||||
var _RequestShortener = _interopRequireDefault(require("webpack/lib/RequestShortener"));
|
||||
|
||||
var _ModuleFilenameHelpers = _interopRequireDefault(require("webpack/lib/ModuleFilenameHelpers"));
|
||||
|
||||
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
|
||||
|
||||
var _serializeJavascript = _interopRequireDefault(require("serialize-javascript"));
|
||||
|
||||
var _package = _interopRequireDefault(require("terser/package.json"));
|
||||
|
||||
var _options = _interopRequireDefault(require("./options.json"));
|
||||
|
||||
var _TaskRunner = _interopRequireDefault(require("./TaskRunner"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
const warningRegex = /\[.+:([0-9]+),([0-9]+)\]/;
|
||||
|
||||
class TerserPlugin {
|
||||
constructor(options = {}) {
|
||||
(0, _schemaUtils.default)(_options.default, options, 'Terser Plugin');
|
||||
const {
|
||||
minify,
|
||||
terserOptions = {},
|
||||
test = /\.m?js(\?.*)?$/i,
|
||||
chunkFilter = () => true,
|
||||
warningsFilter = () => true,
|
||||
extractComments = false,
|
||||
sourceMap = false,
|
||||
cache = false,
|
||||
cacheKeys = defaultCacheKeys => defaultCacheKeys,
|
||||
parallel = false,
|
||||
include,
|
||||
exclude
|
||||
} = options;
|
||||
this.options = {
|
||||
test,
|
||||
chunkFilter,
|
||||
warningsFilter,
|
||||
extractComments,
|
||||
sourceMap,
|
||||
cache,
|
||||
cacheKeys,
|
||||
parallel,
|
||||
include,
|
||||
exclude,
|
||||
minify,
|
||||
terserOptions: _objectSpread({
|
||||
output: {
|
||||
comments: extractComments ? false : /^\**!|@preserve|@license|@cc_on/i
|
||||
}
|
||||
}, terserOptions)
|
||||
};
|
||||
}
|
||||
|
||||
static isSourceMap(input) {
|
||||
// All required options for `new SourceMapConsumer(...options)`
|
||||
// https://github.com/mozilla/source-map#new-sourcemapconsumerrawsourcemap
|
||||
return Boolean(input && input.version && input.sources && Array.isArray(input.sources) && typeof input.mappings === 'string');
|
||||
}
|
||||
|
||||
static buildSourceMap(inputSourceMap) {
|
||||
if (!inputSourceMap || !TerserPlugin.isSourceMap(inputSourceMap)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new _sourceMap.SourceMapConsumer(inputSourceMap);
|
||||
}
|
||||
|
||||
static buildError(err, file, sourceMap, requestShortener) {
|
||||
// Handling error which should have line, col, filename and message
|
||||
if (err.line) {
|
||||
const original = sourceMap && sourceMap.originalPositionFor({
|
||||
line: err.line,
|
||||
column: err.col
|
||||
});
|
||||
|
||||
if (original && original.source && requestShortener) {
|
||||
return new Error(`${file} from Terser\n${err.message} [${requestShortener.shorten(original.source)}:${original.line},${original.column}][${file}:${err.line},${err.col}]`);
|
||||
}
|
||||
|
||||
return new Error(`${file} from Terser\n${err.message} [${file}:${err.line},${err.col}]`);
|
||||
} else if (err.stack) {
|
||||
return new Error(`${file} from Terser\n${err.stack}`);
|
||||
}
|
||||
|
||||
return new Error(`${file} from Terser\n${err.message}`);
|
||||
}
|
||||
|
||||
static buildWarning(warning, file, sourceMap, requestShortener, warningsFilter) {
|
||||
let warningMessage = warning;
|
||||
let locationMessage = '';
|
||||
let source = null;
|
||||
|
||||
if (sourceMap) {
|
||||
const match = warningRegex.exec(warning);
|
||||
|
||||
if (match) {
|
||||
const line = +match[1];
|
||||
const column = +match[2];
|
||||
const original = sourceMap.originalPositionFor({
|
||||
line,
|
||||
column
|
||||
});
|
||||
|
||||
if (original && original.source && original.source !== file && requestShortener) {
|
||||
({
|
||||
source
|
||||
} = original);
|
||||
warningMessage = `${warningMessage.replace(warningRegex, '')}`;
|
||||
locationMessage = `[${requestShortener.shorten(original.source)}:${original.line},${original.column}]`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (warningsFilter && !warningsFilter(warning, source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `Terser Plugin: ${warningMessage}${locationMessage}`;
|
||||
}
|
||||
|
||||
apply(compiler) {
|
||||
const buildModuleFn = moduleArg => {
|
||||
// to get detailed location info about errors
|
||||
moduleArg.useSourceMap = true;
|
||||
};
|
||||
|
||||
const optimizeFn = (compilation, chunks, callback) => {
|
||||
const taskRunner = new _TaskRunner.default({
|
||||
cache: this.options.cache,
|
||||
parallel: this.options.parallel
|
||||
});
|
||||
const processedAssets = new WeakSet();
|
||||
const tasks = [];
|
||||
const {
|
||||
chunkFilter
|
||||
} = this.options;
|
||||
Array.from(chunks).filter(chunk => chunkFilter && chunkFilter(chunk)).reduce((acc, chunk) => acc.concat(chunk.files || []), []).concat(compilation.additionalChunkAssets || []).filter(_ModuleFilenameHelpers.default.matchObject.bind(null, this.options)).forEach(file => {
|
||||
let inputSourceMap;
|
||||
const asset = compilation.assets[file];
|
||||
|
||||
if (processedAssets.has(asset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
let input;
|
||||
|
||||
if (this.options.sourceMap && asset.sourceAndMap) {
|
||||
const {
|
||||
source,
|
||||
map
|
||||
} = asset.sourceAndMap();
|
||||
input = source;
|
||||
|
||||
if (TerserPlugin.isSourceMap(map)) {
|
||||
inputSourceMap = map;
|
||||
} else {
|
||||
inputSourceMap = map;
|
||||
compilation.warnings.push(new Error(`${file} contains invalid source map`));
|
||||
}
|
||||
} else {
|
||||
input = asset.source();
|
||||
inputSourceMap = null;
|
||||
} // Handling comment extraction
|
||||
|
||||
|
||||
let commentsFile = false;
|
||||
|
||||
if (this.options.extractComments) {
|
||||
commentsFile = this.options.extractComments.filename || `${file}.LICENSE`;
|
||||
|
||||
if (typeof commentsFile === 'function') {
|
||||
commentsFile = commentsFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
const task = {
|
||||
file,
|
||||
input,
|
||||
inputSourceMap,
|
||||
commentsFile,
|
||||
extractComments: this.options.extractComments,
|
||||
terserOptions: this.options.terserOptions,
|
||||
minify: this.options.minify
|
||||
};
|
||||
|
||||
if (this.options.cache) {
|
||||
const defaultCacheKeys = {
|
||||
terser: _package.default.version,
|
||||
node_version: process.version,
|
||||
// eslint-disable-next-line global-require
|
||||
'terser-webpack-plugin': require('../package.json').version,
|
||||
'terser-webpack-plugin-options': this.options,
|
||||
hash: _crypto.default.createHash('md4').update(input).digest('hex')
|
||||
};
|
||||
task.cacheKeys = this.options.cacheKeys(defaultCacheKeys, file);
|
||||
}
|
||||
|
||||
tasks.push(task);
|
||||
} catch (error) {
|
||||
compilation.errors.push(TerserPlugin.buildError(error, file, TerserPlugin.buildSourceMap(inputSourceMap), new _RequestShortener.default(compiler.context)));
|
||||
}
|
||||
});
|
||||
taskRunner.run(tasks, (tasksError, results) => {
|
||||
if (tasksError) {
|
||||
compilation.errors.push(tasksError);
|
||||
return;
|
||||
}
|
||||
|
||||
results.forEach((data, index) => {
|
||||
const {
|
||||
file,
|
||||
input,
|
||||
inputSourceMap,
|
||||
commentsFile
|
||||
} = tasks[index];
|
||||
const {
|
||||
error,
|
||||
map,
|
||||
code,
|
||||
warnings
|
||||
} = data;
|
||||
let {
|
||||
extractedComments
|
||||
} = data;
|
||||
let sourceMap = null;
|
||||
|
||||
if (error || warnings && warnings.length > 0) {
|
||||
sourceMap = TerserPlugin.buildSourceMap(inputSourceMap);
|
||||
} // Handling results
|
||||
// Error case: add errors, and go to next file
|
||||
|
||||
|
||||
if (error) {
|
||||
compilation.errors.push(TerserPlugin.buildError(error, file, sourceMap, new _RequestShortener.default(compiler.context)));
|
||||
return;
|
||||
}
|
||||
|
||||
let outputSource;
|
||||
|
||||
if (map) {
|
||||
outputSource = new _webpackSources.SourceMapSource(code, file, JSON.parse(map), input, inputSourceMap, true);
|
||||
} else {
|
||||
outputSource = new _webpackSources.RawSource(code);
|
||||
} // Write extracted comments to commentsFile
|
||||
|
||||
|
||||
if (commentsFile && extractedComments && extractedComments.length > 0) {
|
||||
if (commentsFile in compilation.assets) {
|
||||
const commentsFileSource = compilation.assets[commentsFile].source();
|
||||
extractedComments = extractedComments.filter(comment => !commentsFileSource.includes(comment));
|
||||
}
|
||||
|
||||
if (extractedComments.length > 0) {
|
||||
// Add a banner to the original file
|
||||
if (this.options.extractComments.banner !== false) {
|
||||
let banner = this.options.extractComments.banner || `For license information please see ${_path.default.posix.basename(commentsFile)}`;
|
||||
|
||||
if (typeof banner === 'function') {
|
||||
banner = banner(commentsFile);
|
||||
}
|
||||
|
||||
if (banner) {
|
||||
outputSource = new _webpackSources.ConcatSource(`/*! ${banner} */\n`, outputSource);
|
||||
}
|
||||
}
|
||||
|
||||
const commentsSource = new _webpackSources.RawSource(`${extractedComments.join('\n\n')}\n`);
|
||||
|
||||
if (commentsFile in compilation.assets) {
|
||||
// commentsFile already exists, append new comments...
|
||||
if (compilation.assets[commentsFile] instanceof _webpackSources.ConcatSource) {
|
||||
compilation.assets[commentsFile].add('\n');
|
||||
compilation.assets[commentsFile].add(commentsSource);
|
||||
} else {
|
||||
compilation.assets[commentsFile] = new _webpackSources.ConcatSource(compilation.assets[commentsFile], '\n', commentsSource);
|
||||
}
|
||||
} else {
|
||||
compilation.assets[commentsFile] = commentsSource;
|
||||
}
|
||||
}
|
||||
} // Updating assets
|
||||
|
||||
|
||||
processedAssets.add(compilation.assets[file] = outputSource); // Handling warnings
|
||||
|
||||
if (warnings && warnings.length > 0) {
|
||||
warnings.forEach(warning => {
|
||||
const builtWarning = TerserPlugin.buildWarning(warning, file, sourceMap, new _RequestShortener.default(compiler.context), this.options.warningsFilter);
|
||||
|
||||
if (builtWarning) {
|
||||
compilation.warnings.push(builtWarning);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
taskRunner.exit();
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
const plugin = {
|
||||
name: this.constructor.name
|
||||
};
|
||||
compiler.hooks.compilation.tap(plugin, compilation => {
|
||||
if (this.options.sourceMap) {
|
||||
compilation.hooks.buildModule.tap(plugin, buildModuleFn);
|
||||
}
|
||||
|
||||
const {
|
||||
mainTemplate,
|
||||
chunkTemplate
|
||||
} = compilation; // Regenerate `contenthash` for minified assets
|
||||
|
||||
for (const template of [mainTemplate, chunkTemplate]) {
|
||||
template.hooks.hashForChunk.tap(plugin, hash => {
|
||||
const data = (0, _serializeJavascript.default)({
|
||||
terser: _package.default.version,
|
||||
terserOptions: this.options.terserOptions
|
||||
});
|
||||
hash.update('TerserPlugin');
|
||||
hash.update(data);
|
||||
});
|
||||
}
|
||||
|
||||
compilation.hooks.optimizeChunkAssets.tapAsync(plugin, optimizeFn.bind(this, compilation));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var _default = TerserPlugin;
|
||||
exports.default = _default;
|
||||
186
node_modules/terser-webpack-plugin/dist/minify.js
generated
vendored
Normal file
186
node_modules/terser-webpack-plugin/dist/minify.js
generated
vendored
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _terser = require("terser");
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
const buildTerserOptions = ({
|
||||
ecma,
|
||||
warnings,
|
||||
parse = {},
|
||||
compress = {},
|
||||
mangle,
|
||||
module,
|
||||
output,
|
||||
toplevel,
|
||||
nameCache,
|
||||
ie8,
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
keep_classnames,
|
||||
keep_fnames,
|
||||
|
||||
/* eslint-enable camelcase */
|
||||
safari10
|
||||
} = {}) => ({
|
||||
ecma,
|
||||
warnings,
|
||||
parse: _objectSpread({}, parse),
|
||||
compress: typeof compress === 'boolean' ? compress : _objectSpread({}, compress),
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
mangle: mangle == null ? true : typeof mangle === 'boolean' ? mangle : _objectSpread({}, mangle),
|
||||
output: _objectSpread({
|
||||
shebang: true,
|
||||
comments: false,
|
||||
beautify: false,
|
||||
semicolons: true
|
||||
}, output),
|
||||
module,
|
||||
// Ignoring sourceMap from options
|
||||
sourceMap: null,
|
||||
toplevel,
|
||||
nameCache,
|
||||
ie8,
|
||||
keep_classnames,
|
||||
keep_fnames,
|
||||
safari10
|
||||
});
|
||||
|
||||
const buildComments = (options, terserOptions, extractedComments) => {
|
||||
const condition = {};
|
||||
const commentsOpts = terserOptions.output.comments; // Use /^\**!|@preserve|@license|@cc_on/i RegExp
|
||||
|
||||
if (typeof options.extractComments === 'boolean') {
|
||||
condition.preserve = commentsOpts;
|
||||
condition.extract = /^\**!|@preserve|@license|@cc_on/i;
|
||||
} else if (typeof options.extractComments === 'string' || options.extractComments instanceof RegExp) {
|
||||
// extractComments specifies the extract condition and commentsOpts specifies the preserve condition
|
||||
condition.preserve = commentsOpts;
|
||||
condition.extract = options.extractComments;
|
||||
} else if (typeof options.extractComments === 'function') {
|
||||
condition.preserve = commentsOpts;
|
||||
condition.extract = options.extractComments;
|
||||
} else if (Object.prototype.hasOwnProperty.call(options.extractComments, 'condition')) {
|
||||
// Extract condition is given in extractComments.condition
|
||||
condition.preserve = commentsOpts;
|
||||
condition.extract = options.extractComments.condition;
|
||||
} else {
|
||||
// No extract condition is given. Extract comments that match commentsOpts instead of preserving them
|
||||
condition.preserve = false;
|
||||
condition.extract = commentsOpts;
|
||||
} // Ensure that both conditions are functions
|
||||
|
||||
|
||||
['preserve', 'extract'].forEach(key => {
|
||||
let regexStr;
|
||||
let regex;
|
||||
|
||||
switch (typeof condition[key]) {
|
||||
case 'boolean':
|
||||
condition[key] = condition[key] ? () => true : () => false;
|
||||
break;
|
||||
|
||||
case 'function':
|
||||
break;
|
||||
|
||||
case 'string':
|
||||
if (condition[key] === 'all') {
|
||||
condition[key] = () => true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (condition[key] === 'some') {
|
||||
condition[key] = (astNode, comment) => {
|
||||
return comment.type === 'comment2' && /^\**!|@preserve|@license|@cc_on/i.test(comment.value);
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
regexStr = condition[key];
|
||||
|
||||
condition[key] = (astNode, comment) => {
|
||||
return new RegExp(regexStr).test(comment.value);
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
regex = condition[key];
|
||||
|
||||
condition[key] = (astNode, comment) => regex.test(comment.value);
|
||||
|
||||
}
|
||||
}); // Redefine the comments function to extract and preserve
|
||||
// comments according to the two conditions
|
||||
|
||||
return (astNode, comment) => {
|
||||
if (condition.extract(astNode, comment)) {
|
||||
const commentText = comment.type === 'comment2' ? `/*${comment.value}*/` : `//${comment.value}`; // Don't include duplicate comments
|
||||
|
||||
if (!extractedComments.includes(commentText)) {
|
||||
extractedComments.push(commentText);
|
||||
}
|
||||
}
|
||||
|
||||
return condition.preserve(astNode, comment);
|
||||
};
|
||||
};
|
||||
|
||||
const minify = options => {
|
||||
const {
|
||||
file,
|
||||
input,
|
||||
inputSourceMap,
|
||||
extractComments,
|
||||
minify: minifyFn
|
||||
} = options;
|
||||
|
||||
if (minifyFn) {
|
||||
return minifyFn({
|
||||
[file]: input
|
||||
}, inputSourceMap);
|
||||
} // Copy terser options
|
||||
|
||||
|
||||
const terserOptions = buildTerserOptions(options.terserOptions); // Let terser generate a SourceMap
|
||||
|
||||
if (inputSourceMap) {
|
||||
terserOptions.sourceMap = true;
|
||||
}
|
||||
|
||||
const extractedComments = [];
|
||||
|
||||
if (extractComments) {
|
||||
terserOptions.output.comments = buildComments(options, terserOptions, extractedComments);
|
||||
}
|
||||
|
||||
const {
|
||||
error,
|
||||
map,
|
||||
code,
|
||||
warnings
|
||||
} = (0, _terser.minify)({
|
||||
[file]: input
|
||||
}, terserOptions);
|
||||
return {
|
||||
error,
|
||||
map,
|
||||
code,
|
||||
warnings,
|
||||
extractedComments
|
||||
};
|
||||
};
|
||||
|
||||
var _default = minify;
|
||||
exports.default = _default;
|
||||
169
node_modules/terser-webpack-plugin/dist/options.json
generated
vendored
Normal file
169
node_modules/terser-webpack-plugin/dist/options.json
generated
vendored
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
{
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"file-conditions": {
|
||||
"anyOf": [
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"test": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
},
|
||||
{
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
]
|
||||
},
|
||||
"include": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
},
|
||||
{
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
]
|
||||
},
|
||||
"exclude": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
},
|
||||
{
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/file-conditions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
]
|
||||
},
|
||||
"chunkFilter": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"cache": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"cacheKeys": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"parallel": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sourceMap": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"minify": {
|
||||
"instanceof": "Function"
|
||||
},
|
||||
"terserOptions": {
|
||||
"additionalProperties": true,
|
||||
"type": "object"
|
||||
},
|
||||
"extractComments": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
},
|
||||
{
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"condition": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "RegExp"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"filename": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
},
|
||||
"banner": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"instanceof": "Function"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"warningsFilter": {
|
||||
"instanceof": "Function"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
17
node_modules/terser-webpack-plugin/dist/worker.js
generated
vendored
Normal file
17
node_modules/terser-webpack-plugin/dist/worker.js
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
var _minify = _interopRequireDefault(require("./minify"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
module.exports = (options, callback) => {
|
||||
try {
|
||||
// 'use strict' => this === undefined (Clean Scope)
|
||||
// Safer for possible security issues, albeit not critical at all here
|
||||
// eslint-disable-next-line no-new-func, no-param-reassign
|
||||
options = new Function('exports', 'require', 'module', '__filename', '__dirname', `'use strict'\nreturn ${options}`)(exports, require, module, __filename, __dirname);
|
||||
callback(null, (0, _minify.default)(options));
|
||||
} catch (errors) {
|
||||
callback(errors);
|
||||
}
|
||||
};
|
||||
94
node_modules/terser-webpack-plugin/package.json
generated
vendored
Normal file
94
node_modules/terser-webpack-plugin/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"name": "terser-webpack-plugin",
|
||||
"version": "1.4.4",
|
||||
"description": "Terser plugin for webpack",
|
||||
"license": "MIT",
|
||||
"repository": "webpack-contrib/terser-webpack-plugin",
|
||||
"author": "webpack Contrib Team",
|
||||
"homepage": "https://github.com/webpack-contrib/terser-webpack-plugin",
|
||||
"bugs": "https://github.com/webpack-contrib/terser-webpack-plugin/issues",
|
||||
"main": "dist/cjs.js",
|
||||
"engines": {
|
||||
"node": ">= 6.9.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npm run build -- -w",
|
||||
"prebuild": "npm run clean",
|
||||
"build": "cross-env NODE_ENV=production babel src -d dist --ignore \"src/**/*.test.js\" --copy-files",
|
||||
"clean": "del-cli dist",
|
||||
"commitlint": "commitlint --from=master",
|
||||
"lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css}\" --list-different",
|
||||
"lint:js": "eslint --cache src test",
|
||||
"lint": "npm-run-all -l -p \"lint:**\"",
|
||||
"prepare": "npm run build",
|
||||
"release": "standard-version",
|
||||
"security": "npm audit",
|
||||
"test:only": "cross-env NODE_ENV=test jest",
|
||||
"test:watch": "cross-env NODE_ENV=test jest --watch",
|
||||
"test:coverage": "cross-env NODE_ENV=test jest --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
||||
"pretest": "npm run lint",
|
||||
"test": "cross-env NODE_ENV=test npm run test:coverage",
|
||||
"defaults": "webpack-defaults"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"webpack": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cacache": "^12.0.2",
|
||||
"find-cache-dir": "^2.1.0",
|
||||
"is-wsl": "^1.1.0",
|
||||
"schema-utils": "^1.0.0",
|
||||
"serialize-javascript": "^3.1.0",
|
||||
"source-map": "^0.6.1",
|
||||
"terser": "^4.1.2",
|
||||
"webpack-sources": "^1.4.0",
|
||||
"worker-farm": "^1.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.5.5",
|
||||
"@babel/core": "^7.5.5",
|
||||
"@babel/preset-env": "^7.5.5",
|
||||
"@commitlint/cli": "^8.1.0",
|
||||
"@commitlint/config-conventional": "^8.1.0",
|
||||
"@webpack-contrib/defaults": "^5.0.2",
|
||||
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
||||
"babel-jest": "^24.8.0",
|
||||
"commitlint-azure-pipelines-cli": "^1.0.2",
|
||||
"cross-env": "^5.2.0",
|
||||
"del": "^4.1.1",
|
||||
"del-cli": "^1.1.0",
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"husky": "^3.0.2",
|
||||
"jest": "^24.8.0",
|
||||
"jest-junit": "^7.0.0",
|
||||
"lint-staged": "^9.2.1",
|
||||
"memory-fs": "^0.4.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^1.18.2",
|
||||
"standard-version": "^7.0.0",
|
||||
"uglify-js": "^3.6.0",
|
||||
"webpack": "^4.38.0"
|
||||
},
|
||||
"keywords": [
|
||||
"uglify",
|
||||
"uglify-js",
|
||||
"uglify-es",
|
||||
"terser",
|
||||
"webpack",
|
||||
"webpack-plugin",
|
||||
"minification",
|
||||
"compress",
|
||||
"compressor",
|
||||
"min",
|
||||
"minification",
|
||||
"minifier",
|
||||
"minify",
|
||||
"optimize",
|
||||
"optimizer"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue