fix(typescript-client): bundle patched version of fetch-event-source#3732
Conversation
📝 WalkthroughWalkthroughAdds a changeset entry for a patch bump of Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✏️ Tip: You can disable this entire section by setting Comment |
commit: |
e462b78 to
7b29b8f
Compare
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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! |
|
Hello! Anything possible here to move this forward? |
|
This PR has been released! 🚀 The following packages include changes from this PR:
Thanks for contributing to Electric! |
Summary
Bundles the patched
@microsoft/fetch-event-sourceinto@electric-sql/clientdist output so consumers get the fixed version instead of the unpatched upstream package. Without this,liveSseshapes 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-sourcefixing document/window assumptions and abort signal bugs. But tsup treated it as an external dependency, so the published@electric-sql/clientnpm package emitted bareimport ... 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...optionsspread to ensure it always takes precedence.Key Invariants
import/requireof@microsoft/fetch-event-sourceshould appear in distVerification
cd packages/typescript-client pnpm build pnpm vitest run --config vitest.unit.config.ts test/bundle.test.tsThe regression test reads all four dist outputs and asserts no external import/require of
@microsoft/fetch-event-sourceexists.Files Changed
packages/typescript-client/tsup.config.tsnoExternalafter...optionsspreadpackages/typescript-client/test/bundle.test.tspackages/typescript-client/vitest.unit.config.ts.changeset/slow-apricots-clean.mdOriginal PR by @pawelblaszczyk5 — see #2322 (comment) for the reported abort bug.
🤖 Generated with Claude Code