# Is it safe to enable for-of to indexed for transform for esm package downstreams

**URL:** <https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193>\
**Category:** Questions\
**Tags:** performance, build, compilation\
**Created:** [April 17, 2026, 3:01am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193 "2026-04-17T03:01:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [April 17, 2026, 3:01am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/1 "2026-04-17T03:01:48Z")

</div>

When developing in the babylonjs repo, there is a custom eslint rule `babylonjs/no-downlevel-iteration` disallows using for-of against `Map`s, and in the umd packages, for-of loop is compiled to indexed for loops, but it’s kept as-is in esm packages.  
So is it safe for downstream users of esm packages to enable similar transform for esm packages, like `assumeArray: true` of `@babel/plugin-transform-for-of`, as a performance optimization, or it “just work” now but might change in future versions?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 18, 2026, 2:37am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/2 "2026-04-18T02:37:21Z")

</div>

cc @RaananW / @ryantrem

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [April 22, 2026, 2:09pm UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/3 "2026-04-22T14:09:59Z")

</div>

Yes, because we target ES5 for our UMD packages. so the short answer is - no, it would be better not to use this until we move to a newer ES version for our UMD packages (which might come earlier than expected, mainly due to TC39’s decorations).

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [April 23, 2026, 2:09am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/4 "2026-04-23T02:09:39Z")

</div>

I saw both yes and no, can I interpret this as:

- Safe for curr released versions
- Might change in furure versions

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [April 23, 2026, 12:18pm UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/5 "2026-04-23T12:18:11Z")

</div>

Sorry! I answered yes to a question with “or” 🙂  
It is safe for you to use it, of course. If you don’t target any es5 users (which you shouldn’t, IMO) - use it for sure. wonderful syntax. Do not use it when implementing anything for babylon.js core, as we are still using es5 in our UMD packages.

I hope this is clearer, and sorry for the confusion before.

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [October 27, 2026, 9:09am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/6 "2026-10-27T09:09:03Z")

</div>

Anything changed since last answer? `no-downlevel-iteration` is removed by this commit, does this mean that `assumeArray` would no longer be supported?

> **[Fix physics plugin not releasing empty Havok world regions (#18699) ·...](https://github.com/BabylonJS/Babylon.js/commit/37f21b819ae5d2dc1af1d87c132e4d65b2229b69)**
>
> Hey there,
> 
> I noticed that havok world region count tends to grow quite a lot, and
> found some gaps in region removal.
> 
> So this PR adds a dedicated helper to accumulate and flush regions to be
> remov...

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 2, 2026, 10:38am UTC](https://forum.babylonjs.com/t/is-it-safe-to-enable-for-of-to-indexed-for-transform-for-esm-package-downstreams/63193/7 "2026-11-02T10:38:10Z")

</div>

We do the es5 downgrade at a different level now. So you can use it in your PRs. our CI will catch any issue in any case.
