css-ratiocinator
css-ratiocinator copied to clipboard
Simplify JS dependency inclusion
Code inside of lib/ needs to be included in both Phantom and a its simulated browser page. Phantom supports require() but the simulated page does not. This leads to weird code like this
var MODULE_NAME = (function () {
var my = {};
my.foo = function () { ... };
// etc...
if (typeof exports !== 'undefined') {
_.extend(exports, my);
}
return my;
}());
This way it uses exports if that exists, otherwise it declares a global variable for the module which a page can reference.
Simplify this!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
@joshuarh do you have any ideas?
You could move that helper somewhere, so it's not repeated, maybe something like browserify would help. I'm not sure I'd have to play with it a bit