fix(react-ui): re-export full ThemeProvider barrel from main entry#488
Merged
ankit-thesys merged 2 commits intothesysdev:mainfrom May 4, 2026
Merged
Conversation
The hand-listed re-export of `./components/ThemeProvider` only surfaced
`ThemeProvider`, `createTheme`, the default themes, `swatchTokens`, and a
couple of types — `useTheme` and `ThemeContext` were left off. Combined
with the `./*` exports map (which compiles each component into a
standalone subpath chunk while the main entry inlines its own copy),
consumers ended up with two separate `createContext()` calls at runtime:
- `<ThemeProvider>` from `@openuidev/react-ui` writes to the main
bundle's ThemeContext.
- `useTheme` from `@openuidev/react-ui/ThemeProvider` reads the
subpath chunk's ThemeContext.
Two contexts, never the same instance — `useTheme()` always returned
the default value when `<ThemeProvider>` was mounted from the main
entry. Caused a real downstream regression in `@thesys/artifact` where
`PresentationThemeProvider` reads the ambient mode via `useTheme()`;
slides always rendered in light mode regardless of the outer
`<ThemeProvider mode="dark">`.
Switching to `export * from "./components/ThemeProvider"` matches the
pattern used by every other component on this file, picks up
`useTheme` + `ThemeContext` (alongside `ThemeProps` and `ThemeMode`
which were previously listed separately below), and is forward-
compatible with future ThemeProvider additions.
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
packages/react-ui/src/index.tswas hand-listing only a subset of./components/ThemeProvider's exports —useThemeandThemeContextwere left off. Combined with the"./*"exports map (which compiles each component to a standalone subpath chunk while the main entry inlines its own copy), this produced two separatecreateContext()calls at runtime:<ThemeProvider>imported from@openuidev/react-uiwrites to the main bundle'sThemeContext.useThemeimported from@openuidev/react-ui/ThemeProviderreads from the subpath chunk'sThemeContext.Two contexts, never the same instance.
useTheme()always returned the default value when<ThemeProvider>was mounted from the main entry — the only placeuseThemewas reachable from.Downstream impact
Caused a real regression in
@thesys/artifact:PresentationThemeProviderreads ambient mode viauseTheme()so it can scope a second<ThemeProvider cssSelector=".thesys-slide">for slide-scale typography. Because of the dual-context bug, slides rendered in light mode regardless of the outer<ThemeProvider mode="dark">. Workaround was passing an explicitmodeprop into everyPresentationThemeProviderinstance.Fix
Replace the hand-listed re-export block with
export * from "./components/ThemeProvider"— the pattern used by every other component in this barrel. Picks upuseTheme+ThemeContext(which were missing) alongsideThemePropsandThemeMode(which were previously re-exported via separate lines that are now redundant and removed).Once consumers migrate from
@openuidev/react-ui/ThemeProviderto@openuidev/react-uifor these symbols, both paths share the same compiled chunk = sameThemeContextinstance.Test plan
pnpm --filter @openuidev/react-ui typecheck(passes locally — no ambiguous-export errors)pnpm --filter @openuidev/react-ui build(passes locally; built tarball verified to exposeuseThemeandThemeContexton the maindist/index.d.mts)@thesys/artifactconsumer: with the rebuiltreact-uioverridden into the consumer and alluseThemeimports flipped to the main entry, slides correctly inherit the outer<ThemeProvider mode>setting.Notes
useTheme,ThemeContext,ThemeProps,ThemeMode,Theme,ThemeProvider,createTheme, default themes, andswatchTokensremain exported from the main entry. The wildcard also surfaces previously-only-via-subpath helpers (black,white,withAlpha,swatch,swatchToken, granular theme interfaces) — these were already public via the subpath; this just promotes them to the main entry.@openuidev/react-ui/ThemeProvider) still works for any existing consumer that depends on it. Consumers mixing subpathuseThemewith main-entry<ThemeProvider>will need to migrate to the main entry to get the dedup benefit.