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.57k stars 444 forks source link

`@urql/next` publishes CommonJS with invalid React usages #3400

Closed brendenpalmer closed 9 months ago

brendenpalmer commented 10 months ago

Describe the bug

As part of the @urql/next bundle React exports are incorrectly called via React["default"], rather than the top-level React object.

For instance, see the @urql/next CommonJS bundle: https://www.unpkg.com/@urql/next@1.0.0/dist/urql-next.js vs. the regular urql bundle here: https://www.unpkg.com/urql@4.0.5/dist/urql.js (see the differences in createContext usages as an example).

When using @urql/next and testing with Jest this breaks in tests with the following error: TypeError: Cannot read properties of undefined (reading 'createContext').

To reproduce:

  1. Clone the following repo: https://github.com/brendenpalmer/next-urql-commonjs-issue-repro
  2. Run npm install
  3. Run npm run test

Reproduction

https://github.com/brendenpalmer/next-urql-commonjs-issue-repro

Urql version

@urql/next 1.0.0

Validations

WillHHH commented 9 months ago

Got the same issue here 🥲