Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d4rkr00t/whybundled
Answers the question – Why the hell is this module in a bundle?
https://github.com/d4rkr00t/whybundled
bundle bundle-size stats webpack
Last synced: about 1 month ago
JSON representation
Answers the question – Why the hell is this module in a bundle?
- Host: GitHub
- URL: https://github.com/d4rkr00t/whybundled
- Owner: d4rkr00t
- License: mit
- Created: 2018-02-24T11:12:27.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T03:57:17.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T22:52:09.132Z (about 1 month ago)
- Topics: bundle, bundle-size, stats, webpack
- Language: TypeScript
- Homepage:
- Size: 2.56 MB
- Stars: 532
- Watchers: 7
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-github-star - whybundled
README
Ever wondered why any particular module ended up in a bundle? WhyBundled is here to answer exactly this question.
It's meant to be used alongside [stats report from webpack](https://webpack.js.org/api/stats/).
## Quick Start
```sh
npm i -g whybundledwhybundled stats.json ← stats file generated by wepback
```![whybundled default report](/assets/screenshot.png)
## Usage
```sh
USAGE
whybundled stats.json [pattern]COMMANDS
by Shows all modules that were brought into the bundle by a particular module.OPTIONS
--limit Limits output of reasons and files [number] [default: 20]
--filesOnly Only include files [boolean]
--modulesOnly Only include modules [boolean]
--directoryOnly Only include direct dependencies [boolean]
--transitiveOnly Only include transitive dependencies [boolean]
--duplicatesOnly Only include modules that have duplicates in a resulting bundle [boolean]
--ignore Comma separated list of glob patterns to exclude modules from final output [string]
--sortBy Sort modules, available fields: size, imported. E.g. size:asc or size:desc. [string]
--help Output usage information
--version Output the version numberEXAMPLES
whybundled stats.json --ignore babel-runtime,tslib
whybundled stats.json --modulesOnly
whybundled by stats.json styled-components
```## Features
### Stats Analyses
- Outputs list of all modules/files included in the bundle in from most imported to least imported order.
- Builds a chain of dependencies for transitive dependencies.
- Shows all files that were included for particular module.
- Shows all reasons why particular module was included.```sh
MODULE isobject
├─ imported: 1 time ← number of times module imported
├─ type: [transitive] ← type of a dependency can be either direct or transitive
│ └─ isobject -> is-plain-object -> styled-components ← for transitive dependencies whybundled outputs a chain of dependencies up to the closest direct
│
├─ locations: ← where module is located in a project
│ └─ ../node_modules/isobject/
│
├─ files: ← list of files that were included for this module
│ └─ ../node_modules/isobject/index.js
│
└─ reasons: ← list of reasons why module was included in a bundle
└─ is-plain-object
└─ ../node_modules/is-plain-object/index.js 10:15-34 [cjs require]
```### Duplicates Badge
If module has been bundled several times from different locations `whybundled` adds `[multiple]` badge next to the locations field:
![whybundled duplicates](/assets/multiple.png)
### Brought by
Using `by` command `whybundled` shows all modules that were brought into the bundle by a particular module:
```sh
USAGE
whybundled by stats.json [pattern]OPTIONS
--limit Limits output of reasons and files [number=20]
--only Limits output to only include modules that were included by specified module exclusively [boolean]
--ignore Comma separated list of glob patterns to exclude modules from final output [string]EXAMPLES
whybundled by stats.json styled-components
whybundled by stats.json styled-components --ignore babel-runtime,tslib
whybundled by stats.json styled-components --only
```![whybundled brought by](/assets/by.png)