{"name":"webpack-stats-plugin","version":"1.0.3","description":"Webpack stats plugin","main":"index.js","repository":{"type":"git","url":"git+https://github.com/FormidableLabs/webpack-stats-plugin.git"},"keywords":["webpack"],"author":{"name":"Ryan Roemer","email":"ryan.roemer@formidable.com"},"license":"MIT","bugs":{"url":"https://github.com/FormidableLabs/webpack-stats-plugin/issues"},"scripts":{"lint":"eslint .","test":"yarn run test:clean && yarn run test:build && yarn run test:run","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","check":"yarn run lint && yarn run test"},"dependencies":{},"devDependencies":{"babel-eslint":"^10.1.0","builder":"^5.0.0","chai":"^4.2.0","eslint":"^7.6.0","eslint-config-formidable":"^4.0.0","eslint-plugin-filenames":"^1.3.2","eslint-plugin-import":"^2.22.0","eslint-plugin-promise":"^4.2.1","mocha":"^8.1.1","pify":"^5.0.0","webpack":"file:test/packages/webpack","webpack-cli":"file:test/packages/webpack-cli","webpack1":"file:test/packages/webpack1","webpack2":"file:test/packages/webpack2","webpack3":"file:test/packages/webpack3","webpack4":"file:test/packages/webpack4","webpack5":"file:test/packages/webpack5"},"gitHead":"4efe1a316805728a7a0404ab0974965cc4c90437","homepage":"https://github.com/FormidableLabs/webpack-stats-plugin#readme","_id":"webpack-stats-plugin@1.0.3","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-tV/SQHl6lKfBahJcNDmz8JG1rpWPB9NEDQSMIoL74oVAotdxYljpgIsgLzgc1N9QrtA9KEA0moJVwQtNZv2aDA==","shasum":"0f64551a0b984b48a9e7acdee32e3cfda556fe51","tarball":"http://registry-npm.ywwl.com/webpack-stats-plugin/download/webpack-stats-plugin-1.0.3.tgz","fileCount":6,"unpackedSize":20310,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf5jdQCRA9TVsSAnZWagAABBIP/2Au2T2SdstlSuBGUdYl\no1NLFWBrBHphZt0DReTntYIyXFO1kQruumIDlfMd5PABjObZVrWCT4BAYGld\nLhM9dKpJHGemQbANK3UBMcB7ckLtig1wmy/gVyjOssaBrX2ubMxER997wxGG\nd6YwyEkN7L1kq75oNtwdLYo+2VDwoA5dHu24F/rJQWHoYtJFrY8T626HGJDM\nfFb515akLfLTrD4F2D/Om/8LXHT/7Wd9iLSeitC7inbS+sUgtVEkEdVIq4x3\nWIBaRlAhUtlMSh15wuQKRDCDGX5/uoNayWGtCCLZhEOUKtm5IOajG2UAghe/\nuT9SG9HNcWSUklNz4oz+DfSD7dEr2RPZiXHa/qJPKfguW1+y9oEVoHDmVy+C\nTQM5ecEiAm28KgceV8ny6PPtJpwqpKhVLEDv/yVT8RUSjqLRSpfo6Mu0ZUZ+\nsq+7AwbFxTfJQSP6b3tE0THZxyzJ1WJbGpnlHFqhc6qZv+edhweKvdDxGt+p\nZrX4STL5OEGfju38pRDqrj+cwRJ/vFMe+pD6sQak/51k26ZxmSGX8AG9EiBj\n1yK7XeCaKV9yN3B20gWYBwz278Q8fhLwLttDLlImVnVXd0VYbrH2ijY5fcRD\nGp8Lnr0aP95kTTdoPXx9ne+XdVGxoWCcHciY8xd9HT6187snlx1Mn3XRf+MG\njJI7\r\n=+z39\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICR+4x8jsuNUWh2xKeM4KjC+enWMj/Ra+6SFM0nLQTNFAiAG0wwUie39t6bJuLSMsLk6DP6S+wjPZRBjocRgGCixqg=="}],"size":6792,"noattachment":false,"key":"/webpack-stats-plugin/-/webpack-stats-plugin-1.0.3.tgz"},"_npmUser":{"name":"ryan.roemer","email":"ryan@loose-bits.com"},"directories":{},"maintainers":[{"name":"manosim","email":"hello@manos.im"},{"name":"michaelmerrill","email":"michael@michaelmerrill.me"},{"name":"sarmeyer","email":"sarahmichellemeyer@gmail.com"},{"name":"mariano-formidable","email":"mariano.martinez@formidable.com"},{"name":"carlospaelinck","email":"me@carlos.dev"},{"name":"parkerziegler","email":"parker.ziegler@formidable.com"},{"name":"ryanisinallofus","email":"ryanrray@gmail.com"},{"name":"samwhale","email":"samuelestrella226@gmail.com"},{"name":"bmathews","email":"spoonart@gmail.com"},{"name":"ryan.roemer","email":"ryan@loose-bits.com"},{"name":"paulathevalley","email":"lavalle.paula@gmail.com"},{"name":"thekenwheeler","email":"ken_wheeler@me.com"},{"name":"tptee","email":"tyler@tylerpaulthompson.com"},{"name":"formidable-owner","email":"admin@formidablelabs.com"},{"name":"ebrillhart","email":"emma.brillhart@gmail.com"},{"name":"mhink","email":"mhink1103@gmail.com"},{"name":"stefvhuynh","email":"huynh.stefan@gmail.com"},{"name":"chrisbolin","email":"bolin.chris@gmail.com"},{"name":"eastridge","email":"ryan@eastridge.me"},{"name":"exogen","email":"exogen@gmail.com"},{"name":"boygirl","email":"lauren.eastridge@formidable.com"},{"name":"coopy","email":"per@sproutlab.com"},{"name":"philpl","email":"phil@kitten.sh"},{"name":"andyrichardson","email":"andy.john.richardson@gmail.com"},{"name":"hartzis","email":"brianhartz@gmail.com"},{"name":"mfulgham","email":"monet.fulgham@formidable.com"},{"name":"jmcbee1","email":"jmcbee1@gmail.com"},{"name":"formidablelabs","email":"npm@formidablelabs.com"},{"name":"carbonrobot","email":"carbonrobot@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-stats-plugin_1.0.3_1608922959791_0.12403963682358543"},"_hasShrinkwrap":false,"readme":"[![Webpack Stats Plugin — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/webpack-stats-plugin/master/webpack-stats-plugin-Hero.png)](https://formidable.com/open-source/)\n\n[![npm version][npm_img]][npm_site]\n[![Actions Status][actions_img]][actions_site]\n[![MIT license][lic_img]][lic_site]\n[![Maintenance Status][maintenance_image]](#maintenance-status)\n\nThis plugin will ingest the webpack [stats](https://webpack.js.org/configuration/stats/#stats) object, process / transform the object and write out to a file for further consumption.\n\nThe most common use case is building a hashed bundle and wanting to programmatically refer to the correct bundle path in your Node.js server.\n\n## Installation\n\nThe plugin is available via [npm](https://www.npmjs.com/package/webpack-stats-plugin):\n\n```sh\n$ npm install --save-dev webpack-stats-plugin\n$ yarn add --dev webpack-stats-plugin\n```\n\n## Examples\n\nWe have example webpack configurations for all versions of webpack. See., e.g. [`test/scenarios/webpack5/webpack.config.js`](test/scenarios/webpack5/webpack.config.js).\n\n### CLI\n\nIf you are using `webpack-cli`, you can enable with:\n\n```sh\n$ webpack-cli --plugin webpack-stats-plugin/lib/stats-writer-plugin\n```\n\n### Basic\n\nA basic `webpack.config.js`-based integration:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    // Everything else **first**.\n\n    // Write out stats file to build directory.\n    new StatsWriterPlugin({\n      filename: \"stats.json\", // Default\n    }),\n  ],\n};\n```\n\n### Custom `stats` Configuration\n\nThis option is passed to the webpack compiler's [`getStats().toJson()`](https://webpack.js.org/api/node/#statstojsonoptions) method.\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      stats: {\n        all: false,\n        assets: true,\n      },\n    }),\n  ],\n};\n```\n\n### Custom Transform Function\n\nThe transform function has a signature of:\n\n```js\n/**\n * Transform skeleton.\n *\n * @param {Object} data           Stats object\n * @param {Object} opts           Options\n * @param {Object} opts.compiler  Current compiler instance\n * @returns {String}              String to emit to file\n */\nfunction (data, opts) {}\n```\n\nwhich you can use like:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      transform(data, opts) {\n        return JSON.stringify(\n          {\n            main: data.assetsByChunkName.main[0],\n            css: data.assetsByChunkName.main[1],\n          },\n          null,\n          2\n        );\n      },\n    }),\n  ],\n};\n```\n\n### Promise transform\n\nYou can use an asynchronous promise to transform as well:\n\n```js\nconst { StatsWriterPlugin } = require(\"webpack-stats-plugin\");\n\nmodule.exports = {\n  plugins: [\n    new StatsWriterPlugin({\n      filename: \"stats-transform-promise.json\",\n      transform(data) {\n        return Promise.resolve().then(() =>\n          JSON.stringify(\n            {\n              main: data.assetsByChunkName.main,\n            },\n            null,\n            INDENT\n          )\n        );\n      },\n    }),\n  ],\n};\n```\n\n## Plugins\n\n- [`StatsWriterPlugin(opts)`](#statswriterplugin-opts-)\n\n### `StatsWriterPlugin(opts)`\n\n- **opts** (`Object`) options\n- **opts.filename** (`String|Function`) output file name (Default: `\"stats.json\"`)\n- **opts.fields** (`Array`) fields of stats obj to keep (Default: `[\"assetsByChunkName\"]`)\n- **opts.stats** (`Object|String`) stats config object or string preset (Default: `{}`)\n- **opts.transform** (`Function|Promise`) transform stats obj (Default: `JSON.stringify()`)\n- **opts.emit** (`Boolean`) add stats file to webpack output? (Default: `true`)\n\nStats writer module.\n\nStats can be a string or array (we'll have an array due to source maps):\n\n```js\n\"assetsByChunkName\": {\n  \"main\": [\n    \"cd6371d4131fbfbefaa7.bundle.js\",\n    \"../js-map/cd6371d4131fbfbefaa7.bundle.js.map\"\n  ]\n},\n```\n\n**`fields`, `stats`**\n\nThe stats object is **big**. It includes the entire source included in a bundle. Thus, we default `opts.fields` to `[\"assetsByChunkName\"]` to only include those. However, if you want the _whole thing_ (maybe doing an `opts.transform` function), then you can set `fields: null` in options to get **all** of the stats object.\n\nYou may also pass a custom stats config object (or string preset) via `opts.stats` in order to select exactly what you want added to the data passed to the transform. When `opts.stats` is passed, `opts.fields` will default to `null`.\n\nSee:\n\n- https://webpack.js.org/configuration/stats/#stats\n- https://webpack.js.org/api/node/#stats-object\n\n**`filename`**\n\nThe `opts.filename` option can be a file name or path relative to `output.path` in webpack configuration. It should not be absolute. It may also be a function, in which case it will be passed the current compiler instance and expected to return a filename to use.\n\n**`transform`**\n\nBy default, the retrieved stats object is `JSON.stringify`'ed:\n\n```javascript\nnew StatsWriterPlugin({\n  transform(data) {\n    return JSON.stringify(data, null, 2);\n  },\n});\n```\n\nBy supplying an alternate transform you can target _any_ output format. See [`test/scenarios/webpack5/webpack.config.js`](test/scenarios/webpack5/webpack.config.js) for various examples including Markdown output.\n\n- **Warning**: The output of `transform` should be a `String`, not an object. On Node `v4.x` if you return a real object in `transform`, then webpack will break with a `TypeError` (See [#8](https://github.com/FormidableLabs/webpack-stats-plugin/issues/8)). Just adding a simple `JSON.stringify()` around your object is usually what you need to solve any problems.\n\n**Internal notes**\n\nIn modern webpack, the plugin uses the [`processAssets`](https://webpack.js.org/api/compilation-hooks/#processassets) compilation hook if available when adding the stats object file to the overall compilation to write out along with all the other webpack-built assets. This is the [last possible place](https://github.com/webpack/webpack/blob/f2f998b58362d5edc9945a48f8245a3347ad007c/lib/Compilation.js#L2000-L2007) to hook in before the compilation is frozen in future webpack releases.\n\nIn earlier webpack, the plugin uses the much later [`emit`](https://webpack.js.org/api/compiler-hooks/#emit) compiler hook. There are technically some assets/stats data that could be added after `processAssets` and before `emit`, but for most practical uses of this plugin users shouldn't see any differences in the usable data produced by different versions of webpack.\n\n## Maintenance Status\n\n**Active:** Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.\n\n[npm_img]: https://badge.fury.io/js/webpack-stats-plugin.svg\n[npm_site]: http://badge.fury.io/js/webpack-stats-plugin\n[actions_img]: https://github.com/FormidableLabs/webpack-stats-plugin/workflows/CI/badge.svg\n[actions_site]: https://github.com/FormidableLabs/webpack-stats-plugin/actions\n[lic_img]: https://img.shields.io/npm/l/webpack-stats-plugin.svg?color=brightgreen&style=flat\n[lic_site]: https://github.com/FormidableLabs/webpack-stats-plugin/blob/main/LICENSE.txt\n[maintenance_image]: https://img.shields.io/badge/maintenance-active-green.svg?color=brightgreen&style=flat\n","publish_time":1608922959914,"_cnpm_publish_time":1608922959914,"dist-tags":{"latest":"1.1.3"}}