• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“¦ Cli for the node BundlePhobia Service 😱

bundle-phobia-cli

npm Build Status codecov License: MIT

Cli for the node BundlePhobia Service

About

BundlePhobia is a tool to help you find the cost of adding a npm package to your bundle. It enables you to query package sizes.

Installation

Just use npm install -g bundle-phobia-cli and you're good to go!

Usage

Once installed you will have access to different executables:

  • bundle-phobia: to query package size. Just invoke it with a list of package names and some options.
  • bundle-phobia-install: to conditionally install package if weight constraint are respected. This is a wrapper on npm install

Note that you can specify a version along with the package range such as an instance exact version [email protected] or range version ora@^3.0.0.

Examples

# Query package size of lodash and react
$ bundle-phobia lodash react
β„Ή lodash (4.17.11) has 0 dependencies for a weight of 68.51KB (24.05KB gzipped)
β„Ή react (16.6.0) has 4 dependencies for a weight of 5.86KB (2.48KB gzipped)

# Perform conditional install of lodash
$ bundle-phobia-install lodash
β„Ή Applying a size limit of 100KB
β„Ή Proceed to installation of package lodash
+ [email protected]
added 1 package from 2 contributors and audited 1 package in 1.377s
found 0 vulnerabilities

Detailed Usage

bundle-phobia

Some option are available to control what stats are outputed by bundle-phobia.

By default an humain friendly output is provided, otherwise you can have a json output with the --json flag. In case you need just the size (or gzip) in a script, you can use the --[gzip]-size flag.

To control the packages to be queried, you can either provide them as an argument list, or you can refer a package.json file with the --package option. This would read the packages as dependencies. You can also provide a folder to -p (including .). This would look for package.json in that folder.

Options Summary
Usage: bundle-phobia <package-name> [other-package-names...]

Options:
  --version           Show version number                              [boolean]
  --package, -p       Provide a package.json to read dependencies       [string]
  --range, -r         Get a range of version (0 for all, 8 by default)  [number]
  --json, -j          Output json rather than a formater string        [boolean]
  --size, -s          Output just the module size                      [boolean]
  --gzip-size, -g     Output just the module gzip size                 [boolean]
  --dependencies, -d  Output just the number of dependencies           [boolean]
  --self              Output bundle-phobia stats                       [boolean]
  -h, --help          Show help                                        [boolean]

bundle-phobia-install

bundle-phobia-install offer three kind of flags:

  • flags to specify the size constraints
  • flags to specify behavior when constraints are not respected
  • npm install flags to control it's behavior

To control the size constraint of a single package: --max-size and --max-gzip-size aliases to -m and -M. To control the overall size of dependencies: --max-overall-size and --max-overall-gzip-size aliases to -o and -O. They expect a size argument that can be either a number or a number followed by a kB, mB unit.

By default if constraint is not respected, install with failed. If you want to perform anyway with just a warning use the --warn/-w flag. If you want to be asked what to do, use the --interactive/-i.

All other options will be conveyed to npm.

Limits can also be configured in the package.json by adding a bundle-phobia section with a max-[gzip-]size key.

{
  "name": "bundle-phobia-install-test",
  "dependencies": {},
  "bundle-phobia": {
    "max-size": "12kB",
    "max-overall-size": "1MB"
  }
}
Options Summary
Usage: bundle-phobia-install <package-name> [other-package-names...]

Options:
  --version            Show version number                             [boolean]
  --warn, -w           Install despite of negative check but warn about
                       predicate violation                             [boolean]
  --interactive, -i    Ask for override in case of predicate violation [boolean]
  --max-size, -m       Size threeshold of individual library to install [string]
  --max-gzip-size, -M  Gzip Size threeshold of individual library to install
                                                                        [string]
  -h, --help           Show help                                       [boolean]

More Repositories

1

configue

βš™οΈ Configue All the Things.js πŸ”§
JavaScript
34
star
2

diractions

πŸ‘¨β€πŸ’» Doing Anything, Anywhere, from Here [zsh] 🚏
Shell
30
star
3

cask-package-toolset.el

πŸ›  Toolsettize your emacs package! πŸ› 
Emacs Lisp
30
star
4

spacemacs-anki-deck

πŸ“‡ Basic spacemacs Anki deck generator πŸ—„
JavaScript
17
star
5

zsh-quiet-accept-line

πŸ™Š Zsh Zle plugin to quietly run a command 🀫
Shell
13
star
6

omni-kill.el

βš”οΈ M-x kill-all-the-thing ☠️
Emacs Lisp
10
star
7

omni-scratch.el

πŸ“‹ Easy and mode-specific draft buffers for emacs πŸ“
Emacs Lisp
8
star
8

omni-quotes.el

Random quotes displayer for Emacs
Emacs Lisp
7
star
9

omni-log.el

(log 'all-the-things)
Emacs Lisp
3
star
10

logupdate.py

πŸ“ Log by overwriting the previous output in the terminal in Python. (port of sindresorhus/log-update)
Python
3
star
11

emojizer

Less is more with emojies πŸ˜‰
JavaScript
3
star
12

vorpal-REPLinception

Vorpal Extension for node Repl
JavaScript
2
star
13

pending-link

API REST POC to compare Hapi and Express
JavaScript
2
star
14

velibe

Cli Wrapper for Velib api, for no-fuss cycling :)
Ruby
2
star
15

omni-tags.el

Β€Highlight and Β§Actions for 'Tags' in emacs
Emacs Lisp
2
star
16

wait-a-minute

Temporise your command, for a minute or so πŸ•°οΈ
JavaScript
1
star
17

promela-mode

Major mode for editing PROMELA program files
Emacs Lisp
1
star
18

adrieankhisbe.github.io

This is not my Personal Website
CSS
1
star
19

spinlog.py

Spinner Logger for Python
Python
1
star
20

omni-tags.vscode

Omni Tags for VSCode πŸ”–
TypeScript
1
star
21

omni-quotes.vscode

Quote Displayer for vscode
JavaScript
1
star
22

vorpal-shell

Vorpal Extension for running shell commands
Shell
1
star
23

Emoji-Dataset

A Collection of Emoji Images and Attributes
Python
1
star
24

my-node-libraries

Personal monorepo for personal node libraries 🏑
JavaScript
1
star
25

AdrieanKhisbe

This is just a personal README ;)
1
star