fix: externalize ably/react and JSX runtime imports, improve demo apps#56
Merged
fix: externalize ably/react and JSX runtime imports, improve demo apps#56
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
The react bundle's external list only covered `ably` and `react`. Sub-path imports (`ably/react`, `react/jsx-runtime`, `react/jsx-dev-runtime`) were not externalized, so rolldown bundled them as CJS and injected its interop shim into the ESM output. In environments without `require` (Turbopack SSR, Node.js native ESM) this threw "Calling `require` for X" at runtime. Adding all three to `external` eliminates the shim entirely.
Switched the unmount cleanup from `useEffect` to `useLayoutEffect` so the transport is closed and the ref cleared before the DOM is updated. This ensures any in-progress operations are aborted before `ChannelProvider` detaches the channel. Also switched the transportRef from `| null` to `| undefined` to comply with the project's `unicorn/no-null` rule.
Both demos now call `createTransportHooks<TEvent, TMessage>()` in their `providers.tsx` and destructure `TransportProvider` and all hooks from the returned object, rather than importing them directly from `@ably/ai-transport/react`. This threads the codec generics through the hook layer so hook calls don't need explicit type annotations at the call site.
91cacd8 to
bcea356
Compare
mschristensen
approved these changes
Apr 15, 2026
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.
Accidentally broke demo apps (Turbopack stopped recognizing
/reactimports)To fix this, externalized ably/react and JSX runtime imports.
Also fixed a small error in provider cleanup logic (unmount cleanup is now synchronous).
And updated demo apps to use
createTransportHooksto avoid explicit types when using hooks.