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

es5 build should not replace existing window.Promise #289

Closed
jjfrankovich opened this issue Nov 20, 2019 · 1 comment
Closed

es5 build should not replace existing window.Promise #289

jjfrankovich opened this issue Nov 20, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jjfrankovich
Copy link

Describe the bug
My project uses a custom Promise implementation called bluebird:
https://github.com/petkaantonov/bluebird/blob/master/API.md

When media-stream-library.min.js runs (which was compiled from the master branch and built for es5) the window.Promise switches from our desired blueJay implementation to a different promise implement that is missing a few functions like Promise.finally.

Here is an example stack trace that we see after media-stream-library.min.js is loaded:

media-stream-library.min.js?version=1574257754418:8 Unhandled promise rejection TypeError: f.then(...).finally is not a function

Ideally, media-stream-library would check for the existence of window.Promise before replacing it.
Something like "window.Promise = window.Promise || media-stream-library.Promise;"

Environment:

  • OS: Windows
  • Browser Chrome
  • Version 6.0.3 built from master branch on 20191112 for es5; we needed the ios 12 fix and no npm version has been provided with that fix yet.
@jjfrankovich jjfrankovich added the bug Something isn't working label Nov 20, 2019
@steabert steabert self-assigned this Nov 22, 2019
@steabert
Copy link
Member

I've read about this issue and it seems to be a general problem with combining core-js and bluebird. There seems to be a solution with zloirock/core-js#283 (https://github.com/zloirock/core-js#configurable-level-of-aggressiveness), but that would require you to rebuild the library with those options.

I'm hesitant to support this out-of-the-box, since I prefer to rely on core-js to do its job instead of making assumptions about someone's use of polyfills. They should only replace the Promise polyfill if it doesn't meet the requirements (so I guess that it's too strict for bluebird). If you can configure core-js with the less aggressive option we could add this to our documentation.

Another options would be to load bluebird after our minified bundle, if that's possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants