re-rxjs / react-rxjs

React bindings for RxJS
https://react-rxjs.org
MIT License
546 stars 18 forks source link

fix: React Native build #243

Closed josepot closed 2 years ago

josepot commented 2 years ago

It turns out that the fix on #239 fixes the error with NextJs, but it breaks things on React Native.

The reason being that the CJS complied code was doing require("use-sync-external-store/shim/index.js"), when in reality it should be doing require("use-sync-external-store/shim"), otherwise React Native can't pick up its correct asset.

So, I had to get a bit creative to solve this. The solution is a bit hacky, but it works: I'm using a esbuild plugin to resolve to a different file on the CJS build when importing the useSyncExternalStore hook.

Why didn't I just alter the CJS files under dist once the build script has finished? Because I'm pretty sure that would have messed up the .map files.

codecov[bot] commented 2 years ago

Codecov Report

Merging #243 (d86e155) into main (d291db9) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #243   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        24    +1     
  Lines          317       318    +1     
  Branches        40        40           
=========================================
+ Hits           317       318    +1     
Impacted Files Coverage Δ
packages/core/src/internal/useObservable.ts 100.00% <100.00%> (ø)
packages/core/src/internal/useSyncExternalStore.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d291db9...d86e155. Read the comment docs.