How to get stacktracejs working with requirejs amd modules

220 views Asked by At

Library: Library repo that im using

I just don't think I am getting the point of requirejs that leads me to be incapable of loading in StackTrace from the stacktrace js library.

I have stacktrace-with-promises-and-json-polyfills.min.js saved under js/lib/stacktrace.js (I renamed it for a shorter version).

In my config, I tried to add:

requirejs.config({
    paths: {
        "stacktrace": "js/lib/stacktrace"
    }
});

Which did not work so I removed them, yet I am able to grab the library from another js module thru:

define(['lib/stacktrace'], function(StackTrace) {

    // function is on page load
    function onPageLoad() {
        console.log(StackTrace);
        StackTrace.get().then(/* defined callback */).catch(/*defined */);
    }
}

Which is really strange to me that it prints out this with error:

Console logging StackTrace

I can log the object but all the functions are lost. I have tried with the original stacktrace.min.js too. Sometimes StackTrace is undefined.

Looking back, I have no idea on how to write a requirejs config to allow stacktrace js library to become a module. Please help.

1

There are 1 answers

0
Eric Wendelin On BEST ANSWER

I totally broke using dist/stacktrace.js with module loaders like RequireJS. I'm sorry.

The good news is: I just fixed it. Please give stacktrace.js v1.3.1 a try and let me know if it works for you.