Search code examples
internet-explorerwebpackbabeljscore-js

Exception thrown and not caught at require-object-coercible in IE11


I'm using Babel to transpile my ES7 code. My setup is a bit strange because I need to transpile some node_modules. I keep getting this error:

SCRIPT5022: Exception thrown and not caught
require-object-coercible.js (4,24)


Solution

  • I thought my config was wrong and I was transpiling incorrect modules (since you shouldn't transpile core-js) but after some digging around, I found out that the problem was in my code.

    I was calling Array.from() on ParentNode.children. from() should be called on an iterable input and in Chrome, the children property always returns an HTMLCollection, which is iterable. In IE, however, children of an SVG element is undefined, which raises the error in require-object-coercible. This makes my code work fine on Chrome, but not in IE11, even after correct polyfills.

    The solution was to simply perform a check on children before calling from().