Converting JS to AMD modules loaded by require.js