crccheck / raphael-svg-import-classic

Import SVG files to Raphael
MIT License
98 stars 40 forks source link

CommonJS support #23

Closed konsumer closed 9 years ago

konsumer commented 9 years ago

CommonJS support for npm & browserify.

Example Usage (browserify & superagent):

var Raphael = require('raphael');
require('raphael-svg-import-classic');
var ajax = require('superagent');

ajax.get('assets/levels/level1.svg').end(function(err,res){
    var paper = Raphael(10, 10, 800, 600);
    var newSet = paper.importSVG(res.xhr.responseXML);
});
crccheck commented 9 years ago

does this affect AMD/requirejs users?

I've only used Raphael with requirejs once. Not planning on doing it again in production =)

konsumer commented 9 years ago

If they pre-require, it's the same. (AMD is asynchronous, unless it's already been included.)

konsumer commented 9 years ago

But, as a sidenote, it already wasn't working for AMD people.

crccheck commented 9 years ago

Ok, and I saved your example in https://github.com/crccheck/raphael-svg-import-classic/wiki/Module-Loaders

you can see the terrible terrible thing I did for requirejs there too.

konsumer commented 9 years ago

I'd also be happy to do a proper UMD wrap, if this is desired. My original goal was minimal codebase impact.

crccheck commented 9 years ago

agreed. I figured that'd happen eventually, but I'd prefer it happen organically rather than push complexity no one needs yet. This was written before I worried about such things.