Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

disc

:chart_with_upwards_trend: Visualise the module tree of browserify project bundles and track down bloat.

Subscribe to updates I use disc


Statistics on disc

Number of watchers on Github 1261
Number of open issues 22
Average time to close an issue 3 months
Main language JavaScript
Average time to merge a PR 11 days
Open pull requests 11+
Closed pull requests 3+
Last commit about 2 years ago
Repo Created about 6 years ago
Repo Last Updated over 1 year ago
Size 282 KB
Homepage http://hughsk.io/...
Organization / Authorhughsk
Contributors9
Page Updated
Do you use disc? Leave a review!
View open issues (22)
View disc activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating disc for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

disc gittip: hughsk npm stable

Disc is a tool for analyzing the module tree of browserify project bundles. It's especially handy for catching large and/or duplicate modules which might be either bloating up your bundle or slowing down the build process.

The demo included on disc's github page is the end result of running the tool on browserify's own code base.

Installation

Disc lives on npm, so if you haven't already make sure you have node installed on your machine first.

Installing should then be as easy as:

sudo npm install -g disc

Command-Line Interface

Note: you'll need to build your bundle with the --full-paths flag, and pass a fully qualified (not relative) input path to browserify for disc to do its thing.

discify [bundle(s)...] {options}

Options:
  -h, --help    Displays these instructions.
  -o, --output  Output path of the bundle. Defaults to stdout.
  -O, --open    Opens disc in a new browser window automatically
  -m, --mode    the default file scale mode to display: should be
                either "count" or "size". Default: size

When you install disc globally, the discify command-line tool is made available as the quickest means of checking out your bundle. As of disc v1.0.0, this tool takes any bundled browserify script as input and spits out a standalone HTML page as output.

For example:

browserify --full-paths index.js > bundle.js
discify bundle.js > disc.html
open disc.html

You can easily chain this file into another command, or use the --open flag to open disc in your browser automatically:

browserify --full-paths index.js | discify --open

Module API

Note: you'll need to build your bundle with the fullPaths option for disc to do its thing.

require('disc')(opts)

Creates a through stream that you can pipe a bundle into, and get an HTML file in return much like you would expect when working with the command-line tool.

So to perform the above example with Node instead of Bash:

var browserify = require('browserify')
var open = require('opener')
var disc = require('disc')
var fs = require('fs')

var input = __dirname + '/index.js'
var output = __dirname + '/disc.html'

var bundler = browserify(input, {
  fullPaths: true
})

bundler.bundle()
  .pipe(disc())
  .pipe(fs.createWriteStream(output))
  .once('close', function() {
    open(output)
  })

This method takes the following options:

  • header: HTML to include above the visualisation. Used internally to render the Fork me on GitHub ribbon.
  • footer: HTML to include beneath the visualisation. Used internally for the description on the demo page.
  • mode: the default file scale mode to display: one of either "count" or "size", defaulting to "size".

disc.bundle(bundles, [opts], callback)

A callback-style interface for disc: takes an array of bundles (note: the file contents and not the file names), calling callback(err, html) with either an error or the resulting standalone HTML file as arguments.

This currently mirrors how disc is currently implemented, but the stream API is a little more convenient to work with.

disc.json(bundles, callback)

Takes an array of bundle contents (as strings, or Buffers), and gathers the required data - calling callback(err, json) with either an error or the results.

Palettes

You can switch between multiple color palettes, most of which serve to highlight specific features of your bundle:

Structure Highlights

Structure Highlights

Highlights node_modules directories as green and lib directories as orange. This makes it easier to scan for kitchen sink modules or modules with lots of dependencies.

File Types

File Types

Highlights each file type (e.g. .js, .css, etc.) a different color. Helpful for tracking down code generated from a transform that's bloating up your bundle more than expected.

Browserify Core

Browserify Core

Highlights the automatically included and/or inserted modules that come courtesy of browserify in red. Makes it easy to quantify just how much space in your bundle is the result of shimming node's core functionality.

Original/Pastel

Nothing particularly special about these palettes colored for legibility and aesthetics respectively.

disc open issues Ask a question     (View All Issues)
  • about 3 years Update d3 to v4 modules
  • over 3 years error "Duplicate data property in object literal not allowed in strict mode"
  • over 3 years --open does not work on Windows
  • over 3 years ES6 syntax (computed property names) causes esprima-fb error
  • over 3 years Unexpected token: ILLEGAL
  • almost 4 years Flattened npm 3 installs don't display dependency hierarchies correctly
  • almost 4 years Outdated dependency `bl` causing install failure
  • about 4 years Manage external package only bundle
  • over 4 years feature request: console reporter
  • over 4 years --open in conjunction with --output
  • over 4 years Cant pipe into discify
  • over 4 years module not resolving when using disc
  • over 4 years TypeError: Cannot read property 'source' of undefined
  • about 5 years -r seems to break it?
  • about 5 years webpack support?
  • about 6 years Make filesize analysis match browserify bundling
  • about 6 years browser vs. server
  • about 6 years minify and gzip before checking file size
disc open pull requests (View All Pulls)
  • deps - bump bl to 0.8.0
  • Handle "external-only" bundles created with browserify -r. Fixes #41
  • Tiny README fix
  • Listen on random port rather than 12999
  • Remove protocol
  • Add rotate option
  • Update README.md
  • Updated deps, added travis ci support to ensure coverage
  • Support ES2015 parsing
  • bump bl version
  • Handle module.id being null
disc questions on Stackoverflow (View All Questions)
  • Since FireFox extensions are written in Javascript, how are they able to write to the local disc, which JS proscribes?
  • Datapump Jobs Linux Not Working After Making Disc Space
  • I am getting the error "Could not find the developer disc image". The Xcode version is Version 7.1 (7B91b)
  • Set disc quota with DeviceMapper
  • How to make a DJ disc that follows MediaPlayer and scratches in android
  • Save camera roll image to disc in react native
  • Erlang: create a disc schema
  • How to handle windows "Drive not ready", "No disc" etc alert dialog
  • How to delete unused org-mode attachment files from disc
  • DirectX C++ Disc animation
  • Newton's Disc rotation program too slow. Any way to speed up timer? Also, animation flickers. Any way to fix that?
  • Boto does not save s3 file to disc on AWS Lambda
  • Large data from SQL server to local hard disc to Tableau and Pandas
  • Combine picture with text and save to disc. (Someecards style)
  • Is there a way to discern if a drive is a dvd/cd/blueray drive without a disc inside?
  • Leveraging nx.minimum_node_cut to get all minimal sets of nodes that disc
  • Prevent Redis from saving to disc
  • How to control size of list-style-type disc in CSS?
  • Every time I clean, run, or build the project, the manifest file gets reloaded from disc
  • PHP Word, send generated file to browser as output without saving it on disc
  • Working with big data in python and numpy, not enough ram, how to save partial results on disc?
  • PyX python scripts write files to disc but not to screen
  • Docker maximize disc quota
  • Cassandra increased disc usage when updating to 2.1.9
  • How To Add List-style-type: "disc" to <p> tag
  • Erlang - Is it possible to limit the ram consumption when using disc copies in Mnesia?
  • is there an easy/efficient way to make a mysql database dynamically 'build it's own structure' as it saves name/value pairs to disc?
  • KickStart Centos Says Please insert Centos Disc 1 to Continue
  • Make ms access database trusted for all users on network disc
  • SOLR Cloud 4.3 delete data from index and disc
disc list of languages used
Other projects in JavaScript