unjs / unenv

๐Ÿ•Š๏ธ Convert javaScript code to be runtime agnostic
MIT License
358 stars 19 forks source link

refactor(node:events): rewrite `EventEmitter` #128

Closed pi0 closed 1 year ago

pi0 commented 1 year ago

->

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

Checking a bundle size increase issue with @danielroe, we found out that EventEmitter class (used by HTTP modules) is not side-effect free and when referencing it from h3 (only unused import) bundlers add it to the runtime.

This rewrites the class entirely with modern syntax and smaller code. (there are slight behavior changes but i guess they should be fine)

๐Ÿ“ Checklist