Factor out serialize.js from compiler.js