Repository navigation
feat(socket.io-client): expose the standalone ESM bundle through the "./browser" subpath export - #5576
Open
saadkhantareen wants to merge 1 commit into
Conversation
…"./browser" subpath export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
socket.io-clientpackage 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/browsersubpath export pointing to that bundle, with the existing ESM type declarations:Changes
packages/socket.io-client/package.json: add a./browserentry toexports, mappingtypesto./build/esm/index.d.tsanddefaultto./dist/socket.io.esm.min.js(both paths are already included in the publishedfiles).packages/socket.io-client/test/browser-export.ts: new tests asserting that the./browserexport 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(inpackages/socket.io-client) — 12 passing (3 newbrowser exporttests, 9 existingurltests).npm run format:check(inpackages/socket.io-client) — all matched files use Prettier code style.require.resolve("socket.io-client/browser")resolves todist/socket.io.esm.min.jsand that the bundle exportsio,Manager,Socketandprotocol(5).Fixes #5383