npm / node-semver

The semver parser for node (the one npm uses)
ISC License
5.06k stars 492 forks source link

[ENHANCEMENT] Allow * prerelease versions for * version ranges. #736

Open Sophos-Elias-Vasylenko opened 1 month ago

Sophos-Elias-Vasylenko commented 1 month ago

Is there an existing issue for this?

Current Behavior

I came across the behaviour described in this issue: https://github.com/npm/node-semver/issues/510

The behaviour is that 1.x.x-whatever ranges as parsed, but the prerelease version is just ignored. I agree with the comment on that issue that something like 1.0.*-rc doesn't really make much sense and isn't terribly useful. Presumably the resolution to this problem is one of the following:

However I do think that something like 1.*.*-* could serve a genuine purpose. Currently this version range does not parse.

Expected Behavior

For context, I was trying to find work-arounds for https://github.com/npm/rfcs/pull/397. This is an RFC to update NPM behaviour to make development of peer dependencies more convenient, so that we can satisfy a peer dependency range with a prerelease version if the host app explicitly specifies one.

In lieu of a happy resolution to the RFC, it would be useful to allow a peer dependency to signal that it is intended to accept pre-releases at the discretion of the importing package. And a 1.*.*-* style version range could satisfy this purpose.

Steps To Reproduce

  1. In this environment...
  2. With this config...
  3. Run '...'
  4. See error...

Environment

mbtools commented 3 weeks ago

This is trying to integrate the includePrerelease option into the range definition. This makes it very confusing.

This package already has the corresponding option available in the satisfies function. Letting users specify includePrerelease in package.json would be a much cleaner solution (see my comment).