convert to a common node/broswer compatibility practice

http://www.matteoagosti.com/blog/2013/02/24/writing-javascript-modules-for-both-browser-and-node/
also, in generate.js, serialize the rules in a more diff'able style