babel-polyfills
babel-polyfills copied to clipboard
Function 'finally' on prototype shouldn't polyfill 'promise'
When i define a 'finally' function on other function's prototype, why dist code includes "core-js/modules/es.promise.finally.js", "core-js/modules/es.promise.js".
ex:
I think we can skip the MemberExpression path if the it is in the left
of an AssignmentExpression
whose operator is =
?
https://github.com/babel/babel-polyfills/blob/615e5cd57a64eca434f9129e2a73d46af9223801/packages/babel-helper-define-polyfill-provider/src/visitors/usage.js#L27
It would work, even if somewhere that .finally
method is probably used so the es.promise.finally
polyfill will be added anyway.
I wonder why we add the polyfill for
function Test() {}
Test.prototype.finally = function() {}
but not for
Test.prototype.finally = function() {}
I think we can skip the MemberExpression path
It will break the monkey patching of built-in methods in some cases, for example testing.