MSW v3.0 drops CommonJS, slashes bundle size, and intercepts traffic at the socket level
Original headline: Mock Service Worker Releases v3.0 with ESM-Only Build, Socket-Based Interception and GraphQL Subs — infoq.com
More in Programming and developer news
Mock Service Worker (MSW), the popular API mocking library, has launched version 3.0. This major release, arriving nearly three years after the last rewrite, ditches CommonJS entirely and ships as pure ECMAScript Modules (ESM). It requires newer versions of Node.js and TypeScript, removes several dependencies, and nearly halves the library's total size. Notable new features include dedicated entrypoints for different protocols (HTTP, GraphQL, Server-Sent Events, WebSockets) and long-awaited native support for GraphQL subscriptions, finally completing its GraphQL feature set.
The update delivers a more granular, modular API and introduces an experimental `defineNetwork` primitive designed to eventually replace the current setup methods, offering more control over traffic sources and handlers. For developers, the most significant technical leap is under the hood: MSW's new Node.js interception now works at the TCP/TLS socket level, going as deep into the runtime as possible without modifying Node.js itself. This opens the door for mocking arbitrary socket-based protocols, moving MSW from a purely HTTP-focused tool to a more comprehensive network simulation layer for testing.
Read the original at infoq.com
Satirical commentary on real tech news, summarised with AI. Read the original source for the facts. How ZeroDaily works
