Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-126342

Math.js 9.4.4 and later does not work

    XMLWordPrintable

Details

    • Linux/Wayland, Windows

    Description

      Math.js is supposed to work on any ES6 compatible JavaScript engine, but versions newer than 9.4.3 does not work with Qt.

      This code works fine with Math.js 9.4.3

      import QtQuick
      import "math_943.js" as MathJs
      Window {
          width: 640
          height: 480
          visible: true
          title: math.version
      }

      but with version 9.4.4 you get this:

      qrc:/qt/qml/mjs/math_944.js:33: TypeError: Type error
      qrc:/qt/qml/mjs/Main.qml:7: ReferenceError: math is not defined
      

      The cause of the error seems to be this functions (as reported here: https://github.com/josdejong/mathjs/issues/2346#issuecomment-960484438)

      function(e,t,r)
      {
          var n=r(20),i=r(23),a=r(73);
          e.exports=n?
          function(e,t,r)
          {
              return i.f(e,t,a(1,r)) // <--------------- Type error
          }
          :
          function(e,t,r)
          {
              return e[t]=r,e
          }
      }

      The github discussion linked above have some additional details.

      With old Qt versions (like 6.2) you also had to replace all occurrences of
      "use strict";
      with
      ;"use strict";
      to get math.js 9.4.3 working but that seems to have been fixed

      The Math.js files (minified) are available here:
      Math.js 9.4.3: https://unpkg.com/mathjs@9.4.3/lib/browser/math.js
      Math.js 9.4.4: https://unpkg.com/mathjs@9.4.4/lib/browser/math.js

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtqmlteam Qt Qml Team User
              heneri Henrik Eriksson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes