minutemailer / react-popup

React popup component
http://minutemailer.github.io/react-popup/
MIT License
208 stars 71 forks source link

Missed `events` package causes crash #68

Open berdyshev opened 3 months ago

berdyshev commented 3 months ago

The PopupStore class extends EventEmitter class from events package. There is a standard NodeJS library with such a name and a kind of polyfil as events package on NPM. Usually it might be already installed as a dependency in your project by other tools (in my cause it's webpack and its plugins) But if not, the react-popup package might brake an app.

Once I replaced Webpack with Vite the app broke with the following error:

Uncaught TypeError: Super expression must either be null or a function
    at _inherits (react-popup.js?v=5c9bd9e2:367:15)
    at react-popup.js?v=5c9bd9e2:430:7
    at node_modules/react-popup/dist/Store.js (react-popup.js?v=5c9bd9e2:506:6)

So, I would recommend to either add the events library as a dependency, or find another way to implement event emitting using browser's native APIs (e.g. EventTarget).