Move detection of CommonJS-style exports for amdFactory.
Use new getMetadata() function rather than metadata property.
Use window.location instead of document.location.

Chrome and IE will overwrite document.location if there is an element with the name "location". WTF