Skip to content

feat(socket.io-client): expose the standalone ESM bundle through the "./browser" subpath export - #5576

Open
saadkhantareen wants to merge 1 commit into
socketio:mainfrom
saadkhantareen:feat/socket-io-client-browser-export
Open

saadkhantareen wants to merge 1 commit into
socketio:mainfrom
saadkhantareen:feat/socket-io-client-browser-export

Conversation

@saadkhantareen

Copy link
Copy Markdown

Summary

The socket.io-client package ships a standalone ESM bundle (dist/socket.io.esm.min.js), but there is no subpath export for it, so users who want to import the client without a bundler (for example with Deno, or directly in the browser) have to copy the bundle locally or use a CDN URL instead of the npm package.

This adds a socket.io-client/browser subpath export pointing to that bundle, with the existing ESM type declarations:

import { io } from "socket.io-client/browser";

Changes

  • packages/socket.io-client/package.json: add a ./browser entry to exports, mapping types to ./build/esm/index.d.ts and default to ./dist/socket.io.esm.min.js (both paths are already included in the published files).
  • packages/socket.io-client/test/browser-export.ts: new tests asserting that the ./browser export is declared, that the files it points to exist, and that the subpath resolves through the package name.
  • packages/socket.io-client/test/index.ts: register the new test file.

Tests

  • npm run compile -ws --if-present — all workspaces compile successfully.
  • mocha --import=tsx --exit test/browser-export.ts test/url.ts (in packages/socket.io-client) — 12 passing (3 new browser export tests, 9 existing url tests).
  • npm run format:check (in packages/socket.io-client) — all matched files use Prettier code style.
  • Additionally verified by hand that require.resolve("socket.io-client/browser") resolves to dist/socket.io.esm.min.js and that the bundle exports io, Manager, Socket and protocol (5).

Fixes #5383

Copilot AI balanced review requested due to automatic review settings October 15, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

socket.io-client on the browser

2 participants