Ua-parser-js only supports the CommonJS module. And when exporting, the export statement is not found:
if (typeof(exports) !== UNDEF_TYPE) {
// nodejs env
if (typeof module !== UNDEF_TYPE && module.exports) {
exports = module.exports = UAParser;
}
exports.UAParser = UAParser;
} else {
// requirejs env (optional)
if (typeof(define) === FUNC_TYPE && define.amd) {
define(function () {
return UAParser;
});
} else if (typeof window !== UNDEF_TYPE) {
// browser env
window.UAParser = UAParser;
}
}
Nevertheless, why can I import UAParser by import { UAParser } from 'ua-parser-js'
? This code was shown in the following SO answer and GitHub issue.