Add commonjs support

Fixes #62,#63,#64 and #81.