Socket
Socket
Sign inDemoInstall

terser-webpack-plugin

Package Overview
Dependencies
8
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.3 to 2.3.0

dist/Webpack4Cache.js

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.3.0](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v2.2.3...v2.3.0) (2019-12-12)
### Features
* support webpack@5 cache ([3649b3d](https://github.com/webpack-contrib/terser-webpack-plugin/commit/3649b3d0bf697288661676b47b33ae88226eb6f5))
### [2.2.3](https://github.com/webpack-contrib/terser-webpack-plugin/compare/v2.2.2...v2.2.3) (2019-12-11)

@@ -7,0 +14,0 @@

44

dist/index.js

@@ -156,2 +156,6 @@ "use strict";

static isWebpack4() {
return _webpack.version[0] === '4';
}
apply(compiler) {

@@ -222,6 +226,9 @@ const {

if (this.options.extractComments) {
commentsFilename = this.options.extractComments.filename || '[file].LICENSE[query]'; // Todo remove this in next major release
commentsFilename = this.options.extractComments.filename || '[file].LICENSE[query]';
if (typeof commentsFilename === 'function') {
commentsFilename = commentsFilename.bind(null, file);
if (TerserPlugin.isWebpack4()) {
// Todo remove this in next major release
if (typeof commentsFilename === 'function') {
commentsFilename = commentsFilename.bind(null, file);
}
}

@@ -254,2 +261,3 @@

const task = {
asset,
file,

@@ -264,13 +272,22 @@ input,

if (this.options.cache) {
const defaultCacheKeys = {
if (TerserPlugin.isWebpack4()) {
if (this.options.cache) {
const defaultCacheKeys = {
terser: _package.default.version,
// eslint-disable-next-line global-require
'terser-webpack-plugin': require('../package.json').version,
'terser-webpack-plugin-options': this.options,
nodeVersion: process.version,
filename: file,
contentHash: _crypto.default.createHash('md4').update(input).digest('hex')
};
task.cacheKeys = this.options.cacheKeys(defaultCacheKeys, file);
}
} else {
task.cacheKeys = {
terser: _package.default.version,
// eslint-disable-next-line global-require
'terser-webpack-plugin': require('../package.json').version,
'terser-webpack-plugin-options': this.options,
nodeVersion: process.version,
filename: file,
contentHash: _crypto.default.createHash('md4').update(input).digest('hex')
'terser-webpack-plugin-options': this.options
};
task.cacheKeys = this.options.cacheKeys(defaultCacheKeys, file);
}

@@ -288,4 +305,7 @@

const CacheEngine = TerserPlugin.isWebpack4() ? // eslint-disable-next-line global-require
require('./Webpack4Cache').default : // eslint-disable-next-line global-require
require('./Webpack5Cache').default;
const taskRunner = new _TaskRunner.default({
cache: this.options.cache,
cache: new CacheEngine(compilation, this.options),
parallel: this.options.parallel

@@ -400,3 +420,3 @@ });

if (_webpack.javascript && _webpack.javascript.JavascriptModulesPlugin) {
if (!TerserPlugin.isWebpack4()) {
const hooks = _webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation);

@@ -403,0 +423,0 @@

@@ -10,6 +10,2 @@ "use strict";

var _cacache = _interopRequireDefault(require("cacache"));
var _findCacheDir = _interopRequireDefault(require("find-cache-dir"));
var _jestWorker = _interopRequireDefault(require("jest-worker"));

@@ -27,13 +23,6 @@

constructor(options = {}) {
this.options = options;
this.cacheDir = TaskRunner.getCacheDirectory(this.options.cache);
this.numberWorkers = TaskRunner.getNumberWorkers(this.options.parallel);
this.cache = options.cache;
this.numberWorkers = TaskRunner.getNumberWorkers(options.parallel);
}
static getCacheDirectory(cache) {
return cache === true ? (0, _findCacheDir.default)({
name: 'terser-webpack-plugin'
}) || _os.default.tmpdir() : cache;
}
static getNumberWorkers(parallel) {

@@ -75,4 +64,4 @@ // In some cases cpus() returns undefined

if (this.cacheDir && !result.error) {
return _cacache.default.put(this.cacheDir, (0, _serializeJavascript.default)(task.cacheKeys), JSON.stringify(result)).then(() => result, () => result);
if (this.cache.isEnabled() && !result.error) {
return this.cache.store(task, result).then(() => result, () => result);
}

@@ -83,6 +72,4 @@

if (this.cacheDir) {
return _cacache.default.get(this.cacheDir, (0, _serializeJavascript.default)(task.cacheKeys)).then(({
data
}) => JSON.parse(data), enqueue);
if (this.cache.isEnabled()) {
return this.cache.get(task).then(data => data, enqueue);
}

@@ -89,0 +76,0 @@

{
"name": "terser-webpack-plugin",
"version": "2.2.3",
"version": "2.3.0",
"description": "Terser plugin for webpack",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -144,2 +144,4 @@ <div align="center">

> ⚠ Doesn't work with webpack 5!
Type: `Boolean|String`

@@ -193,2 +195,4 @@ Default: `true`

> ⚠ Doesn't work with webpack 5!
Type: `Function<(defaultCacheKeys, file) -> Object>`

@@ -496,2 +500,4 @@ Default: `defaultCacheKeys => defaultCacheKeys`

filename: (file, fileData) => {
// ⚠ webpack 5: there is only fileData parameter
// A file can contain a query string (for example when you have `output.filename: '[name].js?[chunkhash]'`)

@@ -529,2 +535,4 @@ // You must consider this

filename: (file, fileData) => {
// ⚠ webpack 5: there is only fileData parameter
// A file can contain a query string (for example when you have `output.filename: '[name].js?[chunkhash]'`)

@@ -549,3 +557,3 @@ // You must consider this

Available placeholders: `[file]`, `[query]` and `[filebase]`.
Available placeholders: `[file]`, `[query]` and `[filebase]` (`[base]` for webpack 5).

@@ -596,2 +604,4 @@ The file where the extracted comments will be stored.

filename: (file, fileData) => {
// ⚠ webpack 5: there is only fileData parameter
// A file can contain a query string (for example when you have `output.filename: '[name].js?[chunkhash]'`)

@@ -598,0 +608,0 @@ // You must consider this

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc