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

Events API polyfilled badly?

オープン
#16 コメント 1 件 リアクション 7 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
142
フォーク
65
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず、async-mqtt と rollup-plugin-node-polyfills による events モジュールの処理を使って Snowpack のビルドを再現します。生成された events バインディングを調べ、パッケージでの `class Parser extends events` の使用方法と比較します。報告されているコンストラクターエラーなしで polyfill された events の値を拡張できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, rollup
領域
build-system, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。