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
exports lib packages in package.json #5000
Comments
And, if I'm not mistaken, react native users needs the Some users of axios-cache-interceptor raised an issue about this same problem and, after some reading, this may also be the best way to deascribe your exports in a project coded by default with ESM: |
Also, it would be great if a simple Like: |
See #5030 merged should fix this. |
No, this is not fixed by #5030, it's a complete different problem. People who are affected by this issue want to import utils from Currently The other issues closed by this #5030 are indeed importing from |
@jasonsaayman could you re-open this issue? |
Ok fair enough, I have re-opened and will investigate as soon as I can |
This is correct, I made a mistake in when describing #5030, as this issue was mentioned in #5008 (comment). |
Related: jamesmbourne/aws4-axios#701 |
I think my issue is related to this:
fails with axios 1.x due to the httpAdapter not being exported. |
Hi 👋 Please try the latest pre-release by running the following: npm i axios@1.2.0-alpha.1 Please provide feedback in either the pinned issue or the discussion thread 🧵 |
I'm pretty sure it's not what we wanted… utils are still not exported, makes no difference |
Oh, yeah I don't think we will ever export that. Exporting the entire libs would cause a large potential issue and cause people to use Axios outside of the scope of its declared public API. If you could motivate what you would like and why maybe I would look into it but blanket exports of the directory would not be smart. |
Ok |
Yeah sorry, I get what you are trying to do but should we do this we would then open ourselves up to so much more issues if we declared this as part of the public API. That being said if you would like to roll what you are working on into a package we can maybe work on that and see how we can make it possible to provide this to a consumer. |
I think it's very understandable that these API are not stable.You can document that they may change any time and export them. |
@jasonsaayman One possible use case is aws4-axios, which uses
A possible solution for package maintainers would be to duplicate these axios methods in their own codebase. On the other hand I believe the majority of signing-related middleware/interceptors would need these set of helpers. Do you think increasing the surface of the public API will increase issues in general, or is there anything particular about these helpers (e. g. frequent changes). |
Still doesn't work for me.
The docs here are quire explicit about using the |
I'm not sure if this is the correct suggestion since it's basically changing how Axios package is being shipped (And the effort is definitely huge). What if we modularize it and make the repository a monorepo approach similar to what parcel did? |
@jasonsaayman could you please provide a way to export built-in adaptors, which is a config option of axios? I want to use http adaptor in jsdom environment. jsdom's XHR implementation is a trouble... |
I have a solution and it wasted me a few days: webpack.config.jsmodule.exports = {
//...
resolve: {
exportsFields: ['exports2'],
},
}; or webpackChain
It really works |
@DigitalBrainJS, Actually, this just extends the current problem into smaller ones. Everytime someone will be needing an internal function from axios that is not exported. As you can see in #5324, #5264 and so on... Why can't all functions be exported as normal so anyone can use it while integrating with axios? The bytesize wouldn't be that big? or would it? |
@arthurfiorette we don't want to export everything else people will rely on code that can change without being documented as we can change underlying implementations without changing the public API. The only way I can see this working is we either export it and then whoever uses it does so explicitly at their own risk or we export only what is needed. For now I would like to do it one by one but if there are many uses cases and people really want us to do so we can look into everything being exported. |
the following fixed the issue for me webpack.config.jsmodule.exports = {
resolve: {
alias: {
"axios/lib": path.resolve(__dirname, "../../node_modules/axios/lib"),
},
},
}; |
any news? same problem here. |
Hey @jasonsaayman. I know that importing code inside The main reason we import things inside the The code is in OUR node_modules and just disallowing us from accessing it WILL not prevent us from using it. It is going to just create another bigger problem as, to solve our problem, we will copy/paste axios source code, which is much worse than our code breaking when upgrading axios, because it creates duplicity anyway and even future critical problems axios may fix won't reflect on our copy-pasted code. And even if we achieve to import axios internal content without copy-pasting functions, I am sure that the code written to access it is more error-prone than just hypothetic incompatibilities axios may bring with a patch/minor version. I am strongly in favor of exporting everything axios has, even if it is going to be under a I know that creating a issue to export Happy to discuss more, also if you want, I can create another issue. |
Ok fair enough, I have been gone for a bit of a hiatus, but seems as good as any time to start getting stuck in again. I will look into this |
I have been using https://github.com/ds300/patch-package to patch package.json of axios for a while.... |
Perhaps we can export the lib folder with some prefix in the path to highlight this as an unsafe operation. I would like to avoid potential situations when we change the internal structure of Axios in a minor version, causing a bunch of issue reports. The next major version will have intensive changes to internal modules, as the core needs a deep rework in order to add middleware/hooks functionality and a plugin loader. |
@DigitalBrainJS I'm trying to implement a custom Axios adapter. |
Same here |
axios internal files are plain js, so you need to write your own type defs for them. There is nothing axios can do unless they rewrite whole project into TypeScript. |
TLDR:
#5000 (comment)
Is your feature request related to a problem? Please describe.
Yes. I'm writing a adaptor to be used in userscript like tampermonkey or Violentmonkey,
it use a xhr provided be broser extension
GM.xmlHttpRequest
to make cors request.And to make it behavior like axios' xhr adaptor, I'm using some axios' helper functions directly by
But after axios 1.0.0 is released, a
exports
field is added to package.json, and lib directory is no longer exported anymore, this make me unable to use helper function provided by axios anymore.axios/package.json
Lines 6 to 17 in 484aa4f
modern js bundler will raise a error for this:
Package subpath './lib/core/buildFullPath' is not defined by "exports" in .../node_modules/axios/package.json
by bundler.Describe the solution you'd like
add
lib
dir topackage.json#exports
The text was updated successfully, but these errors were encountered: