nandorojo / dripsy

🍷 Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
2.01k stars 80 forks source link

drispy/gradient path doesn't match entrypoint #285

Closed awinograd closed 1 year ago

awinograd commented 1 year ago

👋 Thanks @nandorojo for an awesome lib!

I just upgraded from 3.x to 4.1 and after updating gradients to import from `dripsy/gradient' I get the following error when rendering a Gradient:

Cannot read property 'theme' of null

What i'm seeing, is that dripsy.gradient always exports from build

https://github.com/nandorojo/dripsy/blob/e8272cd46261a34554c16fd370a536c5514e1312/packages/dripsy/gradient/index.js#L1

But in react-native, metro bundler will import from on src

https://github.com/nandorojo/dripsy/blob/e8272cd46261a34554c16fd370a536c5514e1312/packages/dripsy/package.json#L7

This leads to two different copies of dripsy being loaded from dripsy and dripsy/gradient so when I import DripsyProvider it doesn't properly provide to Gradient.

I'm a little surprised this hasn't come up yet in your usage of Gradient so I figure I must be "holding it wrong 🙃 . Am I missing something here? Thanks again!

nandorojo commented 1 year ago

Ah, that's interesting, will look into it

nandorojo commented 1 year ago

this might require removing the react-native field from package.json. i wonder if setting it to src instead of src/index would fix it.

awinograd commented 1 year ago

removing react-native should work as then metro will use the main field.

I think that's probably the best option until full support for exports lands in metro (https://github.com/facebook/metro/issues/670#issuecomment-1434510835)

awinograd commented 1 year ago

Another idea would be adding dripsy/gradient/index.native.js to export * from '../src/gradient'

nandorojo commented 1 year ago

yeah, not sure if there are downsides there. i guess everyone uses metro so could be fine

Wilson-Lim commented 1 year ago

Hi, i am hitting this issue as well.

How could i make it work temporarily, while waiting for the fix ?

Wilson-Lim commented 1 year ago

Hi, i am hitting this issue as well.

How could i make it work temporarily, while waiting for the fix ?

  • i tried removing "react-native": "src/index.ts", at package.json Line 7
  • i tried adding dripsy/gradient/index.native.js to export * from '../src/gradient'

I did a clean yarn install, and it works.

Kindly ignore my post

nandorojo commented 1 year ago

Can you guys try 4.3.2 and see if this is fixed?

gorbypark commented 5 months ago

Can you guys try 4.3.2 and see if this is fixed?

@nandorojo Upgraded from drippy 3 to 4.3.5 and I am hitting this issue as well.