Add support for AMD (e.g. require.js)

Fixes #223.