4
votes

Here is how I've done:

bower install d3 --save

then added to Broccoli.js:

app.import('bower_components/d3/d3.js');

then in my view, added:

import d3 from 'bower_components/d3/d3';

and attempted to use it.

This causes an issue when launching the app. In devtools I see this error:

Uncaught TypeError: Cannot read property 'length' of undefined  vendor.js:40
Module   vendor.js:52
define   vendor.js:88532
(anonymous function)   vendor.js:88534
(anonymous function)   

So I'm guessing that I'm including it the wrong way.

I'm trying to avoid adding stuff to .jshintrc and making all import explicit instead, but no luck so far. So I tried that too:

Don't import d3 in my module, and instead just add d3 to jshint's predef. No luck either, same issue.

How have you guys been doing this?

Thanks!

1
This is absolutely not off topic. And the solution is very useful for anyone finding these errors.Edy Bourne

1 Answers

2
votes

I had the wrong loader.js version installed. Should be 1.0.1, and I had 2.1.1. Now everything works!