urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.61k stars 449 forks source link

storage-rn: Incorrect interop require expressions in CJS #3250

Closed oliverdolgener closed 1 year ago

oliverdolgener commented 1 year ago

Describe the bug

With the update to v1.0.1 the read / write operations fail. (undefined is not an object). v1.0.0 works fine. The issue seems to come from the transpiled ts files in the dist folder. I noticed a change in the way the Async Storage is called:

v1.0.0: persistedData = await AsyncStorage__default["default"].getItem(dataKey); v1.0.1+: persistedData = await AsyncStorage.getItem(dataKey);

For some reason Async Storage cannot be found after upgrading to v1.0.1+

Reproduction

Urql version

urql 4.0.3

Validations

oliverdolgener commented 1 year ago

@kitten Thanks a lot for this blazing fast fix :)

kitten commented 1 year ago

@oliverdolgener No worries! Would you like to give urql@0.0.0-canary-20230606164854 and @urql/storage-rn@0.0.0-canary-20230606164854 a quick try before I issue a full release?

oliverdolgener commented 1 year ago

@kitten unfortunately the app now crashes with undefined is not a function at urql.js line 19: var Context = React__namespace.createContext(OBJ);

kitten commented 1 year ago

@oliverdolgener Did some more digging and https://github.com/urql-graphql/urql/commit/7a11714f02e77fb0b91969b06ee223fbf19164bb should fix this for the react package. I think, I skipped a line in the Rollup docs and confused two of the options.

As before urql@0.0.0-canary-20230607144157 and @urql/storage-rn@0.0.0-canary-20230607144157 are available for testing on npm.