Closed Frando closed 2 years ago
👎🏻 use standard exports
field instead.
I don't think this is a decision to be taken lightly.
Personally, I feel that this module is not a great fit for the browser even when using polyfills for http
, https
, url
and similar, since it adds a significant amount of code and complexity. Having said that, this PR would be a big breaking change, and will only work in browsers with a native EventSource implementation. While that is thankfully the case for most modern browsers, it is not a drop-in replacement. For instance, the second argument to the constructor does not provide any way to specify headers in the browser, so it creates a mismatch in behavior between node and the browser which is annoying to deal with.
Hi, this PR adds a
browser
field topackage.json
, with abrowser.js
that re-exportswindow.EventSource
in CommonJS format. This makes the package easily compatible with CommonJS based bundlers (e.g. vite).