Problems importing justgage npm package _justgage2.default is not a constructor

Hello I´m trying to use the npm package of justgage, when I imported with

import { JustGage } from ‘justgage’;

And call

new JustGage(thisGage);

Where thisGage are the options of the package I get the following error in the Browser console:

TypeError: _justgage.JustGage is not a constructor
at . (body.js:21)
at view.js:199
at Function.Template._withTemplateInstanceFunc (template.js:465)
at view.js:197
at Object.Blaze._withCurrentView (view.js:538)
at viewAutorun (view.js:196)
at Tracker.Computation._compute (tracker.js:323)
at new Tracker.Computation (tracker.js:211)
at Object.Tracker.autorun (tracker.js:562)
at Blaze.View.autorun (view.js:209)

Where line 21 is the call to new JustGage(thisGage);

I´m using Meteor 1.3.

Any ideas?

Thank you

Try the default export: import JustGage from 'justgage'

Already try that and I get the same error, sorry for not mentioned before.

Did you ever figure this out? I think i might have to just fork it to make it all work. There has to be an easier way?

I had a look at the source, seems it doesn’t actually export anything, just declares a global - https://github.com/toorshia/justgage/blob/master/justgage.js#L8

// nothing to import
JustGage();

If you want to import:

// client/scripts/justgage.js
export default window.JustGage;

// client/file.js
import JustGage from '/client/scripts/justgage';

So you are saying you just copy and paste the script in? I think it would be much better to import it from npm. Plus you still need raphael and eve dependencies.

That second part was just so you still get the import benefit of knowing where it’s coming from

The justgage.js was literally just that export

I guess you could also:

import 'justgage';

JustGage();

https://www.npmjs.com/package/justgage-meteor

This way you can just drop it in.

note JustGage requires new keyword.

Thank you! I will try it

Sure. Let me know if it doesn’t work and I’ll help fix it.