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

Publish an ESM version #1879

Closed
franktopel opened this issue Nov 15, 2018 · 20 comments
Closed

Publish an ESM version #1879

franktopel opened this issue Nov 15, 2018 · 20 comments
Projects

Comments

@franktopel
Copy link

franktopel commented Nov 15, 2018

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

@viT-1
Copy link

viT-1 commented Nov 26, 2019

a year has passed

@viT-1 viT-1 mentioned this issue Nov 26, 2019
@43081j
Copy link

43081j commented Dec 26, 2019

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.

@hyingreborn
Copy link

@LaurentChardin
Copy link

LaurentChardin commented Jul 30, 2020

vitejs/vite#162 (comment)

I had to compile a local version of Axios to have it ESM compliant in order to use it with vite.
Would love to see this piece of work started.

Can we start a branch and probably refactor the build process to have multiple versions generated (like rollup is doing) ?

@jdvivar
Copy link

jdvivar commented Aug 6, 2020

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!

@ldsenow
Copy link

ldsenow commented Feb 17, 2021

Any progress on this one?

@xiaoxiangmoe
Copy link

Any update on this one?

@Exomnius
Copy link

Waiting for the ESM version for usage with vitejs/svelte.

@DigitalBrainJS
Copy link
Collaborator

@Exomnius Hmm. Probably you will have to wait a very long time. Axios is written in ES3 :)

@jasonsaayman
Copy link
Member

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.

@xiaoxiangmoe
Copy link

xiaoxiangmoe commented Mar 23, 2021

@jasonsaayman I would be happy to help do this. BTW, if we setup a new project, can we take TypeScript into consideration?

@EHadoux
Copy link

EHadoux commented Mar 24, 2021

Likewise, I'd be happy to help as much as I can and I second the Typescript comment.

@hronro
Copy link

hronro commented Mar 24, 2021

For anyone looking for a ESM alternative, if you don't mind some APIs are missing (like interceptors), I recommend use redaxios.

@jasonsaayman
Copy link
Member

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?

@xiaoxiangmoe
Copy link

@jasonsaayman Yes. Writing TypeScript codes and compile it to esm and cjs.

@jasonsaayman
Copy link
Member

@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.

@jasonsaayman
Copy link
Member

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.

@jasonsaayman jasonsaayman added this to To do in v1.0.0 via automation May 15, 2021
@jimmywarting
Copy link

A bit against TypeScript (but not typing per say - i think that is grate)

  • I think jsDoc can provide you with the same level of typing support.
  • You don't have to compile anything and it works much faster.
  • Fewer dependencies/configurations
  • Always in the frontline when it comes to new syntax - TS will always stay in the shadow of javascript
  • And i don't think it's something wrong with a loosed typed languages that needs to be fixed
  • TS do not actually run anywhere without being transpiled to JS in the first place

@EHadoux
Copy link

EHadoux commented May 25, 2021

If I may add a few counter-arguments to the above:

You don't have to compile anything and it works much faster.

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).

Fewer dependencies/configurations

Same as above, replacing one by another one but without plugins so net/net that's less dependencies.

Always in the frontline when it comes to new syntax - TS will always stay in the shadow of javascript

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 exports in TS, but that's really minor and being addressed).

And i don't think it's something wrong with a loosed typed languages that needs to be fixed

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

TS do not actually run anywhere without being transpiled to JS in the first place

True, although publishing an ESM version doesn't mean not publishing a CJS version, which in turn means transpiling anyway

@jasonsaayman
Copy link
Member

Please see #4209 this is a high priority

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v1.0.0
  
To do
Development

No branches or pull requests