stacktrace.js icon indicating copy to clipboard operation
stacktrace.js copied to clipboard

How to load stacktrace-gps with RequireJS?

Open oguzhaneren opened this issue 9 years ago • 1 comments

I want to try loading stacktrace.js with below configuration and its working. But I can't access stacktrace-gps from stackTrace module because its a different module. How can I load stacktrace-gps with RequireJS? (I assume stacktrace.js include all tools, its a bundle)

Thanks,

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

require(["stacktrace"],function(stackTrace){
    stackTrace.fromError()...
});

oguzhaneren avatar Aug 22 '16 18:08 oguzhaneren

@oguzhaneren Did you get it working? I'm trying to do the same thing, but with TypeScript. The index.d.ts file (that I got from npm install @types/stacktrace-js --save-dev) exports stacktrace-js. so import 'stacktrace-js'; is working with TypeScript compiling (that translates to require(['stacktrace-js'], function(stackTrace){});)

The d.ts file has declare module "stacktrace-js" { export = StackTrace; }

However, I'm getting Uncaught ReferenceError: StackTrace is not defined. TypeScript thinks that StackTrace is something instead of just a namespace and compiles to StackTrace.fromError(error).then(callback).catch(errback);.

Changing the import to import * as stacktrace from 'stacktrace-js'; got everything working.

Maybe this will help someone.

aligneddev avatar Oct 27 '16 20:10 aligneddev