Core-js: Changes in global behavior impact multiple javascript libraries

Created on 21 Mar 2017  路  3Comments  路  Source: zloirock/core-js

I'm reviving the issue reported in #278 as it seems to be a real problem to Magento websites (they use prototype.js 1.7.0)

Explained the same problem in more detail in https://github.com/babel/babel/issues/5518

This change in behavior trickles down into how google tag manager works and can break other things in a website.

compatibility

Most helpful comment

I can confirm that the exact same issue is breaking RequireJS in my application. The affected code is here: https://github.com/requirejs/requirejs/blob/f2335026867afd80c394247bfe5278d2bd8f32ee/require.js#L47-L49
In my case, it actually causes RequireJS injected modules to be passed in as undefined.
This is a very obscure bug and it therefore led to very confusing and difficult-to-debug behaviour. I spent almost 2 days identifying the exact issue.

I imagine that PrototypeJS and RequireJS are not the only other libraries affected by this global change; the title of this issue should probably be "Changes in global behavior impact multiple javascript libraries". When working with a legacy application, it's often not possible to simply swap out the problematic legacy JS library, so a fix here is critical.

Thank you!

All 3 comments

I can confirm that the exact same issue is breaking RequireJS in my application. The affected code is here: https://github.com/requirejs/requirejs/blob/f2335026867afd80c394247bfe5278d2bd8f32ee/require.js#L47-L49
In my case, it actually causes RequireJS injected modules to be passed in as undefined.
This is a very obscure bug and it therefore led to very confusing and difficult-to-debug behaviour. I spent almost 2 days identifying the exact issue.

I imagine that PrototypeJS and RequireJS are not the only other libraries affected by this global change; the title of this issue should probably be "Changes in global behavior impact multiple javascript libraries". When working with a legacy application, it's often not possible to simply swap out the problematic legacy JS library, so a fix here is critical.

Thank you!

A workaround is to reset the toString() return value for Arrays to the ES5 default by including the following in your bundle:

Object.defineProperty(Array.prototype, Symbol.toStringTag, { value: "Array" });

Looks like cb30530 fixes the issue but hasn't been released yet ... ?

Was this page helpful?
0 / 5 - 0 ratings