ahmedshuhel / aurelia-cli

Aurelia CLI tool
5 stars 0 forks source link

Problem with toastr when bundling #4

Open peebles opened 9 years ago

peebles commented 9 years ago

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).

ahmedshuhel commented 9 years ago

@peebles Please report it here.

peebles commented 9 years ago

Done. a

On Wed, Jun 24, 2015 at 3:22 PM, Shuhel Ahmed notifications@github.com wrote:

@peebles https://github.com/peebles Please report it here https://github.com/aurelia/cli/issues.

— Reply to this email directly or view it on GitHub https://github.com/ahmedshuhel/aurelia-cli/issues/4#issuecomment-115028906 .