JustinBeckwith / retry-axios

🦖 A super flexible interceptor for Axios that makes it easy to retry requests.
Apache License 2.0
483 stars 62 forks source link

v3 Breaks Typescript Build #193

Open LoganArnett opened 2 years ago

LoganArnett commented 2 years ago

I am not entirely sure what the issue is but on v2.6.0 everything works so I reverted back to that version but when I attempted to build the same project o v3.0.0 with a node version of v16+ the build succeeds with no errors but when the code is run I get this error:

"require() of ES Module /var/task/node_modules/retry-axios/build/src/index.js from /var/task/utils/axios.js not supported.\nInstead change the require of index.js in /var/task/utils/axios.js to a dynamic import() which is available in all CommonJS modules."

I attempted to change the import structure between both

import rax from 'retry-axios';

// and

import * as rax from 'retry-axios';

And still got the same error.

Just curious if there is something obvious I need to do to be able to upgrade to v3.

zymotik commented 2 years ago

I have an error that I believe is related when using the Vue 2.6 build tools. I see a message in the console "This dependency was not found" with the suggestion "To install it, you can run: npm install --save retry-axios"

Code:

import * as rax from "retry-axios";

Results in:

 ERROR  Failed to compile with 1 error

This dependency was not found:

* retry-axios in ./src/backend/tracking/tracking-client.ts

To install it, you can run: npm install --save retry-axios

My package.json has retry-axios in it, this is a cleaned up version for brevity:

{
  "name": "ui",
  "version": "1.0.0-0",
  "scripts": {
    "serve": "vue-cli-service serve --port 8082",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "axios": "0.26.0",
    "retry-axios": "^3.0.0",
    "vue": "2.6.14",
    "vue-router": "3.5.2",
    "vuetify": "2.5.6",
    "vuex": "3.6.2"
  },
  "devDependencies": {
    "@typescript-eslint/parser": "5.10.1",
    "@vue/cli-plugin-babel": "4.5.15",
    "@vue/cli-plugin-eslint": "5.0.4",
    "@vue/cli-plugin-router": "4.5.15",
    "@vue/cli-plugin-typescript": "4.5.13",
    "@vue/cli-plugin-unit-jest": "4.5.13",
    "@vue/cli-plugin-vuex": "5.0.4",
    "@vue/cli-service": "4.5.13",
    "ts-jest": "^26.5.6",
    "typescript": "4.3.4"
  }
}

Versions: Node: 16.14.0 TypeScript version 4.3.4 retry-axios 3.0.0 VueJs 2.6.14 @vue/cli-service 4.5.13

ashkanjj commented 2 years ago

I'm getting the same, happy to create a reproducible setup in somewhere like codesandbox if anyone is happy to look into this?

leefsmp commented 2 years ago

Same here, getting error ERR_REQUIRE_ESM which seems to be related to the way lib is being exported: https://github.com/standard-things/esm/issues/868 Reverting to 2.6.0 works thanks.

leopucci commented 2 years ago

image

DavidHe1127 commented 2 years ago

We see a different error

    Details:

    /work/node_modules/retry-axios/build/src/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import axios from 'axios';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      3 | import * as k8s from '@kubernetes/client-node';
      4 | import axios, { AxiosError } from 'axios';
    > 5 | import * as rax from 'retry-axios';
        | ^
      6 | import * as https from 'https';
      7 |
      8 | // The `waitForStatefulset` checks are necessary because Pulumi does not

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (src/tests/system/prometheus.spec.ts:5:1)

Adding config below to transform that file doesn't work

  "transformIgnorePatterns": [
    "node_modules/(?!retry-axios/build/src/index)"
  ]

Removed rax.attach(); didn't cause the error though.

hisham commented 7 months ago

+1

willbui256resi commented 1 month ago

+1