ionic-team / rollup-plugin-node-polyfills

MIT License
139 stars 59 forks source link

Events API polyfilled badly? #16

Open bmz1 opened 4 years ago

bmz1 commented 4 years ago

Hey there,

I am using Snowpack to deal with dependencies. I am aware that Snowpack uses rollup-plugin-node-polyfills to polyfill Node built-in modules. I'd like to use a package called async-mqtt which relies on node built-in modules (events, stream, buffer). So I installed it with Snowpack, and polyfilled it with this plugin. However, I noticed that the polyfilling process did something strange. I got an error: Class extends value [object Object] is not a constructor or null

Now, this error applies for the following code: class Parser extends events. So I checked what is the value of events, and it turns out, that events is an object instead of a class:

var events = /*#__PURE__*/Object.freeze({
  __proto__: null,
  'default': EventEmitter,
  EventEmitter: EventEmitter
});

Obviously, you cannot extend a class from an object like this. How can I resolve this issue? Thanks.

curran commented 3 years ago

A minimal reproduction repository would be most useful to debug this.