begriffs / css-ratiocinator

because your CSS is garbage
MIT License
1.03k stars 49 forks source link

Simplify JS dependency inclusion #40

Open begriffs opened 11 years ago

begriffs commented 11 years ago

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.

begriffs commented 11 years ago

@joshuarh do you have any ideas?

losingkeys commented 11 years ago

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