Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

bhovhannes/bundle-validator

Repository files navigation

Bundle Validator

NPM packages MIT License

A monorepo containing CLI tool for validating minified bundle content and related packages.

All packages in this repo are published under @bundle-validator scope. For example, @bundle-validator/cli or @bundle-validator/plugin-bundle-size

Usage

First, install bundle validator either globally:

npm install -g @bundle-validator/cli

or add it to your project as a devDependency:

npm install --save-dev @bundle-validator/cli

Second, create a configuration. Bundle validator will start to search in your current directory and up the directory tree for the following:

  • a bv property in package.json
  • a .bvrc file in JSON or YAML format
  • a .bvrc.json, .bvrc.yaml, .bvrc.yml, .bvrc.js, or .bvrc.cjs file
  • a bv.config.js or bv.config.cjs CommonJS module exporting an object

And last, run the tool's check subcommand, providing glob patterns for finding files tool will validate and using -c, --config command line argument to specify a path to the configuration file, i.e.:

bv check --config "./tools/.bvrc.json" "./dist/*.js"

See examples section for more usage examples.

Configuration

plugins

Configuration has only one required option - plugins. By that option one should specify which plugins tool should use to validate provided set of files.
For example:

{
  "plugins": [
    [
      "@bundle-validator/plugin-bundle-size",
      {
        "maxSize": "128 KB"
      }
    ],
    "@bundle-validator/plugin-no-ie11"
  ]
}

Here, we specified 2 plugins - @bundle-validator/plugin-bundle-size and @bundle-validator/plugin-no-ie11. Some plugins may require options, in this example we provided maxSize option for @bundle-validator/plugin-bundle-size and no options for @bundle-validator/plugin-no-ie11.

Plugins are regular packages and should be installed from NPM. Official plugins are published under @bundle-validator scope.

reporter and reporterOptions

To customize tool output, one can specify the name of reporter and, optional configuration for reporter using reporterOptions option. All mocha reporters are supported. Tool uses spec reporter by default.
For example:

{
  "reporter": "tap",
  "plugins": ["@bundle-validator/plugin-no-ie11"]
}

Examples

Multiple pattern arguments, no config option

$ npm install -g @bundle-validator/cli
$ LOG_LEVEL=debug bv check "./dist/*.js" "./output/**/*.min.js"

One pattern argument, config option specified

$ npm install -g @bundle-validator/cli
$ LOG_LEVEL=debug bv check --config ./tools/bv.config.js "./dist/*.js"

Contributing

See our Contributing Guide.
If you want to create a new plugin, please go through Plugins.

Contributors

  • Amy Zhao

License

MIT (http://www.opensource.org/licenses/mit-license.php)

About

A tool for validating minified bundle content

Resources

License

Stars

Watchers

Forks