{"name":"webpack-stats-plugin","version":"1.1.2","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":{"@changesets/cli":"^2.26.1","@svitejs/changesets-changelog-github-compact":"^0.1.1","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","json-stream-stringify":"^3.0.0","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":"be3d0e9106079d817c2d8b2483c16f446c4fd889","homepage":"https://github.com/FormidableLabs/webpack-stats-plugin#readme","_id":"webpack-stats-plugin@1.1.2","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-xEFDKoa96I+IDf6g9dmLx1QU33C00mpjm7lE1IaAeRENfvqqILi1bckoCfDPZOVu8xecPbOAhu+S3z7+AhBycQ==","shasum":"032e2b2ca015362b244ae651d5e0ca90da4ae779","tarball":"http://registry-npm.ywwl.com/webpack-stats-plugin/download/webpack-stats-plugin-1.1.2.tgz","fileCount":5,"unpackedSize":17816,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDrXBE1euZGK73JKf833Pk7c/x5JcYTaVRZ29vCz7VhyAiEAovoNu5slulnyNJBV5dVGMY+n7Hu9AuBCCo1TFV83tRU="}],"size":5977,"noattachment":false,"key":"/webpack-stats-plugin/-/webpack-stats-plugin-1.1.2.tgz"},"_npmUser":{"name":"formidablelabs","email":"npm@formidablelabs.com"},"directories":{},"maintainers":[{"name":"scottianstewart","email":"scott@scottstewart.co"},{"name":"keithluchtel","email":"keith.luchtel@formidable.com"},{"name":"ceceppa","email":"senesealessandro@gmail.com"},{"name":"robwalkerco","email":"hi@robwalker.co"},{"name":"gksander","email":"gksander93@gmail.com"},{"name":"sarahformidable","email":"sarah.wright@formidable.com"},{"name":"scott-rippey","email":"scott.william.rippey@gmail.com"},{"name":"yankovalera","email":"yankovalera@gmail.com"},{"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":"ryan.roemer","email":"ryan@loose-bits.com"},{"name":"formidable-owner","email":"admin@formidablelabs.com"},{"name":"eastridge","email":"ryan@eastridge.me"},{"name":"exogen","email":"exogen@gmail.com"},{"name":"jmcbee1","email":"jmcbee1@gmail.com"},{"name":"formidablelabs","email":"npm@formidablelabs.com"},{"name":"carbonrobot","email":"carbonrobot@gmail.com"},{"name":"masiddee","email":"mansoor@msiddeeq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-stats-plugin_1.1.2_1685723726099_0.4270618748676078"},"_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":1685723726286,"_cnpm_publish_time":1685723726286,"dist-tags":{"latest":"1.1.3"}}