Skip to content

fix(exports): expose web chart builds via browser condition#307

Merged
zhiqingchen merged 1 commit into
wuba:mainfrom
ry-allan:main
Jul 3, 2026
Merged

fix(exports): expose web chart builds via browser condition#307
zhiqingchen merged 1 commit into
wuba:mainfrom
ry-allan:main

Conversation

@ry-allan

@ry-allan ry-allan commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

The package ships web builds (lib/module/skia/skiaChart.web.js, lib/module/svg/svgChart.web.js), but the exports for ./skiaChart and ./svgChart only define default, pointing at the native build. Subpath exports bypass a bundler's .web.js platform-extension resolution, so web bundlers (webpack, Vite, esbuild) resolve the native entry, pull in react-native-svg / react-native, and fail on web. The shipped web build is unreachable.

Fix

Add a browser condition to both subpaths, pointing at the existing .web.js builds. Additive: web bundlers pick the web build; Metro keeps resolving default for native. No existing resolution changes.

Testing

Built from source (yarn prepare), packed, and installed into a real consumer. Web bundler (Vite via Storybook) resolves svgChart.web.js and renders charts on web where it previously failed; native (Metro) resolution unchanged.

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>
@zhiqingchen zhiqingchen merged commit e1ca288 into wuba:main Jul 3, 2026
1 check passed
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.

2 participants