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

bundlephobia-tool

v1.0.11

Published

cli tool to analyze npm packages with bundlephobia

Downloads

37

Readme

BundlePhobia Tool

BundlePhobia Tool License Node.js

BundlePhobia Tool is a powerful command-line tool that interacts with BundlePhobia APIs to help you analyze the size and dependencies of your npm packages directly from your terminal. Whether you're looking to check the size of a specific package, explore its dependencies, or analyze all dependencies listed in your package.json, BundlePhobia Tool has you covered.

Table of Contents

Features

  • Check Package Size: Quickly view the minified and gzipped sizes of any npm package.
  • View Package Information: Fetch detailed information about a package, including dependencies, version history, and more.
  • List Dependencies: Retrieve a list of all dependencies for a specific package.
  • Analyze package.json: View sizes of all dependencies listed in your project's package.json.
  • Search Similar Packages: Discover packages similar to the one you're interested in.
  • Open in Browser: Easily open the package details on BundlePhobia's website.

Installation

Ensure you have Node.js installed (version 14 or higher).

Install BundlePhobia Tool globally using npm or yarn:

# Using npm
npm install -g bundlephobia-tool

# Using yarn
yarn global add bundlephobia-tool

Note: You might need to restart your terminal or ensure that your global node_modules are in your system's PATH.

Usage

BundlePhobia Tool provides various commands and flags to interact with npm packages. Below are the primary ways to use the tool.

Basic Commands

bp <package-name> [flag]
  • <package-name>: The name of the npm package you want to analyze.
  • [flag]: Optional flags to modify the command's behavior.

Flags

  • --info, -i: Fetch detailed information about the package.
  • --dependencies, -d: List all dependencies of the package.
  • --package.json, -j: Analyze all dependencies listed in your package.json.
  • --peer, -p: List peer dependencies of the package.
  • --raw, -r: Output raw JSON data of the package.
  • --browse, -b: Open the package details in your default browser.
  • --history, -h: View the version history of the package.
  • --similar, -s: Find packages similar to the specified package.

Examples

  1. View Package Size

    bp react

    Output:

    [email protected]
    • 30.5 kB minified
    • 10.2 kB gzipped
  2. Fetch Package Information

    bp react --info

    Output:

    [email protected]
    {
      project: "react",
      version: 18.2.0,
      description: "React is a JavaScript library for building user interfaces.",
      dependents: 80000,
      dependencies: 3,
      devDepends: 2,
      types: "@types/react",
      license: "MIT",
      keywords: "react, ui, library, javascript",
      deprecated: false,
      popular: true,
      downloads: 5000000,
      crawled: "2024-04-01T12:34:56Z",
      authors: "Jordan Walke, Facebook"
    }
  3. List All Dependencies of a Package

    bp react --dependencies

    Output:

    [email protected]
    react-dom: 25.3 kB
    scheduler: 5.1 kB
  4. Analyze All Dependencies in package.json

    bp --package.json

    Output:

    ✔ Fetched data for packages in package.json
    ✔ [email protected]
            • 456.2 kB minified
            • 206.0 kB gzipped
    ✔ [email protected]
            • 48.7 kB minified
            • 12.4 kB gzipped
    ✔ [email protected]
            • 0.7 kB minified
            • 0.4 kB gzipped
  5. Open Package in Browser

    bp react --browse

    Output:

    opened [email protected] in your default browser
  6. View Version History of a Package

    bp react --history

    Output:

    react 5 versions
    [email protected]
    25.0 kB minified
    8.0 kB gzipped
    
    [email protected]
    25.5 kB minified
    8.1 kB gzipped
    
    ...
  7. Find Similar Packages

    bp react --similar

    Output:

    react 3 similar pkgs
    [email protected]
    [email protected]
    [email protected]

Help

If you need assistance or forgot the commands, simply run:

bp

Output:

bundlephobia-tool
bp open <package> <view package size of latest open version>
bp colors --info <fetch information about the colors package>
bp orb --dependencies <list all dependencies of the orb package>
bp --package.json <view sizes of all packages in package.json>

API Endpoints

BundlePhobia Tool interacts with several BundlePhobia API endpoints to fetch the required data:

  • Basic Size: https://bundlephobia.com/api/size?package=<package-name>
  • History: https://bundlephobia.com/api/package-history?package=<package-name>
  • Similar Packages: https://bundlephobia.com/api/similar-packages?package=<package-name>
  • Package Information: https://ofcncog2cu-dsn.algolia.net/1/indexes/npm-search/<package-name>?x-algolia-application-id=OFCNCOG2CU&x-algolia-api-key=YOUR_API_KEY

Note: Ensure you handle API keys securely if required.

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the Repository

  2. Create a Feature Branch

    git checkout -b feature/YourFeature
  3. Commit Your Changes

    git commit -m "Add some feature"
  4. Push to the Branch

    git push origin feature/YourFeature
  5. Open a Pull Request

Please ensure your code adheres to the project's coding standards and includes relevant tests.

License

This project is licensed under the MIT License.