blackhole.js icon indicating copy to clipboard operation
blackhole.js copied to clipboard

add supporting nodejs

Open artzub opened this issue 10 years ago • 3 comments

artzub avatar Apr 07 '14 08:04 artzub

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;

gazpachu avatar Aug 12 '16 15:08 gazpachu

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.

artzub avatar Aug 12 '16 16:08 artzub

Thanks, that fixed it!

gazpachu avatar Aug 12 '16 17:08 gazpachu