diff --git a/lib/index.ts b/lib/index.ts index cfae547d..958cb623 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -80,10 +80,6 @@ Object.assign(lookup, { connect: lookup, }); -if (typeof module !== "undefined") { - module.exports = lookup; -} - /** * Protocol version. * diff --git a/postcompile.sh b/postcompile.sh index 5c3aa390..e243e869 100755 --- a/postcompile.sh +++ b/postcompile.sh @@ -6,3 +6,6 @@ cp ./support/package.esm.json ./build/esm/package.json cp -r ./build/esm/ ./build/esm-debug/ sed -i '/debug(/d' ./build/esm/*.js + +# for backward compatibility with `const socket = require("socket.io-client")(...)` +echo -e '\nmodule.exports = lookup;' >> ./build/cjs/index.js