Course contentsShow
← Software Engineering
Lesson 669 of 1,93321. Build Automation and Dependency ManagementFree lesson

Semantic Versioning (SemVer)

How major.minor.patch versioning communicates backward compatibility and breaking changes to consumers.

Semantic Versioning (SemVer)

You'll learn how version numbers communicate compatibility information to dependency consumers.

When you declare dependencies in your build configuration, you've probably seen version numbers like 2.4.7 or 1.0.0. These aren't random—they follow Semantic Versioning (SemVer), a standardized system for communicating what kind of changes a library release contains.

The Three-Part Version Number

SemVer uses the format MAJOR.MINOR.PATCH:

  • PATCH (the rightmost number): Bug fixes and internal improvements that don't change the public API. Upgrading should be completely safe—2.4.7 to 2.4.8 won't break your code.

  • MINOR (the middle number): New features added in a backward-compatible way. Your existing code still works, but new capabilities are available—2.4.8 to 2.5.0 adds features without breaking anything.

  • MAJOR (the leftmost number): Breaking changes that modify or remove existing behavior. Upgrading requires you to change your code—2.5.0 to 3.0.0 means "careful, things broke."

Why This Matters for Dependencies

Think of SemVer like traffic signals: green means safe (patch), yellow means proceed with awareness (minor), and red means stop and check (major). When you specify lodash 4.17.21 as a dependency, that version number tells you exactly what to expect if you upgrade.

This communication is crucial for transitive dependencies (dependencies of your dependencies). If a library respects SemVer, you can safely allow automatic patch updates without fear of breaking changes.

Pre-1.0 and Special Cases

Versions starting with 0. (like 0.8.3) indicate unstable, pre-release software where anything can change at any time—the SemVer guarantees don't fully apply yet.

Key Takeaway: SemVer's MAJOR.MINOR.PATCH format lets library maintainers communicate breaking changes (major), new features (minor), and bug fixes (patch), helping you make informed decisions about updating dependencies.