Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function 'finally' on prototype shouldn't polyfill 'promise' #96

Open
chenjianzhonglol opened this issue Aug 20, 2021 · 3 comments
Open

Comments

@chenjianzhonglol
Copy link

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:

image

@JLHwung
Copy link
Collaborator

JLHwung commented Sep 7, 2021

I think we can skip the MemberExpression path if the it is in the left of an AssignmentExpression whose operator is =?

@nicolo-ribaudo
Copy link
Member

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() {}

@zloirock
Copy link
Member

zloirock commented Sep 7, 2021

I think we can skip the MemberExpression path

It will break the monkey patching of built-in methods in some cases, for example testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants