Skip to content

Instantly share code, notes, and snippets.

View rtm-ctrlz's full-sized avatar

Ilia Urvachev rtm-ctrlz

View GitHub Profile
@rtm-ctrlz
rtm-ctrlz / WDSSocket-failsafe.js
Created July 6, 2026 22:10
react-refresh-webpack-plugin WDS-6 fix candidates
/**
* Initializes a socket server for HMR for webpack-dev-server.
* @param {function(*): void} messageHandler A handler to consume Webpack compilation messages.
* @returns {void}
*/
function initWDSSocket(messageHandler) {
let SockJSClient;
try {
// that still produces compilation warning
({ default: SockJSClient } = require('webpack-dev-server/client/clients/SockJSClient'));