Include es.promise.finally in PromiseDependencies #136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Include es.promise.finally in PromiseDependencies, so it is correctly loaded when the native Promise constructor is overwritten.
context:
Version 3.24.0 of CoreJS changed how the loading of the Promise constructor shim behaves in NodeJS environments, causing it to overwrite the native Promise constructor when JSDom is loaded (e.g. with Jest), because JSDom tries to emulate a browser but misses the global PromiseRejectionEvent. I would agree with the author that this is correct behavior from a core-js point of view (zloirock/core-js#1110 (comment)). However, this means that when using babel-polyfills, the new Promise is missing a
finally
method, because it is not listed as one of the PromiseDependencies, causing 3rd party code that is not run through Babel to break.Although this is how the problem occurs to me, I don't think this problem is JSDom-specific. It could occur in any browser that has a non-compliant native Promise implementation.
This PR adds es.promise.finally to the PromiseDependencies, so it always gets loaded when Promises are used, and not just when the finally method is used in transformed code