Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events API polyfilled badly? #16

Open
bmz1 opened this issue Nov 3, 2020 · 1 comment · May be fixed by #44
Open

Events API polyfilled badly? #16

bmz1 opened this issue Nov 3, 2020 · 1 comment · May be fixed by #44

Comments

@bmz1
Copy link

bmz1 commented Nov 3, 2020

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
Copy link

curran commented Jul 22, 2021

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

robertsLando added a commit to robertsLando/rollup-plugin-node-polyfills that referenced this issue Aug 9, 2022
Fixes ionic-team#16. This allows `const EventEmitter = require('events')` to work as intended
@robertsLando robertsLando linked a pull request Aug 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants