I am using PDF.js in my Ember app.
Sometime, I am getting an error, which seems to be caused by Ember extending array prototype and making them enumerable, as describe here
It seems that the problem is caused by Ember, since it's adding a number of methods on Arrays, but for some reason they are all enumerable which is the cause of the problem. When adding methods on e.g. Arrays and Objects, they should be set to enumerable = false, just like the native methods are.
One proposed solution to this that do work is to globally set the array extension to false like this
//config/environment.js
EmberENV: {
EXTEND_PROTOTYPES: {
String: true,
Array: false,
Function: true
}
}
But this seems incredibly inefficient, as our app is already quite big and going back everywhere that there are array and transforming them into Ember arrays would be very tedious work.
Is there a better way to deal with this issue?
At first I was thinking it might be a polyfill issue with babel because of this
Found the issue - we are polyfilling Array.prototype.find.
But removing babel's polyfill does not fix the problem.
I don't understand how Ember is able to modify an external library method to extend it and then cause an error. I am kind of lost where to look at for a solution that does not involve globally modifying ember array's extension.
Any help would be greatly appreciated.
Thanks.
Aucun commentaire:
Enregistrer un commentaire