I have a class that uses toastr that works normally but fails after bundling. The class is Notify.js:
import 'bootstrap';
import toastr from 'toastr/toastr';
import 'toastr/toastr.css!';
export class Notify {
constructor() {
toastr.options = {
"closeButton": false,
"debug": false,
"positionClass": "toast-bottom-right",
"onclick": null,
"showDuration": "1000",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
};
}
notify( body, title, severity ) {
toastr[severity || 'info']( body, title );
}
}
I installed toastr with "jspm install toastr=github:CodeSeven/toastr". After bundling, the variable toastr in the constructor is {}, not the object that the toastr js creates, and thus in the notify() method, there is no function hanging off of it.
But things work ok before bundling. Am I importing incorrectly? The bottom of toastr.js looks like:
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
if (typeof module !== 'undefined' && module.exports) { //Node
module.exports = factory(require('jquery'));
} else {
window['toastr'] = factory(window['jQuery']);
}
}));
So I might wonder if there is a module.exports w/out bundling and after bundling, window.toastr might exist, but I tried that and its null (in the bundling case).