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

graphcache: Untranspiled class property initializers break Safari <14.1 #3274

Closed mattwoodage closed 1 year ago

mattwoodage commented 1 year ago

Describe the bug

Since switching from urql/core 3.0.3 to 4.0.10 and graphcache 5.0.1 to 6.1.1 our Next bundle no longer runs in Safari 12 or 13.

Screenshot 2023-06-14 at 17 27 57

It's due to the public field declaration use in GraphCache - specifically the lines keyOfField=keyOfField; and resolveFieldByKey=this.resolve; in class Store

I can see you changed browser support in August 2022 - and say that you support ECMA2015+ which includes Safari 12.

The addition of @babel/plugin-proposal-class-properties would correct the transpilation I believe.

Is this something you'd be happy to add please?

Using https://babeljs.io/ - compiled version of urql-exchange-graphcache.mjs - AS IS:

Screenshot 2023-06-15 at 10 28 06

Using https://babeljs.io/ - compiled version of urql-exchange-graphcache.mjs - WITH @babel/plugin-proposal-class-properties PLUGIN:

Screenshot 2023-06-15 at 10 28 27

Reproduction

https://github.com/urql-graphql/urql/blob/main/exchanges/graphcache/src/store/store.ts

Urql version

"@urql/core": "^4.0.10",
"@urql/exchange-graphcache": "^6.1.1",

Validations

kitten commented 1 year ago

Hey, thanks for reporting this! 🙌 I'll make sure I get a hotfix out since this affects Safar <14.1 and is hence quite severe. I spotted the PR that regressed this but, to keep the build process simple and lean with recent changes, I put a further ESLint rule in place that should prevent regression on this.

Cheers!

mattwoodage commented 1 year ago

@kitten thanks so much.