npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webpack-bundle-content-validator

v0.2.0

Published

Webpack plugin and CLI tool for Webpack bundle content validation

Readme

Build Status Coverage Status Known Vulnerabilities NPM version

Webpack Bundle Content Validator

Webpack plugin and CLI tool for Webpack bundle content validation.

  • ✔️ check if your Webpack bundle contains mandatory dependencies and doesn't contain disallowed ones
  • ⚠️ print warning in console or fail whole build process when validation is not successful
  • 🤖 use as Webpack plugin or CLI tool

This plugin/tool is compatible with Webpack 4. Compatibility with older versions of Webpack was not tested yet, but there might be some issues with that due to the fact that structure of Webpack Stats object was changed in Webpack 4.

Note: This is early version of this project. Feedback and suggestions are appreciated!

Background

We're using internal package of vendor libraries in my project. We wanted to ensure that none of dependencies provided by vendor ends up in bundles representing our applications. Therefore, I wrote this tool to validate content of Webpack bundle against list of mandatory and disallowed dependencies, and open sourced it. We're using it as Webpack plugin during development and as CLI tool in CI/CD process.

Usage

You can download this project as a package from NPM:

npm install --save-dev webpack-bundle-content-validator

You can also download this project as a source code from GitHub and build it yourself (compiled project will be placed in lib directory):

npm run build

As Webpack plugin

In order to use it as Webpack plugin, import it in your Webpack configuration, and add it to plugins section of Webpack's configuration file.

const WebpackBundleContentValidatorPlugin = require('webpack-bundle-content-validator/lib/plugin');

module.exports = {
  // rest of your configuration
  plugins: [
    // rest of your plugins
    new WebpackBundleContentValidatorPlugin(/* options */),
  ]
}

Options

| Name | Description | Default value | |-|-|-| | mandatoryDependencies | Array of names of dependencies without which validation will be unsuccessful. | [] | | disallowedDependencies | Array of names of dependencies with which validation will be unsuccessful. | [] | | failOnInvalid | If set to false, unsuccessful validation will print warning message in console, but bundle will be compiled. If set to true, unsuccessful validation will print error in console and exit process; bundle will not be compiled. | false |

Example

const WebpackBundleContentValidatorPlugin = require('webpack-bundle-content-validator/lib/plugin');

module.exports = {
  // rest of your configuration
  plugins: [
    // rest of your plugins
    new WebpackBundleContentValidatorPlugin({
      mandatoryDependencies: ['preact'],
      disallowedDependencies: ['react', 'react-dom'],
      failOnInvalid: true,
    }),
  ]
}

As CLI tool

In order to use it as CLI tool, you need to produce Webpack Stats object first. This can be done with following command:

webpack --json > stats.json

Make sure that the file contains valid JSON! If yes, you can pass it to Webpack Bundle Content Validator.

node ./node_modules/webpack-bundle-content-validator/lib/cli.js -s ./stats.json

Options

| Name | Description | Default value | |-|-|-| | -s, --stats | Path to JSON file with Webpack Stats object. | stats.json | | -m, --mandatory | Array of names of dependencies without which validation will be unsuccessful. | [] | | -d, --disallowed | Array of names of dependencies with which validation will be unsuccessful. | [] | | -f, --fail | If set to false, unsuccessful validation will print warning message in console, but bundle will be compiled. If set to true, unsuccessful validation will print error in console and exit process; bundle will not be compiled. | false |

Example

./node_modules/webpack-bundle-content-validator/lib/cli.js -s ./my-stats.json -m preact -d react,react-dom -f

TODO

  • install CLI tool globally and make it run with npx