factor out mapgeneration and integrated CannonJS into frontend