Skip to content

fix(typescript-client): bundle patched version of fetch-event-source#3732

Merged
KyleAMathews merged 1 commit intoelectric-sql:mainfrom
pawelblaszczyk5:bundle-patched-dependency
Feb 12, 2026
Merged

fix(typescript-client): bundle patched version of fetch-event-source#3732
KyleAMathews merged 1 commit intoelectric-sql:mainfrom
pawelblaszczyk5:bundle-patched-dependency

Conversation

@pawelblaszczyk5
Copy link
Contributor

@pawelblaszczyk5 pawelblaszczyk5 commented Jan 18, 2026

Summary

Bundles the patched @microsoft/fetch-event-source into @electric-sql/client dist output so consumers get the fixed version instead of the unpatched upstream package. Without this, liveSse shapes can't be aborted and throw errors in non-browser environments (SSR, Node, React Native).

Root Cause

The monorepo applies a pnpm patch to @microsoft/fetch-event-source fixing document/window assumptions and abort signal bugs. But tsup treated it as an external dependency, so the published @electric-sql/client npm package emitted bare import ... from '@microsoft/fetch-event-source' statements. Consumers resolved this to the unpatched upstream version from npm, reintroducing all the bugs the patch fixed.

Approach

Add noExternal: ['@microsoft/fetch-event-source'] to the shared tsup config, which inlines the (patched) source into all four build outputs (ESM, CJS, legacy ESM, browser). Placed after the ...options spread to ensure it always takes precedence.

Key Invariants

  • The patched fetch-event-source code must be present in all dist outputs
  • No external import/require of @microsoft/fetch-event-source should appear in dist

Verification

cd packages/typescript-client
pnpm build
pnpm vitest run --config vitest.unit.config.ts test/bundle.test.ts

The regression test reads all four dist outputs and asserts no external import/require of @microsoft/fetch-event-source exists.

Files Changed

File Change
packages/typescript-client/tsup.config.ts Add noExternal after ...options spread
packages/typescript-client/test/bundle.test.ts Regression test asserting the dependency is inlined
packages/typescript-client/vitest.unit.config.ts Register new test in unit config
.changeset/slow-apricots-clean.md Changeset for patch bump

Original PR by @pawelblaszczyk5 — see #2322 (comment) for the reported abort bug.

🤖 Generated with Claude Code

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Adds a changeset entry for a patch bump of @electric-sql/client and updates the TypeScript client's build config to include @microsoft/fetch-event-source in bundled outputs so the patched implementation is delivered to consumers.

Changes

Cohort / File(s) Summary
Build configuration
packages/typescript-client/tsup.config.ts
Added noExternal: [\@microsoft/fetch-event-source`]tocommonOptions, causing @microsoft/fetch-event-source` to be bundled into outputs (esm, cjs, legacy esm, browser).
Changeset documentation
.changeset/slow-apricots-clean.md
Adds a changeset noting a patch bump for @electric-sql/client and documents that liveSse previously relied on fetch-event-source (with assumptions/bugs around document/window and abort handling) which are intended to be included in the patched client build.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • KyleAMathews

Poem

🐰 I hopped through code to tuck it tight,
Fetch-event-source bundled snug and right,
No loose hops in browsers now, hooray—
Patch in place, I nibble worries away! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: bundling a patched version of fetch-event-source into the typescript-client package to fix runtime issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e462b78 and 7b29b8f.

📒 Files selected for processing (2)
  • .changeset/slow-apricots-clean.md
  • packages/typescript-client/tsup.config.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/slow-apricots-clean.md
  • packages/typescript-client/tsup.config.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 23, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@electric-sql/react@3732
npm i https://pkg.pr.new/@electric-sql/client@3732
npm i https://pkg.pr.new/@electric-sql/y-electric@3732

commit: 7b29b8f

@pawelblaszczyk5 pawelblaszczyk5 force-pushed the bundle-patched-dependency branch from e462b78 to 7b29b8f Compare January 23, 2026 07:52
@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 7b29b8f
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/697328b0fdd1c000081a7909
😎 Deploy Preview https://deploy-preview-3732--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pawelblaszczyk5
Copy link
Contributor Author

I spotted someone running actions here and it failing with some unrelated golang error during build - I rebased the branch to current main, hope it helps 😄 Can I do anything more to help it move forward? Are my findings correct here, or should I dig deeper? Thanks a lot in advance!

Copy link
Contributor

@balegas balegas left a comment

Choose a reason for hiding this comment

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

Hey, nice catch! Thanks for the contribution.

@pawelblaszczyk5
Copy link
Contributor Author

Hello! Anything possible here to move this forward?

@KyleAMathews KyleAMathews merged commit 186b8f8 into electric-sql:main Feb 12, 2026
23 of 27 checks passed
@github-actions
Copy link
Contributor

This PR has been released! 🚀

The following packages include changes from this PR:

  • @electric-sql/client@1.5.4

Thanks for contributing to Electric!

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.

3 participants