swagger-api / swagger-js

Javascript library to connect to swagger-enabled APIs via browser or nodejs
http://swagger.io
Apache License 2.0
2.62k stars 758 forks source link

Dependency was not found `@swagger-api/apidom-reference/configuration/empty` after `3.18` to `3.19` upgrade #3136

Closed mrleblanc101 closed 1 year ago

mrleblanc101 commented 1 year ago

Q&A (please complete the following information)

Describe the bug you're encountering

My Nuxt 2 app stop compiling after upgrading from 3.18.5 to 3.19.0 (or higer, tried 3.19.11 and 3.20.2).

This dependency was not found: 
* @swagger-api/apidom-reference/configuration/empty in ./node_modules/swagger-client/es/resolver/apidom/reference/parse/parsers/json/index.js, ./node_modules/swagger-client/es/resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js and 3 others

To install it, you can run: npm install --save @swagger-api/apidom-reference/configuration/empty

To reproduce...

Here is my package.json:

{
  "name": "nuxt-project",
  "private": true,
  "engines": {
    "node": ">12.0.0"
  },
  "scripts": {
    "dev": "nuxt dev",
    "build": "nuxt build",
    "analyse": "nuxt build -a",
    "start": "nuxt start",
    "generate": "nuxt generate",
  },
  "dependencies": {
    "@nuxtjs/auth-next": "^5.0.0-1643791578.532b3d6",
    "@nuxtjs/axios": "^5.13.6",
    "@nuxtjs/gtm": "^2.4.0",
    "@nuxtjs/i18n": "^7.2.0",
    "@nuxtjs/moment": "^1.6.1",
    "@nuxtjs/sentry": "^5.1.7",
    "@nuxtjs/svg": "^0.4.0",
    "@sentry/tracing": "^6.17.7",
    "calendar-link": "^2.1.1",
    "chart.js": "^2.9.4",
    "cookie-universal-nuxt": "^2.1.5",
    "d3": "^6.6.0",
    "filesize": "^8.0.7",
    "focus-trap": "^6.7.3",
    "foundation-sites": "^6.7.4",
    "fuse.js": "^6.5.3",
    "hex-rgb": "^5.0.0",
    "i18n-iso-countries": "^7.3.0",
    "intro.js": "^7.0.1",
    "lodash": "^4.17.21",
    "moment-duration-format": "^2.3.2",
    "nuxt": "^2.15.8",
    "nuxt-feature-toggle": "^1.2.2",
    "plyr": "3.7.3",
    "portal-vue": "^2.1.7",
    "progressbar.js": "^1.1.0",
    "qs": "^6.10.3",
    "swagger-client": "~3.19.0",
    "swiper": "5.x",
    "v-calendar": "^2.4.1",
    "v-click-outside": "^3.1.2",
    "vue-awesome-swiper": "^4.1.1",
    "vue-chartjs": "^3.5.1",
    "vue-currency-input": "^1.22.4",
    "vue-link": "^1.6.1",
    "vue-marquee-text-component": "^1.2.0",
    "vue-multiselect": "^2.1.6",
    "vue-slider-component": "^3.2.15",
    "vue-sticky-directive": "^0.0.10",
    "vue-sweetalert2": "^5.0.2",
    "vue-the-mask": "^0.11.1",
    "vue-tippy": "^4.13.0",
    "vue-toastification": "^1.7.14",
    "vue-transition-expand": "^0.1.0",
    "what-input": "^5.2.10"
  },
  "devDependencies": {
    "@babel/eslint-parser": "^7.17.0",
    "@crowdin/cli": "^3.10.0",
    "@nuxtjs/eslint-config": "^10.0.0",
    "@nuxtjs/eslint-module": "^3.0.2",
    "@nuxtjs/router": "^1.7.0",
    "@nuxtjs/style-resources": "^1.2.1",
    "@nuxtjs/stylelint-module": "^4.1.0",
    "babel-polyfill": "^6.26.0",
    "eslint": "^8.9.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-no-smart-quotes": "^1.3.0",
    "eslint-plugin-nuxt": "^3.1.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-prettier-vue": "^4.2.0",
    "eslint-plugin-vue": "^9.14.1",
    "fibers": "^5.0.1",
    "prettier": "^2.5.1",
    "sass": "~1.39.2",
    "sass-loader": "10",
    "stylelint": "^13.12.0",
    "stylelint-order": "^4.1.0",
    "vue-i18n-locale-message": "^1.14.0",
    "vue-svg-inline-loader": "^2.1.2"
  }
}

Here is my lockfile if it can be of any help. Let me know if I cna provide anything else. yarn.txt

char0n commented 1 year ago

Hi @mrleblanc101,

You're seeing this because nuxt@2 doesn't support exports and import fields. You'd probably have to overcome this by some sort of heavy aliasing, which will be very fragile. Unfortunately there's nothing we can do about it.

mrleblanc101 commented 1 year ago

Then this should be documented as a breaking change in the README and only be implemented in a Semver major...

char0n commented 1 year ago

Hi @mrleblanc101,

I understand your point of view. But we claimed for years that our minimum supported Node.js version is 12.20.0. imports and exports fields are supported in Node.js 12.20.0. We go far beyond to keep 12.20.0 compatibility, like we did yesterday in https://github.com/swagger-api/swagger-js/pull/3137.

Then this should be documented as a breaking change in the README and only be implemented in a Semver major...

We technically did not do any breaking change. We just use feature from Node.js versions we claim for years we support. We're very careful about that. What we cannot control is what various bundlers/frameworks choose to support - nuxt@2 doesn't support exports/imports, but nuxt@3 does. We bind our complatibility to Node.js version, not to any particular bundler/framework.

I'm sorry that nuxt@2 stopped working for you.

saltovo commented 5 months ago

same issue. use resolutions in package.json to lock the swagger-client version like this: "resolutions": { "swagger-client":"3.18.5", },

pp-assis commented 4 months ago

Node.js version is 12.20.0 --> Whe are on node 12.22 and when trying to update encountered the same issue. Import is just on node 12, otherwise I need yo use an experimental modules and rename for mjs. It broke our production pipeline, as @mrleblanc101 it shoud have been a major version. (https://stackoverflow.com/a/45854500)

char0n commented 4 months ago

Hi @pp-assis,

I already explained this in https://github.com/swagger-api/swagger-js/issues/3136#issuecomment-1716987319

We didn't do any change in this package. We've started using another package (ApiDOM) which is completely compatible with Node.js >=12.20.0 which we still fully support along with testing bundling on webpack@5.

ApiDOM is a direct dependency, but imaging we would use another dependency which has another indirect/transitive dependency that is using exports or imports field. We would never know about this, nor would we detect this. I don't understand why would we do a breaking change release as we didn't break anything related to our claim that swagger-client runs on Node.js >=12.20.0.

@pp-assis you provided some info in your comment, but truthfully I don't really understand it. I can successfully install and run latest version of swagger-client on Node.js@12.20

char0n commented 4 months ago

Maybe using UMD build fragment of swagger-client will help? More info in https://github.com/swagger-api/swagger-js/issues/3411#issuecomment-2100464291