soulwire / sketch.js

Cross-Platform JavaScript Creative Coding Framework
MIT License
4.09k stars 431 forks source link

Add UMD support #61

Closed JSteunou closed 10 years ago

JSteunou commented 10 years ago

Should fix #60

The diff seems pretty messy because of the re-indent. You should merge this one in very last. To sum it up, all I did was wrapping Sketch around this.

(function (root, factory) {
    if (typeof exports === 'object') {

        // CommonJS like
        module.exports = factory(root, root.document);

    } else if (typeof define === 'function' && define.amd) {

        // AMD
        define(function() { return factory(root, root.document); });

    } else {

        // Browser global
        root.Sketch = factory(root, root.document);

    }

}(this, function (window, document) {

   // old Sketch go re-indented here

    return Sketch;

}));
JSteunou commented 10 years ago

@soulwire I updated it from master, so it's ready to merge ;)

JSteunou commented 10 years ago

Thank you for all the morning quick merges @soulwire that was terrific!

soulwire commented 10 years ago

Thanks for the commits @JSteunou! (and those who I hadn't merged but whose code is now in there). I've pushed one more commit with the minified version.

JSteunou commented 10 years ago

Nice!

You should also make a bower.json and register your lib to bower registry. Your lib is a must have for playing with canvas and it will be nice to have it directly from bower, now it's AMD/CommonJS :p