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

browserify-tree

v0.0.6

Published

Generate a Browserify bundle dependency tree for bundled modules

Downloads

7,300

Readme

A library for analysing Browserify generated JavaScript bundles.

If you're interested in something like this you might also be interested in disc, which is a more visual analysis. This lib is useful for helping you to analyse how the dependencies are wired together. Also useful if you are writing Browserify transforms/plugins that are manipulating the bundle.

CLI Usage

Install globally if you want to use the CLI:

sudo npm install -g browserify-tree

CLI options:
   --unusedt     Unused in the entry module's dependency tree.
   --unuseda     Unused anywhere i.e. no dependants in entry module's tree, or among other unused.

   --filter      Unused module listing filter.
                 (see --unusedt and --unuseda)
                 e.g. --filter=/node_modules/parse-asn1

   --unuseddc    List dependencies of unused modules (what the unused module depends on).
                 (see --unusedt and --unuseda)
   --unuseddd    List dependants of unused modules (what depends on the unused module).
                 (see --unusedt and --unuseda)

   --notree      Don't output the entry module's dependency tree.

And --help for help (printing the above).

Basic example:

$ browserify-tree ./target/classes/org/jenkins/ui/jsmodules/blueocean-usain/jenkins-js-extension.js

The bundle entry module is:
	/Users/tfennelly/zap/blueocean-usain/target/jenkins-js-extension.jsx
------------------------------------------------
=--/target/jenkins-js-extension.jsx (49952)
=  |--/src/main/js/Usain.jsx (48047)
=  |  |--/node_modules/@jenkins-cd/blueocean-core-js/dist/js/index.js (42790)
=  |  |  |--/node_modules/@jenkins-cd/js-modules/js/index.js (42660)
=  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/ModuleSpec.js (8844)
=  |  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/Version.js (2965)
=  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/internal.js (23980)
=  |  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/ModuleSpec.js (0) (skipped - see earlier resolve)
=  |  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/promise.js (1874)
=  |  |  |  |--/node_modules/@jenkins-cd/js-modules/js/promise.js (0) (skipped - see earlier resolve)
=  |  |--/node_modules/react/react.js (84)
=  |  |  |--/node_modules/@jenkins-cd/js-modules/js/index.js (0) (skipped - see earlier resolve)
=  |--/node_modules/@jenkins-cd/js-modules/js/index.js (0) (skipped - see earlier resolve)

Sorted by source length/size:
=--/target/jenkins-js-extension.jsx (49952)
=--/src/main/js/Usain.jsx (48047)
=--/node_modules/@jenkins-cd/blueocean-core-js/dist/js/index.js (42790)
=--/node_modules/@jenkins-cd/js-modules/js/index.js (42660)
=--/node_modules/@jenkins-cd/js-modules/js/internal.js (23980)
=--/node_modules/@jenkins-cd/js-modules/js/ModuleSpec.js (8844)
=--/node_modules/@jenkins-cd/js-modules/js/Version.js (2965)
=--/node_modules/@jenkins-cd/js-modules/js/promise.js (1874)
=--/node_modules/react/react.js (84)
------------------------------------------------

--help for options

Example showing:

  1. unused modules in a bundle (--unusedt) + and what depends on those modules (--unuseddd).
  2. not displaying the entry module's dependency tree (--notree).
  3. only showing (--filter) modules in /node_modules/@jenkins-cd/.
browserify-tree ./target/classes/org/jenkins/ui/jsmodules/blueocean-usain/jenkins-js-extension.js --unusedt --unuseddd --notree --filter=/node_modules/@jenkins-cd/

The bundle entry module is:
	/Users/tfennelly/zap/blueocean-usain/target/jenkins-js-extension.jsx

The following modules do not appear to be in use via the bundle entry module:

- /node_modules/@jenkins-cd/blueocean-core-js/dist/js/config.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/blueocean-core-js/dist/js/fetch.js

- /node_modules/@jenkins-cd/blueocean-core-js/dist/js/fetch.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/blueocean-core-js/dist/js/jwt.js

- /node_modules/@jenkins-cd/blueocean-core-js/dist/js/jwt.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/blueocean-core-js/dist/js/fetch.js

- /node_modules/@jenkins-cd/blueocean-core-js/dist/js/urlconfig.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/blueocean-core-js/dist/js/jwt.js

- /node_modules/@jenkins-cd/blueocean-core-js/dist/js/utils.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/blueocean-core-js/dist/js/fetch.js

- /node_modules/@jenkins-cd/js-modules/js/Version.js
    Dependants (depending on this module):
    - /node_modules/@jenkins-cd/js-modules/js/ModuleSpec.js

------------------------------------------------

--help for options

API Usage

You can also use this package programmatically via its API.

To install:

npm install --save browserify-tree

Would probably use this in conjunction with the browser-unpack package.

getUnusedModules

Get a list of bundle module IDs for bundle modules that are not in use on the bundle entry module's dependency graph:

const browserifyTree = require('browserify-tree');
const unusedModules = browserifyTree.getUnusedModules('./target/classes/org/jenkins/ui/jsmodules/blueocean-usain/jenkins-js-extension.js'); // or pass the already unpackaged bundle object

// Do something with unusedModules

getUnloadableModules

Get a list of bundle module IDs for bundle modules that are not loadable for some reason e.g. they "require" unresolvable modules:

const browserifyTree = require('browserify-tree');
const unloadableModules = browserifyTree.getUnloadableModules('./target/classes/org/jenkins/ui/jsmodules/blueocean-usain/jenkins-js-extension.js'); // or pass the already unpackaged bundle object

// Do something with unloadableModules e.g. stub them out of the bundle with an exception.