Split main.js into CommonJS module files, fix #6