Monday, 8 May 2017

Importing / Compiling d3 v4 with Webpack

I've recently incorporated PostCSS, Gulp and Webpack into my workflow, however the learning curve is pretty steep (Webpack in particular!) and I'm having issues getting it to compile d3. I've installed d3 with npm install d3 --save and have tried importing it as:

var d3 = require("d3");

which didn't work. I tried installing a loader, adding

     new webpack.ProvidePlugin({
        d3: "d3"
    }),

to my webpack.config file and importing as

var d3 = require("d3!");

which didn't work either. I've tried the stuff here and here (last answer re the loader) as well.

I get the following error from my browser:

Uncaught ReferenceError: d3 is not defined

And gulp gives me the following error in the command line:

..../node_modules/loader-runner/lib/loadLoader.js:35 throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)");

My code repo is here.

Thanks in advance!



via Tom

No comments:

Post a Comment