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
Configure the promise implementation #44
Comments
One possible approach could be something similar to: |
+1 for possibility to switch promise implementation, using native-promise-only in many projects, this would reduce the bundle size. |
In webpack or browserify, alias the package to:
It will be prebuilt, but it won't require a separate promise. |
Oops, just tried it and the standalone build still assumes Promise.polyfill exists. |
@torarnek why do you want to use your own Promise lib? The idea behind using |
@hoppula axios is already using native Promise if it exists. If you're just trying to reduce the bytes, you can use |
I'm using babel and its runtime. Calls to Promise are swapped with babel-core's Promise. So I already have something taking care of polyfilling. |
@pstoica sounds like a bug. Shouldn't be calling |
Sounds good. How about making a |
Would also be interested in this. I'm using browserify and would like to use bluebird as the promise implementation for axios since it supports |
@pstoica standalone build is fixed with 0.5.1 |
Great, thanks so much! Seems like this can be closed now? |
I'm using browserify. |
@kentor the files under For CJS there currently isn't an option, which is where I think this issue is stemming from. If you want bluebird just to use |
It sounds like browserify is picking up the file fine. Wouldn't one UMD build fix all these issues? (I didn't realize axios.js was one var declaration.) |
|
@hoppula that work for you? I tried it and it's the same, I just get a @mzabriskie thanks that recipe does work indeed. Though, I guess I will need to use the same promise implementation as the one in axios in other places in my code if I want to save bytes in my bundle. |
You're getting an empty object because nothing is being exported yet. One UMD build will give you either AMD, CommonJS, or a global. It also means you wouldn't have to specify AMD/etc in the filename. |
I have reworked the bundling to be UMD compatible. While this will allow requiring
I would prefer using UMD as it simplifies |
Can you not just not require es6-promise (by default instead of in the global build) and add something to the readme telling the consumer to use babel or es6-promise? |
@nelix that would be preferable in a lot of ways. We could switch es6-promise to be a peerDependency, then it's readily available if needed. Anyone else have any opinions on this? It would not be backward compatible, which I'm okay with. This could be communicated with an upgrade guide. The biggest factor is just pushing off the Promise dependency management to the developer consuming axios. At the same time, it allows more flexibility. |
Yeah, I think at this point it'd be better to ask people to responsibly manage their own Promise/ES6 polyfills. I think people would be using Promises in general if they decided to use axios. |
I'm 👍 on removing the promise from the library. I would even go as far as not specifying it as a peerDependency. I'm with facebook's on this one: https://facebook.github.io/react/docs/working-with-the-browser.html#browser-support-and-polyfills
|
+1 to remove polyfills from library. |
Please make axios use standard |
+1 for allowing me to change the promise implementation. |
👍 on removing es6-promise from the library. |
Once 0.6.0 has been released you will need to provide your own promise implementation. |
0.6.0 has released, and in the upgrade guide, only es6-promise has been mentioned. require('es6-promise').polyfill();
var axios = require('axios'); How to config axios using bluebird? |
@CrisLi have you found out how to configure axios to rely onBluebird as promise library? |
Sorry, I have switched to use Fetch API. |
@CrisLi I solved the issue by checking if Promise attribute is in the global scope, otherwise, window.Promise =BluebirdPromise; |
I wish to provide my own Promise implementation (core-js), so I do not want browserify do bundle the es6-promise module. Is there a simple way to configure axios not to require this module?
The text was updated successfully, but these errors were encountered: