Skip to content

Instantly share code, notes, and snippets.

@hmps
Created September 11, 2015 12:39
Show Gist options
  • Save hmps/995583ff1c8755d5f795 to your computer and use it in GitHub Desktop.
Save hmps/995583ff1c8755d5f795 to your computer and use it in GitHub Desktop.
JSPM semver rules

VERSIONING WITH JSPM & SEMVER

I've struggled a little with versioning in JSPM. It adheres to SemVer but does not support everything that NPM does. Here are the rules:

SPECIFIC VERSION

Installs only exactly the version given.

[email protected] => Only installs version 1.0.0 of angular
[email protected] => Only installs version 1.4.3 of angular

ARBITRARY RANGES

Installs the latest version that matches the given version range.

angular@0 => Installs the latest version of angular that is in the 0.x.y range
[email protected] => Installs the latest version of angular that is in the 1.2.y range

CARET RANGES

Installs anything that does not modify the left-most non-zero version digit. In other words it:

  • allows minor and patch updates for versions >= 1.0.0
  • patch updates to versions >= 0.1.0 AND < 1.0.0
  • no updates to version <0.1.0
angular@^1.0.0 => installs the latest version that is < 2.0.0
angular@*0.7.0 => installs the latest version that is < 0.8.0

TILDE RANGES

Allows patch level changes if a minor is specified. Allows minor level changes if it is not.

angular@~1 => installs the latest version in the 1.x.y range
angular@~1.4 => installs the latest version in the 1.4.y range

CHECKING A SEMVER RANGE

If you want to check if a range will allow a certain release, give this tool a spin: http://jubianchi.github.io/semver-check/.

Remember that JSPM only supports the ranges specified above.

@hmps
Copy link
Author

hmps commented Sep 11, 2015

So, caret ranges are pretty hard to work with for < 1.0.0 releases that update minor often. That combination means you have to manually update the minor in your range every time you want to update to a new minor version.

For example angular@^0.3.0 will never update to version 0.4.0. So if this is your use case, a tilde range like angular@~0, or just a arbitrary range like angular@0 is probably your best bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment