jetersu / jsplumb

Automatically exported from code.google.com/p/jsplumb
0 stars 0 forks source link

Add require.js support #333

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please add [require.js](http://www.requirejs.org/) support so that jsPlumb can 
be loaded via AMD.

Original issue reported on code.google.com by jgood...@gmail.com on 9 Apr 2013 at 4:07

GoogleCodeExporter commented 8 years ago
jsplumb already does have require.js support - at least, i think it does, 
because i've not really used require.js myself and so i am not 100% sure i have 
done it correctly.  if you could take a look at this:

https://github.com/sporritt/jsPlumb/tree/master/tests/miscellaneous/jquery-requi
re-sample/webapp-build

and let me know your thoughts i'd appreciate it.

Original comment by simon.po...@gmail.com on 10 Apr 2013 at 10:15

GoogleCodeExporter commented 8 years ago
have you had a chance to look at this?  

Original comment by simon.po...@gmail.com on 15 Apr 2013 at 9:31

GoogleCodeExporter commented 8 years ago
I think it works. In my main.js I need to use the shim, which usually isnt 
necessary for libraries that have require support, so maybe it is because it is 
a jquery plugin?

require.config({
  shim: {
  , jquery: {
      exports: '$'
    }
  , jsPlumb: {
      deps: ['jquery']
    , exports: 'jsPlumb'
    }
  }

, paths: {
    jquery: '../components/jquery/jquery'
  , jsPlumb: '../components/jsPlumb/build/1.3.16/js/jquery.jsPlumb-1.3.16-all'
  }
});

Original comment by jgood...@gmail.com on 17 Apr 2013 at 5:34

GoogleCodeExporter commented 8 years ago
um, i'm not sure....i've not used require.js.  

i see a discussion of the shim here:

http://requirejs.org/docs/api.html#config-shim

it's for "traditional, browser global" scripts, which i guess applies to 
jquery.  did you notice in my example i was using a special version of jquery?  
i got that example from their site (i think):

https://github.com/sporritt/jsPlumb/blob/master/tests/miscellaneous/jquery-requi
re-sample/webapp-build/scripts/require-jquery.js

...it has the require stuff built into it.  

Original comment by simon.po...@gmail.com on 17 Apr 2013 at 8:07

GoogleCodeExporter commented 8 years ago
i'm calling this done. i've added the test page into the demos in jsplumb. well 
its in a branch right now but it will be on master when i get the 1.4.0 release 
out.

Original comment by simon.po...@gmail.com on 30 Apr 2013 at 11:24