artzub / blackhole.js

Library for dinamyc visaulization such as code_swarm. Sandbox:
http://codepen.io/collection/Eqrmi/
MIT License
89 stars 31 forks source link

add supporting nodejs #13

Open artzub opened 10 years ago

gazpachu commented 8 years ago

Do you mean to add the library to NPM? I can install it referring directly to the Github repo:

npm install d3 --save npm install https://github.com/artzub/blackhole.js.git --save

This is how I load them in my React.js component:

import d3 from 'd3';
import blackhole from 'blackhole.js/blackhole.js';

But I get an issue with the D3 dependency:

Uncaught ReferenceError: d3 is not defined here:

    blackhole.utils = {
        isFun: isFun,
        func: func,
        getFun: getFun,
        emptyFun: emptyFun
    };
    d3.blackHole = blackhole;
artzub commented 8 years ago

I think it happends because

import d3 from 'd3'

in local scope.

If you use webpack for building then you can add vendors.js and part of webpack.config.js

const common = {
    entry: {
        app: ['./src/index.js'],
        vendors: ['d3']
    },
    output: {
        path: buildPath,
        filename: 'app.js'
    },
    //   ...
    plugins: [
        // ...
        new webpack.ProvidePlugin({ d3: 'd3' }),
        new webpack.optimize.CommonsChunkPlugin('vendors','vendors.js')
    ]
};

I think we have similar way in order to declare global dependencies

P.S. This task about adding method to collecte git information with using nodejs.

gazpachu commented 8 years ago

Thanks, that fixed it!