0

I am having difficulty declaring the cubism's dependency on d3, when using require.js.

Config is as:

requirejs.config({
  baseUrl: './',
  paths: {
    'jquery': './jquery-1.10.2.min',
    'd3': './d3.min',
    'cubism': './cubism.v1'
 },
 shim: {
    cubism: {
        deps: ['d3']
    }
 }
});

The error I am getting is:

cubism.v1.js:187 Uncaught ReferenceError: d3 is not defined
at cubism.v1.js:187
at cubism.v1.js:1331

Please help find me where I did wrong?

Moh Moh Oo
  • 269
  • 1
  • 3
  • 19

1 Answers1

0

Cubism is not loading as expected when using require.js in my case. I have a workaround to this issue where I change the requirejs config as:

requirejs.config({
baseUrl: './',
paths: {
    jquery: './jquery-1.10.2.min',
    d3: 'http://d3js.org/d3.v3.min',
    cubism_v1: './cubism.v1'
},
shim: {
    cubism_v1: {
        deps: ['d3']
    }
}
});

And declare another module as:

define('cubism', ['cubism_v1'], function (cubism) {
   return this.cubism; 
});

Then I am able to use cubism in other places as required.

requirejs(['jQuery', 'd3', 'cubism'], function (jQuery, d3, cubism) {
   // cubism related code here
});
Moh Moh Oo
  • 269
  • 1
  • 3
  • 19