Giter Site home page Giter Site logo

hughsk / disc Goto Github PK

View Code? Open in Web Editor NEW
1.3K 19.0 83.0 284 KB

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

Home Page: http://hughsk.io/disc

License: Other

JavaScript 87.49% HTML 2.02% CSS 10.49%

disc's Introduction

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's People

Contributors

bjoerge avatar chrisdickinson avatar emkay avatar feross avatar hughsk avatar mantoni avatar mathisonian avatar mikolalysenko avatar parshap avatar raynos avatar robert-chiniquy avatar systemparadox avatar tmcw avatar tnguyen14 avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

disc's Issues

TypeError: Cannot read property 'source' of undefined

This issue is a variation of #24 (same error but I use absolute paths).

  1. Run the gulp code found at #29 (comment) but replace the paths (passed into add() and dest()) with absolute paths.
  2. Exception is thrown:
C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\index.js:99
        size: row.source.length
                 ^
TypeError: Cannot read property 'source' of undefined
    at tree.name (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\index.js:99:18)
    at flat.unflatten.delimiter (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\file-tree\index.js:15:5)
    at next (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\file-tree\node_modules\async-reduce\index.js:11:7)
    at reduce (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\file-tree\node_modules\async-reduce\index.js:23:3)
    at tree (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\file-tree\index.js:13:3)
    at json (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\index.js:95:3)
    at bundle (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\index.js:129:10)
    at BufferList._callback (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\index.js:27:5)
    at BufferList.end (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\bl\bl.js:75:10)
    at Stream.method [as end] (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\duplexer\index.js:47:39)

This issue is reproducible 100% of the time.

--open in conjunction with --output

It's nice that discify has a built in server, but it's rather confusing that --open doesn't work when used in conjunction with --output.

Why not just open the static file that is written immediately upon writing? Or at the very least, make it clear in the documentation/help that --open and --output are mutually exclusive. (I kept repeatedly trying various configurations wondering why --open wasn't doing anything, before I finally tried removing --output.)

Outdated dependency `bl` causing install failure

here's my install failure on v0.12

╭─kumavis@xyzs-MacBook-Pro  ~/dev/dapp-sandbox ‹node-v0.12.7›  (master*) 
╰─$ npm i -g disc
/Users/kumavis/.nvm/versions/node/v0.12.7/bin/discify -> /Users/kumavis/.nvm/versions/node/v0.12.7/lib/node_modules/disc/bin/discify
/Users/kumavis/.nvm/versions/node/v0.12.7/lib
└─┬ [email protected] 
  ├─┬ [email protected] 
  │ └─┬ [email protected] 
  │   ├── [email protected] 
  │   ├── [email protected] 
  │   ├── [email protected] 
  │   └── [email protected] 
  ├─┬ [email protected] 
  │ ├─┬ [email protected] 
  │ │ └─┬ [email protected] 
  │ │   ├── [email protected] 
  │ │   └── [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ ├── [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├── [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  ├── [email protected] 
  ├── UNMET PEER DEPENDENCY stream-browserify@*
  ├── [email protected] 
  └── [email protected] 

npm WARN EPEERINVALID [email protected] requires a peer of stream-browserify@* but none was installed.

ES6 syntax (computed property names) causes esprima-fb error

Appears to be related to one of the parser dependencies needing to be updated.
I am getting syntax error raised from esprima-fb.

├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]  ////// COULD BE THIS ONE
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── UNMET PEER DEPENDENCY stream-browserify@*
│ ├── [email protected]
│ └── [email protected]
/* ... */

feature request: console reporter

I love disc and it's helped our browserify build quite a bit. But I would love to have a reporter option that does just a high level overview straight to STDOUT in a console friendly/ascii format.

The key metrics that most people (I think) care about when looking at their browserify bundle is:

  • size of the browserify-core in bytes and %
  • size of node_modules in bytes and %
    • size of actual library in bytes and %

These three (six with percentages) are all that I care about at a quick glance to ensure that my module is trending the direction that I want.

To go just a step further, I would like to see just a single-level below each of the items above, to see how browserify-core weight, how node_modules weight, and how actual library weight is distributed.

This would be small enough output that emitting to the console would be easily digestable and useful as a quick report. If something trends in an undesirable direction, then one can switch over to the full HTML reporter and dive in deeper.

npm install fails

I forked the project and ran:

npm install

I get the following:

[email protected] prepublish /Users/cabrams/Projects/disc
mkdir -p build && npm run browserify && npm run rework && npm run bundle-demo

[email protected] browserify /Users/cabrams/Projects/disc
browserify src/index.js | uglifyjs -c 2> /dev/null > build/bundle.js

npm ERR! [email protected] browserify: browserify src/index.js | uglifyjs -c 2> /dev/null > build/bundle.js
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the [email protected] browserify script.
npm ERR! This is most likely a problem with the disc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify src/index.js | uglifyjs -c 2> /dev/null > build/bundle.js
npm ERR! You can get their info via:
npm ERR! npm owner ls disc
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "run" "browserify"
npm ERR! cwd /Users/cabrams/Projects/disc
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/cabrams/Projects/disc/npm-debug.log
npm ERR! not ok code 0

npm ERR! [email protected] prepublish: mkdir -p build && npm run browserify && npm run rework && npm run bundle-demo
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] prepublish script.
npm ERR! This is most likely a problem with the disc package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! mkdir -p build && npm run browserify && npm run rework && npm run bundle-demo
npm ERR! You can get their info via:
npm ERR! npm owner ls disc
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/cabrams/Projects/disc
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/cabrams/Projects/disc/npm-debug.log
npm ERR! not ok code 0

module not resolving when using disc

╭─{👳 } kumavis in ~/Development/Node/vapor/app on (master✱) 
╰─± browserify --full-paths index.js > bundle.js
╭─{👳 } kumavis in ~/Development/Node/vapor/app on (master✱) 
╰─± discify bundle.js > disc.html               

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: Cannot find module '../mercury.js'
    at /usr/local/share/npm/lib/node_modules/disc/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/lib/async.js:37:25
    at load (/usr/local/share/npm/lib/node_modules/disc/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/lib/async.js:54:43)
    at /usr/local/share/npm/lib/node_modules/disc/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/lib/async.js:60:22
    at /usr/local/share/npm/lib/node_modules/disc/node_modules/module-deps/node_modules/browser-resolve/node_modules/resolve/lib/async.js:16:47
    at Object.oncomplete (fs.js:108:15)
╭─{👳 } kumavis in ~/Development/Node/vapor/app on (master✱) 
╰─± browserify -v                               
9.0.3

Cannot call method 'reduce' of undefined

/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:97
return child.size = child.size || child.children.reduce(function(size, child
^
TypeError: Cannot call method 'reduce' of undefined
at dirsizes (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:97:52)
at child.size (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:98:34)
at Array.reduce (native)
at dirsizes (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:97:52)
at child.size (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:98:34)
at Array.reduce (native)
at dirsizes (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:97:52)
at child.size (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:98:34)
at Array.reduce (native)
at dirsizes (/home/raynos/nvm/v0.10.5/lib/node_modules/disc/index.js:97:52)

Not sure what causes this.

Error: ENOENT, open 'crypto'

Not sure what is going on here, it passes browserify just fine.

% ./node_modules/.bin/discify app/app.js --open                                                        

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: ENOENT, open 'crypto'

Manage external package only bundle

I'm using the external functionality of browserify to generate my javascript files. It produce two files: app.js and vendor.js. Using disc with the app.js works perfectly. But it's do not work on the vendor.js 😭

Here the blueprint of how I generate my two packages:

// app.js 
var b = browserify('client.js', {...});

// I externalyse some dependencies
var dependencies = ['lodash', 'react', 'react-router'];
for (var i in dependencies) {
     b.external(dependencies[i]);
}

b.bundle() // It's a gulp task, so the rest of the file is not the point of this code 
// vendor.js
var b = browserify(null,  {...}); // Here is the issue I think

var dependencies = ['lodash', 'react', 'react-router']; // same array of external dependencies as before
for (var i in dependencies) {
    b.require(dependencies[i]);
}

b.bundle() 

I guess is thatdisc cannot work on my vendor.js file because there no entry point in this bundle var b = browserify(null, {...});.

If I build all my dependencies in my app.js bundle, everything works.

Tell me if you want my vendor.js file.

Not working with browserify+vue?

When I add this to my package.json to make Vue compatible with browserify:

  "browser": {
    "vue": "vue/dist/vue.common"
  },

I get this error:

/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:6268
            throw e;
            ^

Error: Line 6472: Invalid regular expression
    at throwError (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2159:21)
    at scanRegExp (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:1343:13)
    at parsePrimaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2665:43)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at trackLeftHandSideExpressionAllowCall (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5732:61)
    at parsePostfixExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2795:20)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at parseUnaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2859:16)
    at /usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:5832:38
    at parseBinaryExpression (/usr/local/lib/node_modules/disc/node_modules/esprima-fb/esprima.js:2947:16)

This is the relevant gulp-part:

function bundle(bundler) {
    return bundler
        .on('error', gutil.log)
        .transform("babelify", {presets: ["es2015"]})
        .bundle()
        .pipe(exorcist('./assets/js/dist/bundle.js.map'))
        .pipe(source('bundle.js'))
        .pipe(gulp.dest('assets/js/dist'))
        .pipe(browserSync.stream())
}

gulp.task('js', function (done) {
    bundle(browserify({
        entries: config.js.entry,
        fullPaths: true,
        debug: config.debug
    }));
    return done();
});

gulp.task('js:disc', function() {
    return plugins.run('discify assets/js/dist/bundle.js --open > disc.html').exec();
})

And this is the Vue-Code:

import Vue from 'vue';

const app = new Vue({
    el: '.list',
    data: {
        items: ['123', '123', '333']
    }
});

However, when I remove the first mentioned lines from package.json, disc works (but vue.js does not).

browser vs. server

Browserify does a slightly different lookup to node because it looks in the "browser" field in package.json

It would be good to have an option to specify whether we wanted to do the lookups for browser or server.

Error on discify

I'm getting an error when running discify on a bundle:

/usr/local/lib/node_modules/disc/bin/discify:59
    if (err) throw err
                   ^
Error: Unable to compile one of the supplied bundles!
    at /usr/local/lib/node_modules/disc/index.js:47:56
    at Array.map (native)
    at json (/usr/local/lib/node_modules/disc/index.js:46:5)
    at Function.bundle (/usr/local/lib/node_modules/disc/index.js:128:10)
    at handle (/usr/local/lib/node_modules/disc/bin/discify:56:8)
    at disc.bundle.mode (/usr/local/lib/node_modules/disc/bin/discify:51:5)
    at handler (/usr/local/lib/node_modules/disc/node_modules/map-async/index.js:36:29)
    at fs.js:271:14
    at Object.oncomplete (fs.js:107:15)

Is there a way to get more information on this error to debug it?

Cant pipe into discify

The readme suggests you can pipe into discify, but it doesnt seem to read from stdin

─{👳 } kumavis in ~/Development/Node/vapor on (master) 
╰─± browserify app/index.js --full-paths | discify --open 
/usr/local/share/npm/bin/discify [file(s)...] {options}

Options:
  -h, --help       Displays these instructions.                  
  -o, --output     Output path of the bundle. Defaults to stdout.
  -t, --transform  Browserify transform stream(s) to use.        
  -O, --open       Open the file immediately.                    

Unexpected token: ILLEGAL

Does anyone else get this error, in-browser, from the report generated with disc?

Uncaught SyntaxError: Unexpected token ILLEGAL | dist.html:19

TypeError: Invalid non-string/buffer chunk

Given:

var source = require("vinyl-source-stream");
var disc = require("disc");
var javascript = new browserify(
{
    fullPaths: true
});

javascript.add(
[
    "./inDir/Index.js"
]);

javascript.
bundle().
pipe(source("Common.js")).
pipe(gulp.dest("./outDir"));

The above code works, but if I add pipe(disc()). between source() and gulp.dest() I get this exception:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
TypeError: Invalid non-string/buffer chunk
    at validChunk (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\bl\node_modules\readable-stream\lib\_stream_writable.js:164:14)
    at BufferList.Writable.write (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\bl\node_modules\readable-stream\lib\_stream_writable.js:193:12)
    at Stream.method [as write] (C:\Users\Gili\Documents\realestate\frontend\node_modules\disc\node_modules\duplexer\index.js:47:39)
    at write (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24)
    at flow (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7)
    at DestroyableTransform.pipeOnReadable (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:664:5)
    at DestroyableTransform.emit (events.js:92:17)
    at emitReadable_ (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:448:10)
    at emitReadable (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:444:5)
    at readableAddChunk (C:\Users\Gili\Documents\realestate\frontend\node_modules\vinyl-source-stream\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:187:9)

Any ideas?

Make "file size" the default view

File size seems vastly more useful than number of files if you're trying to find out where your bundle size is coming from. Wouldn't you agree?

Can we make this the default view?

piping into `discify` does not work

Running browserify --full-paths index.js | discify | bcat just prints the help message:

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

Options:
  -h, --help       Displays these instructions.                  
  -o, --output     Output path of the bundle. Defaults to stdout.
  -t, --transform  Browserify transform stream(s) to use.        
  -O, --open       Open the file immediately.                    
  -n, --noparse    Omit file from parse.          

Make node_modules more obvious

I absolutely love this tool, I feel like I've been waiting for something this awesome for ages.

One thing I think would make it easier to use would be if node_modules was always a really distinctive colour such as black. That way it would be easy to see at each level whether stuff came from dependencies, or internal bloat.

Flat disc instead of hierarchy

Maybe I'm doing something wrong, but I seem to only get a flat disc instead of a hierarchical view. I'm running the following command from gulp:

  browserify({ extensions: ['.coffee', '.js'], entries: [__dirname + '\\client\\js\\app.coffee'], fullPaths: true })
    .transform(coffeeify, {global: true})
    .bundle()
    .pipe(disc())
    .pipe(fs.createWriteStream(output))

image

release new version

Would you be able to release a new version with the latest changes? That would remove a deprecated dependency warning.
Please don't hesitate to ask for help in case something else needs to happen first.

-r seems to break it?

With -r ./foo/bar:foo option to browserify, I'm getting this error:

/usr/local/lib/node_modules/disc/bin/discify:59
    if (err) throw err
                   ^
Error: Unable to compile one of the supplied bundles!
    at /usr/local/lib/node_modules/disc/index.js:47:56
    at Array.map (native)
    at json (/usr/local/lib/node_modules/disc/index.js:46:5)
    at Function.bundle (/usr/local/lib/node_modules/disc/index.js:128:10)
    at handle (/usr/local/lib/node_modules/disc/bin/discify:56:8)
    at BufferList.disc.bundle.mode [as _callback] (/usr/local/lib/node_modules/disc/bin/discify:45:5)
    at BufferList.end (/usr/local/lib/node_modules/disc/node_modules/bl/bl.js:75:10)
    at Socket.onend (stream.js:79:10)
    at Socket.emit (events.js:117:20)
    at _stream_readable.js:929:16

Will try to look into it further..

EDIT: Seems related to browser-unpack; the latest version 1.0.0 fixes the problem but introduces another:

/projects/disc/node_modules/commondir/index.js:15
            throw new Error('relative path without a basedir');
                  ^
Error: relative path without a basedir
    at /projects/disc/node_modules/commondir/index.js:15:19
    at Array.reduce (native)
    at module.exports (/projects/disc/node_modules/commondir/index.js:13:30)
    at json (/projects/disc/index.js:70:14)
    at Function.bundle (/projects/disc/index.js:128:10)
    at handle (/projects/disc/bin/discify:56:8)
    at BufferList.disc.bundle.mode [as _callback] (/projects/disc/bin/discify:45:5)
    at BufferList.end (/projects/disc/node_modules/bl/bl.js:75:10)
    at Socket.onend (stream.js:79:10)
    at Socket.emit (events.js:117:20)

Using a full path for my -r option doesn't fix the issue.

Cannot read property 'source' of undefined

When i try verbatim what you said in your example since v1.0.0

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

I get this

E:\Prog\front-web\node_modules\disc\index.js:100
        size: row.source.length
                 ^
TypeError: Cannot read property 'source' of undefined
    at tree.name (E:\Prog\front-web\node_modules\disc\index.js:100:18)
    at flat.unflatten.delimiter (E:\Prog\front-web\node_modules\disc\node_modules\file-tree\index.js:15:5)
    at next (E:\Prog\front-web\node_modules\disc\node_modules\file-tree\node_modules\async-reduce\index.js:11:7)
    at reduce (E:\Prog\front-web\node_modules\disc\node_modules\file-tree\node_modules\async-reduce\index.js:23:3)
    at tree (E:\Prog\front-web\node_modules\disc\node_modules\file-tree\index.js:13:3)
    at json (E:\Prog\front-web\node_modules\disc\index.js:94:3)
    at Function.bundle (E:\Prog\front-web\node_modules\disc\index.js:130:10)
    at handle (E:\Prog\front-web\node_modules\disc\bin\discify:56:8)
    at disc.bundle.mode (E:\Prog\front-web\node_modules\disc\bin\discify:51:5)
    at handler (E:\Prog\front-web\node_modules\disc\node_modules\map-async\index.js:36:29)

var row = byid[id] is the culprit

id was correctly the entry file at first, but it seems that he still didn't found the data inside byid, i'll try some Object.keys on byid to check what happened after I eat something.

any ideas on your side ?

error "Duplicate data property in object literal not allowed in strict mode"

May be related to #51 ... Getting this error on cli command discify bundle.js > disc.html

Corys-MBP:~/projects/therms/.tmp/public/js (records)$ discify bundle.js > disc.html
/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:6268
            throw e;
            ^

Error: Line 10375: Duplicate data property in object literal not allowed in strict mode
    at throwError (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2159:21)
    at throwErrorTolerant (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2171:24)
    at parseObjectInitialiser (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2531:25)
    at /usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:5832:38
    at parsePrimaryExpression (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2657:20)
    at /usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:5832:38
    at trackLeftHandSideExpressionAllowCall (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:5732:61)
    at parsePostfixExpression (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2795:20)
    at /usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:5832:38
    at parseUnaryExpression (/usr/local/lib/node_modules/disc/node_modules/browser-unpack/node_modules/esprima-fb/esprima.js:2859:16)

Update d3 to v4 modules

In the spirit of this very library, i suggest making use of the substantially smaller more modular d3v4 modules

Make filesize analysis match browserify bundling

It would be nice if the total size matches what browserify bundles too. Currently one of my files is 184kb vs 198kb where browserify produces an extra 14kb

browserify will add extra code to the bundle for the basic require emulation.

It will also add extra kb of padding around every module with it's function (require, module, exports) wrapping.

It also detects global usage of process and adds the process emulation to the bundle as well.

Error: Line 2: Unexpected token :

When I try to run discify index.js (or discify -t coffeeify index.coffee, similar result) on https://github.com/deathcap/voxpopuli it fails with:

/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3859
throw e;
^
Error: Line 2: Unexpected token :
at throwError (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:1156:21)
at throwUnexpected (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:1213:9)
at consumeSemicolon (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:1295:13)
at parseStatement (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:2791:9)
at parseSourceElement (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3049:20)
at parseStatementList (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:2041:25)
at parseBlock (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:2056:17)
at parseStatement (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:2727:24)
at parseSourceElement (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3049:20)
at parseSourceElements (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3082:29)
at parseProgram (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3096:19)
at parse (/usr/local/lib/node_modules/disc/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima/esprima.js:3843:23)

Any way to see the source file which might be causing this syntax error? I can try to remove modules to isolate further but "line 2" could be anywhere... (same project parses fine with beefy or browserify)

--open does not work on Windows

The --open option cause the webbrowser (Chrome) to launch but the webserver does not respond and does not serve the page. When --output is used at the same time disc could just start the generated file using the systems browser.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.