@eliasku/sockjs-client
v0.0.4
Published
A modern, browser-only SockJS client — rewritten in pure TypeScript ESM.
Readme
sockts
A modern, browser-only SockJS client — rewritten in pure TypeScript ESM.
This is a fork of sockjs-client stripped down to what matters in 2025: a clean ESM module with zero dependencies, no Node.js runtime support, no legacy browser workarounds, and no CommonJS artifacts.
Why
The original sockjs-client was designed around 2011-era constraints: IE6/7/8 support, Node.js http fallback transports, CommonJS require(), and the debug npm package for logging. Over a decade later, every one of those concerns is obsolete for modern applications. This library removes them all and ships a small, type-safe ESM module instead.
What changed
Format & language
- Pure TypeScript ESM — no
require(), nomodule.exports, no CommonJS export class/export function/export constthroughout (no default exports)- Arrow functions instead of
const self = thispatterns - Template literals instead of string concatenation
Date.now()instead of+new Date()"0".repeat(n)instead ofnew Array(n).join("0")- Rest parameters instead of
argumentsobject class extendsinstead of theinheritsnpm package- Native
URLconstructor instead ofurl-parsenpm package - Native
crypto.getRandomValues()instead of Node.jscrypto.randomBytes() - Project's own
EventEmitterinstead of Node.jseventsmodule console.logwith namespace prefixes instead of thedebugnpm package
Node.js support removed
- No
faye-websocket— uses browserWebSocketdirectly - No
eventsourcenpm package — uses browserEventSourcedirectly - No Node.js
http/https-based XHR driver - No
shims.ts(ES5 polyfills for old browsers) - No Node.js
crypto— uses Web Crypto API
Legacy browser support removed
- No
XDomainRequest(IE8-9) — deletedsender/xdr.ts,xdr-streaming.ts,xdr-polling.ts - No
ActiveXObject("htmlfile")— deletedreceiver/htmlfile.ts,transport/htmlfile.ts,createHtmlfile()fromutils/iframe.ts - No
ActiveXObject("Microsoft.XMLHTTP")fallback in XHR - No IE HTTP status code normalization (1223→204, 12005/12029→0)
- No
document.attachEvent/detachEventfallbacks —addEventListeneronly - No IE JSONP
script.htmlFor/script.onclickhack - No IE
<iframe name="...">createElement hack - No
script.onreadystatechange/iframe.onreadystatechangeIE workarounds - No Opera user-agent sniffing (
isOpera()) - No Konqueror user-agent sniffing (
isKonqueror()) - No Chrome packaged app detection (
chrome.app.runtime) - No
CollectGarbage()IE COM hint - No
doc.parentWindow— IE-specific window reference - No
!(this instanceof Constructor)pattern (impossible with ESclass) - No
protocols_whitelistdeprecated option support
Dependencies removed
debug— replaced withconsole.lognamespaced callseventsource— browserEventSourceused directlyfaye-websocket— browserWebSocketused directlyinherits— nativeclass extendsurl-parse— nativeURLconstructor
Building
bun run buildOutputs ESM bundle to dist/sockjs.js with TypeScript declarations via rolldown + tsc.
Testing
bun testType checking
bun run typecheck