fix(exports): expose web chart builds via browser condition#307
Merged
Conversation
The package ships web builds (skiaChart.web.js, svgChart.web.js) but the exports for ./skiaChart and ./svgChart only define a default condition pointing at the native build. Subpath exports bypass a bundler's platform-extension resolution, so web bundlers (webpack, Vite, esbuild) resolve the native entry, which pulls in react-native-svg and react-native and fails on web. Add a browser condition to both subpaths so web bundlers resolve the shipped .web.js build. Metro keeps using default for native, so native resolution is unchanged. Signed-off-by: Ryan <4126720+ry-allan@users.noreply.github.com>
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.
Problem
The package ships web builds (
lib/module/skia/skiaChart.web.js,lib/module/svg/svgChart.web.js), but theexportsfor./skiaChartand./svgChartonly definedefault, pointing at the native build. Subpathexportsbypass a bundler's.web.jsplatform-extension resolution, so web bundlers (webpack, Vite, esbuild) resolve the native entry, pull inreact-native-svg/react-native, and fail on web. The shipped web build is unreachable.Fix
Add a
browsercondition to both subpaths, pointing at the existing.web.jsbuilds. Additive: web bundlers pick the web build; Metro keeps resolvingdefaultfor native. No existing resolution changes.Testing
Built from source (
yarn prepare), packed, and installed into a real consumer. Web bundler (Vite via Storybook) resolvessvgChart.web.jsand renders charts on web where it previously failed; native (Metro) resolution unchanged.