We're updating the issue view to help you get more done. 

Wrong order of lines in compiled javascript

Description

https://github.com/auth0/jwt-decode

This javascript code (simplified lib/index.js):

1 2 3 4 5 6 7 8 9 '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:

1 2 3 4 5 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.

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

None

Patch

None

Priority

Major