stefanpenner / es6-promise

A polyfill for ES6-style Promises
MIT License
7.29k stars 594 forks source link

Provide separate auto-polyfill version of this module #165

Closed kevinoid closed 8 years ago

kevinoid commented 8 years ago

This pull request provides a mechanism for users to load a version of this module which automatically installs the polyfill, separately from the default non-automatic version, as outlined in https://github.com/jakearchibald/es6-promise/pull/126#issuecomment-120542090

It uses require('es6-promise/auto') instead of require('es6-promise/polyfill') so that it does not directly conflict with the es-shim-api API Contract in case support is later added. I'm open to changing this if another name is preferred.

In addition to the Node/Browserify file, a UMD file which triggers automatic polyfill installation is also provided.

Thanks for considering, Kevin

Fixes: #140 Alternative-to: #126

Note to reviewer: This commit reduces dist/es6-promise.min.js from 18kB to 6.4kB by mangling the names. I'm not sure why the previous commit was not mangled, since mangle: false is not passed to broccoli-uglify-js, but if it was intentional, I can fix and resubmit.

stefanpenner commented 8 years ago

sg

@jakearchibald r?

stefanpenner commented 8 years ago

I will include this as part of 4.0 (hoping to release that this weekend)

kevinoid commented 8 years ago

Sounds great, thanks!

kevinoid commented 8 years ago

I had some time this evening and was curious about the behavior of other popular Promise libraries which could serve as polyfills. From some quick investigation, here's what I've found:

Library Browser Polyfill Un-Polyfill Node Polyfill
bluebird Unconditional .noConflict() None
Native Promise Only If falsy None If falsy
promise If undefined None None
Q None .noConflict() of Q None
RSVP.js None None None
when.js Unconditional from when/es6-shim/Promise only None Unconditional from when/es6-shim/Promise only
vow None None None

I think the behavior implemented in this PR appears to be similar to the behavior of when.js. I don't have an opinion about whether it is the best behavior. Just thought it was worth considering any established conventions.

naoufal commented 8 years ago

@stefanpenner Hey just wanted to check-in on the status of this PR. :smiley:

What's the status on the release of 4.0?

stefanpenner commented 8 years ago

What's the status on the release of 4.0?

When I have time, unfortunately i have been quite busy lately.

naoufal commented 8 years ago

@stefanpenner No worries, I know how it goes.

If there are things you feel you can delegate, I'd be glad to lend a hand.

stefanpenner commented 8 years ago

I'll take a look this weekend, and see what can be delegated. I first must restore my memory on this project, so I can remember where i left off.

naoufal commented 8 years ago

Sounds good to me.

Didn't mean to rush you, just wanted to know whether or not this PR was still active.

stefanpenner commented 8 years ago

@naoufal would love extra help, so no worries :)

stefanpenner commented 8 years ago

updated for latest build updates: https://github.com/stefanpenner/es6-promise/pull/230

kevinoid commented 8 years ago

Thanks for updating and merging this PR @stefanpenner! I appreciate the extra effort for making this non-trivial API change. It looks great!