useDApp icon indicating copy to clipboard operation
useDApp copied to clipboard

🤖 Replace Object.fromEntries with Array.reduce

Open snorkypie opened this issue 3 years ago • 5 comments

Rationale behind change: Object.fromEntries needs to be polyfilled in any project using this right now and the switch to Array.reduce removes this need. To me it makes sense not to have dependencies like that. Sentry for the current project I work with is filled with Object.fromEntries is not a function errors.

snorkypie avatar Mar 31 '22 22:03 snorkypie

Thanks for the PR! Just out of curiosity, what platform are you running on? I believed that this was already implemented in major browsers.

dmaretskyi avatar Apr 01 '22 09:04 dmaretskyi

We might also lower the ES version in the tsconfig if we want to support older platforms

dmaretskyi avatar Apr 01 '22 09:04 dmaretskyi

Thanks for the PR! Just out of curiosity, what platform are you running on? I believed that this was already implemented in major browsers.

Hey! It's a node project. I am not affected personally since I run up-to-date browsers but our Sentry show that enough people are hit with this to require us to do something about it.

snorkypie avatar Apr 01 '22 09:04 snorkypie

We might also lower the ES version in the tsconfig if we want to support older platforms

It doesn't really matter what direction is taken for me personally, as long as our project don't have to resort to a slower solution to solve it. What direction are you leaning towards? Keep Array.reduce but leave the fromEntries helper in there?

snorkypie avatar Apr 01 '22 09:04 snorkypie

It doesn't really matter what direction is taken for me personally, as long as our project don't have to resort to a slower solution to solve it. What direction are you leaning towards? Keep Array.reduce but leave the fromEntries helper in there?

I would leave some sort of helper in there (fromEntries or mapValues). Also I would lower the "lib" version in tsconfig since otherwise it would be difficult for us to enforce those changes.

Do you mind sending the names and versions of affected browsers? Object.fromEntries might not be the only problem in that case.

dmaretskyi avatar Apr 04 '22 09:04 dmaretskyi