Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
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.
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
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
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.
You can switch between multiple color palettes, most of which serve to highlight specific features of your bundle:
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.
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.
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.
Nothing particularly special about these palettes – colored for legibility and aesthetics respectively.
FAQs
A tool for analyzing the module tree of a browserify bundle or node project
The npm package disc receives a total of 2,103 weekly downloads. As such, disc popularity was classified as popular.
We found that disc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.