Skip to content

Commit 6780f29

Browse files
fix: restore the default export (bis)
The previous commit, while successfully restoring support for: ```js const socket = require("socket.io-client")(...); ``` breaks for some other cases: - socketio/socket.io#4128 - #1509 According to [1], we should use `export = `, but this is not supported by module "esnext": > Export assignment cannot be used when targeting ECMAScript modules So we'll go for this ugly workaround, at least until we remove the default export in the next major release. [1]: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
1 parent ca614b2 commit 6780f29

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,6 @@ Object.assign(lookup, {
8080
connect: lookup,
8181
});
8282

83-
if (typeof module !== "undefined") {
84-
module.exports = lookup;
85-
}
86-
8783
/**
8884
* Protocol version.
8985
*

postcompile.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ cp ./support/package.esm.json ./build/esm/package.json
66
cp -r ./build/esm/ ./build/esm-debug/
77

88
sed -i '/debug(/d' ./build/esm/*.js
9+
10+
# for backward compatibility with `const socket = require("socket.io-client")(...)`
11+
echo -e '\nmodule.exports = lookup;' >> ./build/cjs/index.js

0 commit comments

Comments
 (0)