1

I am trying to use a library called techan.js with Ember. It is dependent on d3.js.

In my Brocfile.js, I have:

app.import('bower_components/d3/d3.js'); app.import('bower_components/TechanJS/dist/techan.js');

However, when I run the app, there is an error because d3 is not defined when it is running techan.

When using an AMD library like Requirejs, you can define dependencies and get them to load in the right order. Does Ember have a similar capability?

ttrasn
  • 4,322
  • 4
  • 26
  • 43
Joe
  • 7,922
  • 18
  • 54
  • 83

1 Answers1

0

Yes, ember supports libraries with dependencies. After all steps you did you just should declare d3 and tech as globals to avoid error you see.

//console
bower install --save andredumas/techan.js

//Brocfile.js
...
app.import('bower_components/d3/d3.js');
app.import('bower_components/TechanJS/dist/techan.js');
module.exports = app.toTree();

//.jshintrc
{
  "predef": [
    //...,
    "d3",
    "techan"
  ],
  // ...
}

//console
ember server
artych
  • 3,669
  • 1
  • 17
  • 30
  • I'm afraid that just doesn't work. TechcanJS does not have d3 in scope when it loads. – Joe Jun 12 '15 at 17:22
  • I've created new ember-cli app (0.2.7), make your steps done and I've seen error you mentioned. Error dissapired after I modify "predef". – artych Jun 12 '15 at 17:29
  • I even was able to draw candlestick plot – artych Jun 12 '15 at 22:27
  • And this time it worked for me, but not because I put in predef. I think it decides what to load first randomly, so it may or may not work. I'm pretty sure predef tells JSHint not complain, it doesn't actually effect how things are loaded. – Joe Jun 12 '15 at 23:51