https://github.com/auth0/jwt-decode
This javascript code (simplified lib/index.js):
`
'use strict';
function InvalidTokenError(message) {}
InvalidTokenError.prototype = new Error();
InvalidTokenError.prototype.name = 'InvalidTokenError';
module.exports = function (token,options) {};
module.exports.InvalidTokenError = InvalidTokenError;
`
is compiled to:
var module$node_modules$jwt_decode$lib$index={};
module$node_modules$jwt_decode$lib$index["default"].InvalidTokenError=function(message){};
module$node_modules$jwt_decode$lib$index["default"].InvalidTokenError.prototype=new Error;
module$node_modules$jwt_decode$lib$index["default"].InvalidTokenError.prototype.name="InvalidTokenError";
module$node_modules$jwt_decode$lib$index["default"]=function(token,options){}
It's failing with "Uncaught TypeError: Cannot set property 'InvalidTokenError' of undefined" - second line. In original code the function is exported first and then InvalidTokenError is assigned while in compiled code InvalidTokenError is assigned first to not yet ready "default" property.