npmvitepackage.json

Two vite versions in one NPM package


This is a link to a project I forked [https://github.com/guruyaya/vite5-plugin-replace]

If you look at the changes, the main differance is, in the code is, in package.json, where I replaced:

  "peerDependencies": {
    "vite": "^2"
  }

with:

  "peerDependencies": {
    "vite": "^5"
  }

The thing is, I would like to offer this as a real fix to the NPM package. My tests show this plugin works, with no issues on version 5, and as for version 2 - my guess it was allready tested by it's owner. However, I have no intention of suggesting this fix, without allowing it to work on both version 2 and version 5. I could not find, however, a way to allow 2 different versions of vite. Can you help me with this? Thanks


Solution

  • You can use the logical OR operator for that purpose: ^2 || ^5