anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.75k stars 425 forks source link

Unable to use VivaGraphJS with browserify (because of `require("./version.js")`) #127

Closed brunal closed 9 years ago

brunal commented 9 years ago

Hi, I did npm install vivagraphjs

Then I included that way in my script main.js: var Viva = require("vivagraphjs")

However when I run browserify main.js > bundle.js I get the following stacktrace:

Error: Cannot find module './version.js' from '/home/bru/code/docu/node_modules/vivagraphjs/dist'
    at /home/bru/code/docu/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
    at load (/home/bru/code/docu/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/home/bru/code/docu/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /home/bru/code/docu/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:99:15)

This is because in node_modules/vivagraphjs/dist/vivagraph.js there is a require("./version.js") which is present in src but not in dist.

What am I doing wrong?

Thanks

anvaka commented 9 years ago

I don't think you are doing anything wrong. I can reproduce the bug as well.

What strange is that it works in node. When you look at dist file version is required here, it receives index 63 in the browserify metadata and is exported under the same number here. It is the last module in the list.

Trying to find where the bug is.

anvaka commented 9 years ago

Opened an issue in the browserify repository: https://github.com/substack/node-browserify/issues/1140

anvaka commented 9 years ago

should be fixed in v0.7.5

brunal commented 9 years ago

Thank you!