Uploaded image for project: 'ClojureScript'
  1. CLJS-2936

Wrong order of lines in compiled javascript

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: 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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: