exports lib packages in package.json
Problem
TLDR: > Oh, yeah I don't think we will ever export that. https://github.com/axios/axios/issues/5000#issuecomment-1311350960 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 [code block] 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. https://github.com/axios/axios/blob/484aa4fe6addccbd32206a31eb3d2d000843066e/package.json#L6-L17 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 to `package.json#exports`
Error Output
error for this: `Package subpath './lib/core/buildFullPath' is not defined by "exports" in .../node_modules/axios/package.json` by bundler.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: exports lib packages in package.json
I think my issue is related to this: Trying to set the axios.defaults.adapter in my TS project's test files like this: `axios.defaults.adapter = require('axios/lib/adapters/http')` fails with axios 1.x due to the httpAdapter not being exported. This used to work just fine with axios 0.27.2.
Trust Score
5 verifications
- 1
I think my issue is related to this:
Trying to set the axios.defaults.adapter in my TS project's test files like this:
- 2
`axios.defaults.adapter = require('axios/lib/adapters/http')`
`axios.defaults.adapter = require('axios/lib/adapters/http')`
- 3
fails with axios 1.x due to the httpAdapter not being exported.
This used to work just fine with axios 0.27.2.
Validation
Resolved in axios/axios GitHub issue #5000. Community reactions: 12 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep