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

dep-bundle-size

v0.1.3

Published

Yet another CLI client for BundlePhobia

Downloads

1

Readme

dep-bundle-size is a CLI client for BundlePhobia that scans the dependencies in package.json and shows the performance impact of each dependency, and supports monorepo such as pnpm workspaces, yarn workspaces, npm workspaces.

Features

  • 👀 Auto scan package.json
  • 🛠️ Work with single package, pnpm workspaces, yarn workspaces and npm workspaces
  • ⛓️ Constraint bundle size at dependency installation
  • 💡 Use actual installed version of the dependency to analyze
  • 💥 Display detailed scan results
  • 💎 Use the @clack/prompts for beautiful UI

How to install


pnpm add -g dep-bundle-size

// Or use it as dev dependency of a project
pnpm add dep-bundle-size -D

Usage

dep-bundle-size

Usage:
  $ dep-bundle-size [...packages]

Commands:
  [...packages]
  add <...packages>

For more info, run any command with the `--help` flag:
  $ dep-bundle-size --help
  $ dep-bundle-size add --help

Options:
  -i, --interactive  Select packages to scan
  -r, --recursive    Scan packages in every project of monorepo
  -d, --dir [dir]    Specify project root directory
  -h, --help         Display this message
  -v, --version      Display version number
  • dep-bundle-size will scan all dependencies under the project by default, We can manually select the dependencies to be scanned via --interactive option:
○  Select packages to scan.
│  classnames, react-dom
│
○  Scan ./ completed
╔════════════════════════════════════════════════════════════════════════╗
║                              Scan Results                              ║
╟──────────────────┬──────────┬────────────┬───────────────┬─────────────╢
║ Name             │ MIN      │ MIN + GZIP │ SLOW 3G       │ EMERGING 4G ║
╟──────────────────┼──────────┼────────────┼───────────────┼─────────────╢
║ [email protected] │ 717.00B  │ 431.00B    │ 8ms           │ 481μs       ║
╟──────────────────┼──────────┼────────────┼───────────────┼─────────────╢
║ [email protected] │ 130.48kB │ 41.99kB    │ 0.8398046875s │ 48ms        ║
╚══════════════════╧══════════╧════════════╧═══════════════╧═════════════╝
  • In addition to --interactive. We can also specify the packge to be scanned directly:
$ dep-bundle-size classnames react-dom

dep-bundle-size will get the actual installed version of the scanned dependencies under the project, and if a dependency is not installed, we will request the size information of the latest version instead.

dep-bundle-size add

Usage:
  $ dep-bundle-size add <...packages>

Options:
  -w, --warning    Use warning instead throw an error if
  -d, --dir [dir]  Specify project root directory
  -h, --help       Display this message

The add command is mainly used to limit the size of installed dependencies. We can configure size limits(bytes) in package.json:

{
  "name": "@pkg/foo",
  "dependencies": {},
  "bundle-phobia": {
    "max-size": 10,
    "max-gzip-size": 100
    "max-overall-size": 1000000
    "max-overall-gzip-size": 1000000
  }
}

When installing dependencies(eg.dep-bundle-size add react react-dom), we will first check if the dependencies meets the configured constraints, and if it does not, an error will be reported directly:

$ dep-bundle-size add styled-components

◓  Checking constraints
Error:  Error: Can not install [email protected](33.39kB), Since their max-size is larger than the configured(10.00B).

If we want to continue the installation if the constraints are not met, we can use the --warning option so that dep-bundle-size will automatically detect the package manager used by the project to complete the installation of the dependencies:

$ dep-bundle-size add styled-components -w

◓  Checking constraints
Warn:  Can not install [email protected](33.39kB), Since their max-size is larger than the configured(10.00B).
│
○  Checking constraints completed
Info:  Add deps(npm install styled-components)

Credits

This project is highly inspired by bundle-phobia-cli and uses BundlePhobia as backend service , thanks to these awesome projects. ♪(・ω・)ノ

License

MIT License