Skip to content

Update eventsource and remove no-eventsource build - #1395

Merged
Ryang-21 merged 4 commits into
modernizationfrom
update-eventsource
Apr 23, 2026
Merged

Update eventsource and remove no-eventsource build#1395
Ryang-21 merged 4 commits into
modernizationfrom
update-eventsource

Conversation

@Ryang-21

Copy link
Copy Markdown
Contributor

What

Upgrade the eventsource dependency from v2.0.2 to v4.1.0, migrate to the named-export import form in src/horizon/call_builder.ts, and drop the no-eventsource build variant.

The build-variant removal touches package.json (exports entries + build:*:no-eventsource scripts), config/build.config.js, config/webpack.config.browser.js, babel.config.js, all four vitest.config*.ts files, config/.jsdoc.json, test/setup-browser.ts, src/index.ts (dead __USE_EVENTSOURCE__ fallback), src/bindings/config.ts (stale comment), and README.md. CHANGELOG entries are left intact as historical release notes.

The dom monkeypatch file was removed as the tsconfig now includes DOM types via the lib field

Two streaming test cases in test/integration/client_headers.test.ts also had to change: they previously threw inside onerror to signal "this path shouldn't fire." v4's spec-compliant EventTarget surfaces listener throws as uncaught exceptions where v2 silently swallowed them, so the throws now close the stream instead.

Why

The no-eventsource variant was originally introduced to support the Cloudflare Workers runtime (workerd) and similar environments that didn't provide the Node http/https modules the v2 eventsource package depended on. For those consumers, building without eventsource was the only way to import the SDK at all.

v4.1.0 replaces the Node transport with fetch, which is available natively in browsers, Node 20+ (our minimum), Deno, Bun, and workerd. Every supported runtime can now import the SDK with streaming included, which eliminates the reason the variant existed in the first place.

Removing the dynamic require of eventsource allows for the library to work towards ESM complient code.

Browser consumers will carry some duplication because browsers ship a native EventSource. That's acknowledged, but the eventsource dependency contributes well under 2 KB to the bundle — small enough that collapsing the build matrix from three configurations down to two (default + axios) is clearly the better trade. Fewer bundles to build, publish, and test; fewer stale code paths; one less flag for downstream users to reason about.

@socket-security

socket-security Bot commented Apr 22, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedeventsource@​2.0.2 ⏵ 4.1.099 -1100100 +284100

View full report

@Ryang-21 Ryang-21 linked an issue Apr 22, 2026 that may be closed by this pull request
3 tasks

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.

Pull request overview

Upgrades the SDK’s streaming implementation to use [email protected] and simplifies the build/test matrix by removing the no-eventsource build variant across packaging, build configs, and docs.

Changes:

  • Bump eventsource from ^2.0.2 to ^4.1.0 and switch Horizon streaming to the new import style.
  • Remove the no-eventsource bundle/exports/scripts and associated __USE_EVENTSOURCE__ plumbing.
  • Adjust browser setup and integration streaming tests to match eventsource@4 error behavior.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Updates eventsource dependency graph; removes @types/eventsource.
types/dom-monkeypatch.d.ts Deletes custom DOM type monkeypatch file.
test/setup-browser.ts Stops attempting to load the removed no-eventsource bundle variant.
test/integration/client_headers.test.ts Updates streaming tests’ onerror handling to close streams instead of throwing.
src/rpc/index.ts Removes triple-slash reference to deleted DOM monkeypatch.
src/index.ts Removes triple-slash reference and dead __USE_EVENTSOURCE__ fallback.
src/horizon/call_builder.ts Switches to EventSource named import and removes gating by __USE_EVENTSOURCE__.
src/bindings/config.ts Updates comment to remove stale no-eventsource reference.
package.json Removes no-eventsource exports/scripts; bumps eventsource version; drops @types/eventsource.
config/webpack.config.browser.js Removes no-eventsource naming/define logic from browser build.
config/vitest.config.ts Removes lib/no-eventsource from coverage excludes and drops __USE_EVENTSOURCE__ define.
config/vitest.config.e2e.ts Same as above for e2e config.
config/vitest.config.browser.ts Drops __USE_EVENTSOURCE__ define for browser tests.
config/vitest.config.axios.ts Drops __USE_EVENTSOURCE__ define for axios unit tests.
config/build.config.js Removes useEventSource build flag.
config/.jsdoc.json Stops excluding generated lib/no-eventsource docs.
babel.config.js Removes __USE_EVENTSOURCE__ constant injection.
README.md Removes USE_EVENTSOURCE / no-eventsource build documentation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 16 to 21
@@ -24,20 +21,6 @@ export interface EventSourceOptions<T> {
reconnectTimeout?: number;
Comment on lines +96 to 98
onerror: () => {
closeStream();
},
Comment on lines +295 to 297
onerror: () => {
closeStream();
},
@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown

Size Change: -14.8 MB (-43.03%) 🎉

Total Size: 19.6 MB

📦 View Changed
Filename Size Change
dist/stellar-sdk-axios.js 5.41 MB -899 kB (-14.25%) 👏
dist/stellar-sdk-axios.min.js 4.54 MB -816 kB (-15.24%) 👏
dist/stellar-sdk-no-eventsource.js 0 B -6.19 MB (removed) 🏆
dist/stellar-sdk-no-eventsource.min.js 0 B -5.2 MB (removed) 🏆
dist/stellar-sdk.js 5.29 MB -899 kB (-14.52%) 👏
dist/stellar-sdk.min.js 4.38 MB -816 kB (-15.69%) 👏

compressed-size-action

@Ryang-21
Ryang-21 merged commit ce1e1a8 into modernization Apr 23, 2026
7 checks passed
@Ryang-21
Ryang-21 deleted the update-eventsource branch April 23, 2026 23:10
@github-project-automation github-project-automation Bot moved this from Backlog (Not Ready) to Done in DevX Apr 23, 2026
@Ryang-21 Ryang-21 mentioned this pull request Jun 5, 2026
Ryang-21 added a commit that referenced this pull request Jun 5, 2026
* [Modernization] Make fetch default (#1394)

* Replace __USE_AXIOS__ dynamic require with static fetch default

* Add babel and webpack aliasing to emit axios variant from shared source

* Flip package.json exports: fetch default, /axios opt-in, drop /no-axios

* Update eventsource and remove no-eventsource build (#1395)

* update eventsource to v4.1.0 and remove conditional import of eventsource

* remove the dom-monkeypatch as its now included in the tsconfig lib field

* build and export cjs and esm build varients, remove export of umd bundles

* Base Migration (#1399)

* move stellar-base src under src/base

* migrate from classic yarn to pnpm (#1400)

* remove randomBytes for universal crypto.getRandomValues

* replace sha.js with noble/hashes and update to version 2.2.0

* update BigNumber to v11.0.0

* replace noble/curves with noble/ed25519 for reduced bundle size

* replace toml with smol-toml

* replace URI for native URL (#1402)

* refactor: replace URI usage for native URL + URLSearchParam objects

* allow expandUriTemplate to handle relative templated links

* Tooling modernization: Node 22, husky v9, pnpm minimumReleaseAge, drop nyc (#1408)

* Update husky config + remove nyc

* Root .nvmrc + bump Node to v22

* pnpm minimumReleaseAge config

* Use pnpm workspace (#1417)

* New docs (#1413)

* TypeDoc setup

* P27 updates (#1429)

* Update XDR base URLs and improve Makefile for TypeScript definitions

* pull and regenerate xdr definitions for p27

* handle signing the new SorobanCredential varients

* add CAP-71 delegate-credential signing helpers

  - buildAuthorizationEntryPreimage: expose the signature payload (authorizeEntry
    now builds its preimage through it)
  - buildWithDelegatesEntry: wrap ADDRESS/ADDRESS_V2 into ADDRESS_WITH_DELEGATES,
    sorting + de-duping delegates; top-level signature defaults to Void
  - authorizeEntry: optional forAddress to fill a specific node (top-level or a
    delegate) instead of always the top-level
  - export the new helpers + DelegateSignature/BuildWithDelegatesParams from base

* Update readme + pre-push check for docs (#1430)

* Pre-push hook + updated docs

* Update pre-push hook

* Add @stellar/stellar-base migration guide to the installation docs

* Map xdr.HashIdPreimage in typedoc to fix docs:reference build

---------

Co-authored-by: oceans404 <[email protected]>

* Tx builder type regression (#1438)

* Implement TransactionSource interface for Account and MuxedAccount classes; update TransactionBuilder to use TransactionSource

* TSDoc: Replace @internal with @ignore tag (#1436)

* TSDoc: Replace @internal with @ignore tag

* Add friendbot call builder items

* Dependency updates (#1433)

* Minor: axios + bignumber.js

* Patch: vitest + @vitest

* Minor astro + patch @astro

* Minor: esbuild to v0.27.7 (not latest v0.28.0)

* Some patch + minor

* Major: @rollup/plugin-commonjs

* Major: cross-env + dotenv

* Major: jsdom

* Updated pnpm-lock

* Auth flag namespace (#1441)

* add back AuthFlag namespace

* fix: update build types script for axios to ensure generated types are copied correctly

* P27 guide (#1440)

* add p27 guide

* docs: add task-oriented guides (connect-and-fund, send-a-payment) + internal-link tooling (#1434)

* docs: add internal-link tooling (base-prefix rewriting + dead-link validation)

* docs: add connect-and-fund and send-a-payment guides

* docs: add issue-an-asset guide

* docs: refine issue-an-asset guide (token framing, typed helper, review fixes)

* docs: add query-and-stream guide

* docs: add handle-errors guide

* docs: link guides 02-04 to the handle-errors guide

Add error-handling pointers now that guide 05 exists (sibling-link upgrade):
a primary pointer in guide 02's submit section and lighter pointers in 03/04.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: add invoke-a-contract guide (06)

Teaches invoking a deployed Soroban contract from JS with contract.Client and
AssembledTransaction: connect over RPC, preview a call by simulation, then sign
and send a state change. Uses the increment contract; deployment is linked out
to the Stellar CLI tutorial. Regenerate llms bundles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: add contract-auth guide (07)

Covers signing Soroban contract authorization for an account other than the
transaction source, framed for AddressV2 (CAP-0071-02) readiness: the same code
is correct on the legacy ADDRESS credential today and on AddressV2 after the
Protocol 28 flip. Distinguishes envelope signing from authorization-entry
signing, and gives a before/after migration for hand-rolled signers
(buildAuthorizationEntryPreimage / authorizeEntry).

Also upgrades the Invoke a Contract guide's closing link to point at this guide,
replaces numbered guide references with named links, and regenerates the llms
bundles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: fold versioning into the home page, drop it as a guide

Versioning and compatibility is reference material, not a task how-to, so it
moves out of the guides nav into a 'Versioning and compatibility' section on the
home page (README -> index). Repoints the agents.md reference to the new
home-page anchor and regenerates index.md + llms bundles.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: add migration guide (00)

A versioned breaking-changes guide for upgrading to the v16 modernization release (base fold-in, native fetch, ESM, Node 22) and Protocol 27 / 28 Soroban auth (AddressV2). Modeled on viem's migration guide: one section per version, one entry per change, with before/after diffs. Sorts first in the guides nav and opens with a pointer to the home-page versioning section.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* docs: link API references in migration guide (00)

Link the first mention of each documented symbol (Keypair, the auth helpers, contract.Client/basicNodeSigner/signAuthEntries, rpc.Server/Horizon.Server, getLatestLedger, BalanceResponse, SigningCallback) to its reference page, base-agnostic, matching guide 07. Anchors verified against the rendered reference pages; internal link check passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Ryan Yang <[email protected]>
Co-authored-by: Iveta <[email protected]>

* update package version to 16.0.0-rc.1

* fix: improve token formatting logic

---------

Co-authored-by: Iveta <[email protected]>
Co-authored-by: oceans404 <[email protected]>
Co-authored-by: Steph <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Iveta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Modernization 2/4: Remove CJS constructs and make the library ESM compliant

3 participants