-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Publish an ESM version #1879
Comments
a year has passed |
yep, node supports ESM (finally) so my suggestion is that the entire source be ESM out of the box. anything else should be considered legacy these days (including commonjs) so, if anyone needs it anymore, it should be a build artifact rather than the source module system. im happy to have a stab at converting the whole repo if there's a chance anyone will ever merge it. let me know (whoever maintains this now) and ill sort it out. |
I had to compile a local version of Axios to have it ESM compliant in order to use it with vite. Can we start a branch and probably refactor the build process to have multiple versions generated (like rollup is doing) ? |
In case someone lands here looking for an ESM Axios package, 2 options for them:
The first is based directly on Axios, the second one has some useful features, based on the first one. I hope this helps! |
Any progress on this one? |
Any update on this one? |
Waiting for the ESM version for usage with vitejs/svelte. |
@Exomnius Hmm. Probably you will have to wait a very long time. Axios is written in ES3 :) |
Hi, I would be open to looking into this with collaborators that would like to contribute at least in part to getting this done. It would be a pretty large task but I am certain it would be exceptionally beneficial to Axios. Comment here if you would like to work on this. We can maybe setup a project and start looking at what needs to be done etc. |
@jasonsaayman I would be happy to help do this. BTW, if we setup a new project, can we take TypeScript into consideration? |
Likewise, I'd be happy to help as much as I can and I second the Typescript comment. |
For anyone looking for a ESM alternative, if you don't mind some APIs are missing (like interceptors), I recommend use redaxios. |
We can setup a project and start adding things we would like to see. I think TypeScript will be a great idea too, are you thinking native TypeScript and then we compile as needed @xiaoxiangmoe? |
@jasonsaayman Yes. Writing TypeScript codes and compile it to esm and cjs. |
@xiaoxiangmoe Ok that seems like a very good idea, we can then publish all the possible versions people may want to use and keep the codebase pretty simple as we would only have the one language to worry about. Ok since this would be a huge change I am thinking we would need to create a new fork and this could maybe work as a V1 for Axios. The biggest thing is we would need to port all current features as well as maybe trying to incorporate as many possible new features as we can. |
This is still something I am working on, the first step is fixing the test suite to work better and cover more of the code base. I am about 60% done with this. Once done I will update with a new issue and roadmap for this. |
A bit against TypeScript (but not typing per say - i think that is grate)
|
If I may add a few counter-arguments to the above:
In terms of execution time it doesn't change anything, in terms of compilation, that's true, although 1. this project already contains gulp and Webpack so it's not straight from code to package anyway, it's transpiled. And using esbuild is insanely fast (and faster than almost anything else).
Same as above, replacing one by another one but without plugins so net/net that's less dependencies.
For something like axios you want stability not experimental features. If you use them, you need to polyfill for older versions of Node anyway so we go back to transpiling. Also there is barely any difference in terms of timing language-wise (configuration-wise is a different discussion, see the current lack of support for
That's a matter of taste, I personally think loosely typed languages are unreliable (or rather people using them are), and Python implementing typings seems to indicate that as well
True, although publishing an ESM version doesn't mean not publishing a CJS version, which in turn means transpiling anyway |
Please see #4209 this is a high priority |
As more and more people start using the ECMAScript module system, Axios should provide an ESM version that allows for importing in a browser rather than only in a webpack environment.
Just as an example, here's someone requesting that: https://stackoverflow.com/questions/53316944/using-npm-modules-with-es6-and-future-of-npm
The text was updated successfully, but these errors were encountered: