Ua-parser-js currently only supports the CommonJS module structure. However, when attempting to export it, the export statement is not present:
if (typeof(exports) !== UNDEF_TYPE) {
// nodejs environment
if (typeof module !== UNDEF_TYPE && module.exports) {
exports = module.exports = UAParser;
}
exports.UAParser = UAParser;
} else {
// requirejs environment (if needed)
if (typeof(define) === FUNC_TYPE && define.amd) {
define(function () {
return UAParser;
});
} else if (typeof window !== UNDEF_TYPE) {
// browser environment
window.UAParser = UAParser;
}
}
Despite this limitation, why am I able to import UAParser using
import { UAParser } from 'ua-parser-js'
? This discrepancy was highlighted in the following Stack Overflow answer and GitHub issue: