Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix re-export of io module #1503

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/browser-entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import { io } from "./index.js";

export default io;
export { io as default } from "./index";
15 changes: 14 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ function lookup(

export { protocol } from "socket.io-parser";

// Manually create a merged object which acts as both the `lookup` function and
// a 'namespace' on which the other functionality is exported and available.
// This lets callers invoke the funtion directly as `io(...)` and also lets them
// invoke subvalues on it, e.g. `io.connect(...)`. This allows the browser
// entrypoint module to export this `io` as default, while still providing a
// more general ES module export below.
const io = Object.assign(lookup, {
Manager,
Socket,
io: lookup,
connect: lookup,
});

/**
* Expose constructors for standalone build.
*
Expand All @@ -90,6 +103,6 @@ export {
ManagerOptions,
Socket,
SocketOptions,
lookup as io,
io,
lookup as connect,
};