ClojureScript

Wrong order of lines in compiled javascript

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

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.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: