Major Changes
-
#33
39cf365Thanks @rexxars! - Require Node.js 22.12 or higher, drop the CommonJS build, and discard invalid lines instead of buffering themBreaking changes
- Node.js 18 and 20 are no longer supported.
enginesnow requires>=22.12, and the browserslist target moved fromnode >= 18tonode >= 22.12. Older versions may keep working, but they are no longer tested or guaranteed. - The CommonJS build has been removed. The
mainfield and therequireexport conditions are gone, so the package resolves to./dist/index.jsand./dist/stream.jsonly. Node 22.12 and above supportsrequire(esm)transparently, sorequire('eventsource-parser')continues to work there. - The root
stream.jsfile has been removed. It re-exported./dist/stream.cjsfor React Native and other bundlers without package exports support. Importeventsource-parser/streaminstead, and make sure your bundler resolves theexportsfield. - Invalid lines are now discarded as soon as the parser can tell they cannot become a valid SSE field, rather than being buffered until the line terminator arrives.
onErroris not called for these, and noline,field, orvalueis retained. Only lines that are complete when found to be invalid still produce aParseErrorwithtype: 'unknown-field'. This also meansreset({consume: true})no longer reports pending data that was already discarded. - Partial comment lines (starting with
:) are only buffered when anonCommentcallback is configured. Without one, they are discarded like any other line the parser has no use for.
Other changes
- A leading byte order mark is now stripped whether it arrives as a decoded
U+FEFF(for example from aTextDecodercreated withignoreBOM) or as the raw three byte0xEF 0xBB 0xBFsequence. Previously only the raw form was handled. - The README documented an
invalid-fielderror type that the parser never emitted. TheErrorTypeunion is unchanged; the documentation now correctly refers tounknown-field.
- Node.js 18 and 20 are no longer supported.