Uh oh!
There was an error while loading. Please reload this page.
Add ES6 Symbol polyfill for compatibility with iOS 8 and Android - #5294
Add ES6 Symbol polyfill for compatibility with iOS 8 and Android#5294skevy wants to merge 1 commit into
Conversation
facebook-github-bot
commented
Jan 13, 2016
By analyzing the blame information on this pull request, we identified @cpojer, @martinbigio and @sahrens to be potential reviewers. |
martinbigio
commented
Jan 14, 2016
mkonicek
commented
Jan 14, 2016
Thanks a lot for the fix @skevy! @davidaurelio How do we merge PRs that add dependencies now that we have the new infra for storing node_modules internally? For context, we have a custom way to fetch node_modules at fb because React Native is used in the main fb apps and there are engineers working on those apps who don't deal with JS, npm, etc. (we also don't want CI servers to run 'npm install' because it takes forever :)). We used to check node_modules into the Mercurial repo but maintaining that proved to be a pain so we have a new system to do that. |
davidaurelio
commented
Jan 14, 2016
@mkonicek I guess for now we have to have these imported by a FB employee and do the necessary things. We could enhance the bot to a) require that or b) do the necessary things itself. |
There was a problem hiding this comment.
I don’t think we want to overwrite native Symbol if present.
There was a problem hiding this comment.
i.e. use require('es6-symbol/implement');
There was a problem hiding this comment.
https://github.com/medikoo/es6-symbol/blob/master/index.js#L3
Am I reading that wrong? It seems like it's checking for native, global Symbol before it polyfills.
Or would you rather have that check in our code?
There was a problem hiding this comment.
I’m sorry, I misunderstood their documentation.
There was a problem hiding this comment.
@davidaurelio np :) If you'd rather me move the check into RN so it's more clear, I'm happy to do that!
There was a problem hiding this comment.
no, it’s good the way it is. @mkonicek will take care of merging
mkonicek
commented
Jan 15, 2016
@facebook-github-bot import |
facebook-github-bot
commented
Jan 15, 2016
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1107166042641372/int_phab to review. |
mkonicek
commented
Jan 15, 2016
I just did Here are all the files: http://pastebin.com/wyePxHtd cc @vjeux, @davidaurelio |
ide
commented
Jan 15, 2016
Could we use core-js instead of es6-symbol, since that's what Babel uses (or used to use...) and should get deduped with Babel? |
satya164
commented
Jan 17, 2016
What about using |
skevy
commented
Jan 17, 2016
@mkonicek sorry I didn't see this. I'll take a look. I'm sure we can figure out a different solution. We actually do already have Babel-polyfill in deps (not actually sure why)...I was just hesitant of using that as it adds a lot of code to people's bundles and doesn't really add that much (since we polyfill a bunch anyway). I'm AFK at the moment, but my intuition tells me that either we can vendor a symbol polyfill or try core-JS... |
skevy
commented
Jan 17, 2016
Honestly, I wouldn't be surprised if the deps that es6-symbol added are deps we already have somewhere in the tree...but that's not how npm works. :-( |
mkonicek
commented
Jan 18, 2016
@skevy Yes I was just worried when I saw this was adding files like I have little context, just read the Symbol docs last week. If you guys more familiar with JS are happy with merging this go ahead. I was just asking whether adding all this code was worth it, and you're right all of it might already be in the tree :( It's frustrating to see the |
skevy
commented
Jan 18, 2016
@mkonicek totally agreed. Hold off on merging this everyone - I'm gonna just vendorize this polyfill -- absolutely no reason to add a huge dep. |
skevy
commented
Jan 18, 2016
@mkonicek I am going to do this right now though, so hopefully we can still get this into RN 0.18...would be a good fix as this causes a problem on < iOS 9 and Android (some or all...not sure). |
skevy
commented
Jan 18, 2016
OK so actually, two comments on this:
|
ide
commented
Jan 18, 2016
The size of the bundle is more important than the size of node_modules here. npm uses gzip and npm 3 is not bandwidth-constrained, and 3xxMB is a fraction of a percent of modern HDD space. So whatever polyfill gives us some combination of compact and clean code is actually my preference, whether that's core-js or something else. |
skevy
commented
Jan 18, 2016
I'm talking to @vjeux about this...will report back. |
vjeux
commented
Jan 18, 2016
Here's the plan:
It just replaces
|
mkonicek
commented
Jan 18, 2016
Nice! I've released 0.18.0. Can anyone release 0.18.1 with the single extra commit? Since it's a JS-only change, it's just |
satya164
commented
Jan 22, 2016
ping @bestander :) |
skevy
commented
Jan 25, 2016
@DmitrySoshnikov what would be the specific point of defining |
DmitrySoshnikov
commented
Jan 26, 2016
@skevy, I meant in case if you don't wanna use loose mode. Otherwise it should be fine (we don't have |
skevy
commented
Jan 26, 2016
@DmitrySoshnikov great. We'll go with using loose mode + documenting what we do and don't support. @vjeux you good with this plan? |
vjeux
commented
Jan 26, 2016
Works for me, Dmitry is the pro here :p |
skevy
commented
Jan 26, 2016
Ok - I'm going to close this then in favor of adding loose mode in #5214 and then I'll open a new PR with doc changes. |
Summary: Turns out, even after discussion that was had in #5294 (comment), we really do need this transform. I've just included it in the preset...let me know if you all would rather publish to npm. The actual reason why this is necessary is because in the latest sync from FB, fbjs was updated to use the `Symbol.iterator` express in it's isEmpty function: facebook/fbjs@064a484 We use this in RN in the ListView...and this change (once #5084 is merged) will cause ListView to break on older JSC context's. This resolves that, and is probably something we should have had all along. Closes#5824 Reviewed By: svcscm Differential Revision: D2913315 Pulled By: vjeux fb-gh-sync-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca shipit-source-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca
Summary: Turns out, even after discussion that was had in #5294 (comment), we really do need this transform. I've just included it in the preset...let me know if you all would rather publish to npm. The actual reason why this is necessary is because in the latest sync from FB, fbjs was updated to use the `Symbol.iterator` express in it's isEmpty function: facebook/fbjs@064a484 We use this in RN in the ListView...and this change (once #5084 is merged) will cause ListView to break on older JSC context's. This resolves that, and is probably something we should have had all along. Closes#5824 Reviewed By: svcscm Differential Revision: D2913315 Pulled By: vjeux fb-gh-sync-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca shipit-source-id: abaf484a9431b3111e8118d01db8d2c0d2dd73ca
peterlazar1993
commented
Feb 22, 2016
ms88privat
commented
Feb 28, 2016
👍 |
lrettig
commented
Feb 29, 2016
I upgraded to RN 0.20 and I'm now getting a different error. My code looks like this:
and it appears to transpile into this:
which produces this error:
Indeed, my array doesn't contain functions, so I don't understand how this transpiled code is supposed to work. Does anyone know what's going on? Thanks. |
skevy
commented
Feb 29, 2016
@lrettig in JS environments that support I'm not sure why that's not working for you...are you using any custom babelrc or any type of custom config? |
lrettig
commented
Feb 29, 2016
There was indeed some junk in my .babelrc that must have caused this. I removed it, and it started working. Thanks! |
skevy
commented
Feb 29, 2016
So the reason, for what it's worth, that it wasn't working...is because your code was not being transpiled into the "for...of" loose mode code. This is important for non-Symbol supporting JS platforms. |
lrettig
commented
Feb 29, 2016
I suspect the culprit was this entry in my .babelrc "plugins": On Mon, Feb 29, 2016 at 1:36 AM, Adam Miskiewicz notifications@github.com
|
skevy
commented
Feb 29, 2016
Note that we have a preset now...called "babel-preset-react-native" that you can install and use in your babelrc, rather than copying the RN config or using the This ensures that you're using all the proper transforms that RN requires. |
davide-scalzo
commented
Mar 6, 2016
related to this by any chance? gaearon/react-proxy#50 |
sdeleon28
commented
Mar 16, 2018
This missing polyfill causes this weird behavior with immutable immutable-js/immutable-js#1474 Thought I'd leave it here for reference |

Fixes#4676