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 🙏

© 2024 – Pkg Stats / Ryan Hefner

bundle-report

v1.2.2

Published

Track your bundle size over time

Downloads

69

Readme

 

Build Status

minimal setup

npm install bundle-report --save-dev

 

usage

Add it to your scripts in package.json

"scripts": {
  "test": "bundle-report"
}

 

Or you can use npx with NPM 5.2+.

npx bundle-report

configuration

Specify configuration through any method below. Files may be yaml, json, or js modules, and package.json may contain an object.

  1. Specify cli option --config [file name] to point at any config file.
  2. Create a config file ".bundlereport.rc" (see the exmaple in src/default.bundlereport.rc)
  3. Specify package.json key "bundleReport" with a string config file path.
  4. Add a settings object in package.json under key "bundleReport".
  5. Specify property "config" in the object at package.json
Basic Settings
{
  "name": "your cool library",
  "version": "1.1.2",
  "bundleReport": {
    "files": [
      {
        "path": "./dist.js",
       "maxSize": "3 kB"
      } 
    ]
  }
}
globs

bundle-report also supports glob patterns

This makes it great for using with applications that are bundled with another tool. It will match multiple files if necessary and create a new row for each file.

{
  "bundleReport": {
    "files": [
      {
        "path": "./dist/vendor-*.js",
        "maxSize": "3 kB"
      },
      {
        "path": "./dist/chunk-*.js",
        "maxSize": "3 kB"
      }
    ]
  }
}
named output

Some bundle files may contain irrelevant path info, or simply be too long, or contain hashes (which prevents comparing built-to-build). There are two ways to specify another name for the file. For more examples, see this project's package.json.

  1. Each item in the files option may contain a name property. For globs with multiple entries, this name will receive a numeral suffix
{
  "bundleReport": {
    "files": [
      {"path": "webpack-with-hash*.js", "maxSize": "3KB", "name": "webpack"}
    ]
  }
}
  1. You may specify a replace pattern for substring or regex replacement. The pattern may be specified at the top level config or for each entry in 'files'. The replacement will be applied to the path of the file (after glob expansion), and the result will become the name property for that file. (name is superceded by replace)

The replace options requires two properties, pattern and replacement. These properties become the first and second argument to String.prototype.replace. If pattern contains an array, then its first element and optional second element are passed as arguments to new RegExp. (This permits RegExp via package.json or yaml strings. If you use a module as configuration in progress, then you may specify a RegExp directly, as well as a function for the replacement property)

This example uses a regular expression to name each file starting with re, and removes its path and file extension.

{
  "bundleReport": {
    "files": [
      {
        "path": "./src/re*.js",
        "maxSize": "2KB",
        "replace": {
          "pattern": ["\\./src/(.*)\\.js"],
          "replacement": "$1"
        }
      }
    ]
  }
}

2) build status

build status

Bundle report uses the storage server of its fork source, bundlesize. (Old references still exist.) buildsize hosts a server store that both 1.) uses the Github Status API to mark commits and PRs, and 2.) saves the results from the previous build, if that build is "master". bundle-report allows this storage to apply to any branch name via the baseBranch config option. The ability to check against any merge target is on the TODO list.

To use the size comparison (via bundlesize):

Currently works for Travis CI, CircleCI, Wercker, and Drone.

 

CLI

example usage:

bundle-report -f "dist/*.js" -s 20kB

For more granular configuration, we recommend configuring it in the package.json (documented above).

TODO

  • Work with other CI tools (AppVeyor, etc.)
  • Automate setup (setting env_var)

 

similar projects

license

MIT © sethbattin