export.js: Export in all CommonJS environments

Closes #521
This is too complicated. Just do `document = window.document`. Or just check for `window.document` where needed below.