kuitos / axios-extensions

🍱 axios extensions lib, including throttle, cache, retry features etc...
MIT License
831 stars 49 forks source link

axios 1.5.0 not compatible #106

Closed ocervell closed 1 year ago

ocervell commented 1 year ago

I'm using Axios 1.5.0, and it seems like some import broke:

import { cacheAdapterEnhancer, throttleAdapterEnhancer } from 'axios-extensions';
ERROR in ./node_modules/axios-extensions/esm/utils/buildSortedURL.js 7:0-50
Module not found: Error: Package path ./lib/helpers/buildURL is not exported from package /home/vagrant/secator-ui/node_modules/axios (see exports field in /home/vagrant/secator-ui/node_modules/axios/package.json)

Indeed the exports in package.json:

  "exports": {
    ".": {
      "types": {
        "require": "./index.d.cts",
        "default": "./index.d.ts"
      },
      "browser": {
        "require": "./dist/browser/axios.cjs",
        "default": "./index.js"
      },
      "default": {
        "require": "./dist/node/axios.cjs",
        "default": "./index.js"
      }
    },
    "./lib/adapters/http.js": "./lib/adapters/http.js",
    "./lib/adapters/xhr.js": "./lib/adapters/xhr.js",
    "./unsafe/*": "./lib/*",
    "./unsafe/core/settle.js": "./lib/core/settle.js",
    "./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js",
    "./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js",
    "./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js",
    "./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js",
    "./unsafe/adapters/http.js": "./lib/adapters/http.js",
    "./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js",
    "./unsafe/utils.js": "./lib/utils.js",
    "./package.json": "./package.json"
  },

Replacing

import buildURL from 'axios/lib/helpers/buildURL';

by:

import buildURL from 'axios/unsafe/helpers/buildURL';

in esm/utils/buildSortedURL.js makes it work

ocervell commented 1 year ago

Update: nevermind, installing npm install axios-extensions@^3.1.7 made it work.

Seems like my npm install axios-extensions without a version installed 3.1.6 somehow ....