ionic-team / ionic-team/rollup-plugin-node-polyfills

Events API polyfilled badly?

Open
#16 1 comment 7 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
142
Forks
65
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.