Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Fix transpilation of for of loops with Set caused by dangerousForOf in Buble config. #75

Merged
merged 3 commits into from
Jul 9, 2020

Conversation

parkerziegler
Copy link
Contributor

This PR fixes a major 🐛 in v0.6.0. Previously, we had dangerousForOf enabled in our Buble transforms. dangerousForOf assumes all structures being iterated with for...of loop are array-like objects with a length property 😱 . This doesn't work for us because we iterate over a Set using for...of.

This PR adds in the necessary Babel transform to support IE11: https://babeljs.io/docs/en/babel-plugin-transform-for-of For now I'd like to keep IE11 support, but it is clear from the example that we end up adding a pretty hefty transpilation cost with this plugin. In a future release of renature (likely v1), we'll remove IE11 support entirely and strip this plugin. But for now, it makes sense to keep it in.

@kitten
Copy link

kitten commented Jul 8, 2020

In urql we'd typically not use for...of but would hand write for-each loops instead. Given that you're about to pull in a lot of helper code potentially for the iterables, is that maybe a preferable option?

@parkerziegler
Copy link
Contributor Author

Good shout. The more I think about it too, the more I'm less inclined to include bundle bloating code for IE11. All modern browsers natively support for...of so I actually think I just won't include any transforms for it ✅

@parkerziegler parkerziegler merged commit d1f1ce4 into saturn Jul 9, 2020
@parkerziegler parkerziegler deleted the patch/fix-for-of-transpilation branch July 9, 2020 00:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants