ionic-team / ionic-team/rollup-plugin-node-polyfills
Events API polyfilled badly?
- Vorherrschende Sprache
- JavaScript
- Sterne
- 142
- Forks
- 65
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Start by reproducing the Snowpack build with async-mqtt and the rollup-plugin-node-polyfills handling of the events module. Inspect the generated events binding and compare it with the package's `class Parser extends events` usage. Done means the polyfilled events value can be extended without the reported constructor error.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, rollup
- Bereich
- build-system, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100