I want to use Draw2D touch in an AMD environment. The library itself isn't AMD compliant but depends on some other - AMD compliant - libraries like Raphael and Shifty. So I set up a shim config for Draw2D (relevant parts included):
requirejs.config({
paths : {
// ...
'shifty': 'lib/shifty',
'raphael': 'lib/raphael',
'draw2d': 'lib/draw2d-2.10.1.min'
},
shim: {
// ...
'shifty': {
exports: 'Tweenable'
},
'raphael': {
exports: 'Raphael'
},
'draw2d': {
exports: 'draw2d',
deps: ['jquery', 'Class', 'raphael', 'json2', 'canvg',
'rgbcolor', 'jquery.layout', 'jquery.contextmenu',
'jquery.touch_punch', 'jquery.autoresize', 'shifty',
'plugins-js', 'jquery.ui.custom']
}
}
});
Draw2D tries to access Raphael (and Shifty) globally:
function() {
Raphael.fn.group
...
}
even with the shim config I'm getting ReferenceError
because Raphael is not defined.
The question is basically, how to load a library which isn't AMD compliant but relies on AMD compliant libraries.