v0.14.0
Better SSE Version 0.14.0
npm install better-sse@latestyarn add better-sse@latestpnpm add better-sse@latestThis release includes fixes for minor issues when importing the package into an ESM module as well as to the TypeScript types for the createSession and createChannel factory functions.
ESM Import Fixes
For consumers using ESModules (with either JavaScript or TypeScript) to import the package, named exports did not work and you would have to extract individual exports out of the default-exported object:
// Before
import sse from "better-sse";
const { createSession } = sse;This has now been fixed and importing the package will work correctly with both ESM and CJS, allowing you to use named imports directly:
// After
import { createSession } from "better-sse";If you still wish to group your imports under an sse namespace, you can use a namespace import:
import * as sse from "better-sse";Factory Function Type Fixes
Previously, when creating a session or channel with createSession or createChannel, if no explicit type is given to the first generic State, the type of the returned Session#state or Channel#state properties would be incorrectly set to unknown rather than DefaultSessionState or DefaultChannelState, respectively:
// Before
const session = await createSession(req, res);
const channel = createChannel();
session.state; // unknown
channel.state; // unknownThis has now been fixed:
// After
const session = await createSession(req, res);
const channel = createChannel();
session.state; // DefaultSessionState
channel.state; // DefaultChannelStateFull Changelog
Fixed
- Fixed default state type when creating sessions and channels with
createSessionandcreateChannelbeing set tounknowninstead ofDefaultSessionStateandDefaultChannelState, respectively. - Fixed package directly exporting a single object containing exports, breaking named imports when using ESModules, and instead dual-export two separate builds to support both ESM and CJS.
Removed
- Dropped support for Node 17 and below.