Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'source' of undefined #24

Closed
Sinewyk opened this issue Nov 22, 2014 · 5 comments
Closed

Cannot read property 'source' of undefined #24

Sinewyk opened this issue Nov 22, 2014 · 5 comments

Comments

@Sinewyk
Copy link

Sinewyk commented Nov 22, 2014

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 ?

@Sinewyk
Copy link
Author

Sinewyk commented Nov 22, 2014

Oh yeah. That's it, some kind of path issue. My first file is in the object as a relative path

process.cwd() === '/home/sinewyk/dev/repo'
'./app/scripts/main.js'

while it's trying to get '/home/sinewyk/dev/repo/app/scripts/main.js'

all others entries in the object have the correct expected form by disc, that is stuff like

'/home/sinewyk/dev/repo/node_modules/underscore/underscore.js'

Any ideas where it could be coming from ?

@Sinewyk
Copy link
Author

Sinewyk commented Nov 22, 2014

Ok ... fixed, I just needed to send an absolute path into browserify instead of a relative one, so that the entry file also had an expected absolute path instead of a relative one.

Maybe edit the readme, fullPaths: true needed, AND send and absolute path down the browserify bundle API.

@hughsk
Copy link
Owner

hughsk commented Nov 23, 2014

@Sinewyk this is a bug in browserify – maybe you should open an issue or PR to have the supplied path made absolute when using fullPaths?

@cowwoc
Copy link

cowwoc commented Jan 26, 2015

@Sinewyk I am running into the same problem. Did you open a bug report with Browserify? If so, where?

@Sinewyk
Copy link
Author

Sinewyk commented Jan 27, 2015

Oh my bad. I bypassed the problem. I had a "classic" browserify workflow with all my custom things that worked. And then I simply run disc on the result file with --open.

Exactly like that (for example with gulp, but you can do that with anything really).

gulp.task('deps-tree', ['browserify'], function() {
    var discSpawn = spawn('./node_modules/.bin/discify', ['./app/assets/scripts/bundle.js', '--open']);

    discSpawn.on('close', function() {
        process.exit(0);
    });
});

don't forget to send fullPaths: true as option inside the browserify command.

mathisonian added a commit to mathisonian/disc that referenced this issue Apr 7, 2015
Thanks for the library - it's been very useful!

I hit the same problem as hughsk#24, hughsk#30. Using a full path for the browserify input fixed it for me, as well as for other people in those issue threads.
@Sinewyk Sinewyk closed this as completed Jun 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants