webpack-stats-plugin
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -55,2 +55,3 @@ "use strict"; | ||
* @param {Function|Promise} opts.transform transform stats obj (Default: `JSON.stringify()`) | ||
* @param {Boolean} opts.emit add stats file to webpack output? (Default: `true`) | ||
* | ||
@@ -67,2 +68,3 @@ * @api public | ||
this.opts.transform = opts.transform || DEFAULT_TRANSFORM; | ||
this.opts.emit = opts.emit !== false; | ||
@@ -140,2 +142,17 @@ if (typeof opts.stats !== "undefined" && typeof opts.fields === "undefined") { | ||
.then((statsStr) => { | ||
// Handle errors. | ||
if (err) { | ||
curCompiler.errors.push(err); | ||
// eslint-disable-next-line promise/no-callback-in-promise | ||
if (callback) { return void callback(err); } | ||
throw err; | ||
} | ||
// Short-circuit if not emitting. | ||
if (!this.opts.emit) { | ||
// eslint-disable-next-line promise/no-callback-in-promise,promise/always-return | ||
if (callback) { return void callback(); } | ||
return; | ||
} | ||
// Create simple equivalent of RawSource from webpack-sources. | ||
@@ -156,10 +173,2 @@ const statsBuf = Buffer.from(statsStr || "", "utf-8"); | ||
// Handle errors. | ||
if (err) { | ||
curCompiler.errors.push(err); | ||
// eslint-disable-next-line promise/no-callback-in-promise | ||
if (callback) { return void callback(err); } | ||
throw err; | ||
} | ||
const filename = typeof this.opts.filename === "function" | ||
@@ -166,0 +175,0 @@ ? this.opts.filename(curCompiler) |
{ | ||
"name": "webpack-stats-plugin", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Webpack stats plugin", | ||
@@ -25,6 +25,6 @@ "main": "index.js", | ||
"test": "yarn run test:clean && yarn run test:build && yarn run test:run", | ||
"test:run": "mocha 'test/**/*.spec.js'", | ||
"test:run": "mocha \"test/**/*.spec.js\"", | ||
"test:clean": "rm -rf test/scenarios/webpack*/build*", | ||
"test:build:single": "node node_modules/webpack${VERS}/index.js --config test/scenarios/webpack${VERS}/webpack.config${WP_EXTRA}.js", | ||
"test:build": "builder envs test:build:single '[{\"VERS\":1},{\"VERS\":2},{\"VERS\":3},{\"VERS\":4},{\"VERS\":5},{\"VERS\":5,\"WP_EXTRA\":\".contenthash\"}]' --buffer", | ||
"test:build": "builder envs test:build:single \"[{\\\"VERS\\\":1},{\\\"VERS\\\":2},{\\\"VERS\\\":3},{\\\"VERS\\\":4},{\\\"VERS\\\":5},{\\\"VERS\\\":5,\\\"WP_EXTRA\\\":\\\".contenthash\\\"}]\" --buffer", | ||
"check": "yarn run lint && yarn run test" | ||
@@ -42,2 +42,3 @@ }, | ||
"eslint-plugin-promise": "^4.2.1", | ||
"json-stream-stringify": "^3.0.0", | ||
"mocha": "^8.1.1", | ||
@@ -44,0 +45,0 @@ "pify": "^5.0.0", |
@@ -5,3 +5,3 @@ Webpack Stats Plugin | ||
[![npm version][npm_img]][npm_site] | ||
[![Build Status][trav_img]][trav_site] | ||
[![Actions Status][actions_img]][actions_site] | ||
[![MIT license][lic_img]][lic_site] | ||
@@ -139,2 +139,3 @@ [![Maintenance Status][maintenance_image]](#maintenance-status) | ||
* **opts.transform** (`Function|Promise`) transform stats obj (Default: `JSON.stringify()`) | ||
* **opts.emit** (`Boolean`) add stats file to webpack output? (Default: `true`) | ||
@@ -209,7 +210,6 @@ Stats writer module. | ||
[npm_site]: http://badge.fury.io/js/webpack-stats-plugin | ||
[trav]: https://travis-ci.com/ | ||
[trav_img]: https://api.travis-ci.com/FormidableLabs/webpack-stats-plugin.svg | ||
[trav_site]: https://travis-ci.com/FormidableLabs/webpack-stats-plugin | ||
[actions_img]: https://github.com/FormidableLabs/webpack-stats-plugin/workflows/CI/badge.svg | ||
[actions_site]: https://github.com/FormidableLabs/webpack-stats-plugin/actions | ||
[lic_img]: https://img.shields.io/npm/l/webpack-stats-plugin.svg?color=brightgreen&style=flat | ||
[lic_site]: https://github.com/FormidableLabs/webpack-stats-plugin/blob/main/LICENSE.txt | ||
[maintenance_image]: https://img.shields.io/badge/maintenance-active-green.svg?color=brightgreen&style=flat |
183
17701
18
5