sciactive / pnotify

Beautiful JavaScript notifications with Web Notifications support.
https://sciactive.com/pnotify/
Apache License 2.0
3.65k stars 513 forks source link

PNotify not defined or not a constructor #328

Closed AdrianKuriata closed 6 years ago

AdrianKuriata commented 6 years ago

Hi, i updated to newest alpha version PNotify and tried use it with bootstrap4 and fontawesom4. Every time got error when import it with webpack like umd, es or iife. Just only when i imported ES module and use

PNotify.default.defaults.styling = "bootstrap4";
        PNotify.default.defaults.icons = "fontawesome4";

        PNotify.default.alert({

Just start working, when i tried use PNotify.defaults and PNotify.alert i got error this is not defined. So if someone have a problem like me, just need tu use PNotify.default.defaults etc.

hperrin commented 6 years ago

If you're importing UMD, it will be the export called "default". You can use something like this:

requirejs(['PNotify'], function(PNotify){
  PNotify = PNotify && PNotify.__esModule ? PNotify["default"] : PNotify;
  PNotify.notice({
    title: "Yay!",
    text: "It works!"
  });
});
amoshydra commented 6 years ago

Changing

import PNotify from 'pnotify';

to

import PNotify from 'pnotify/dist/es';

Works for me on 4.0.0-alpha.2 on webpack

fnlopez10 commented 4 years ago

import PNotify from 'pnotify/dist/es/PNotify'; import PNotifyButtons from 'pnotify/dist/es/PNotifyButtons'; PNotify.defaults.styling = 'bootstrap4'; PNotify.defaults.icons = 'fontawesome5';

PNotify.notice({ title: 'Animate.css Effect', text: 'I use effects from Animate.css. Such smooth CSS3 transitions make me feel like butter.', modules: { Animate: { animate: true, inClass: 'bounceInLeft', outClass: 'bounceOutRight' } } });