Write a migration guide for every major version
Show old and new code side by side for each breaking change in a MIGRATING file, so users upgrade a major version in minutes. Works for any package.
A major version tells users that something breaks. A migration guide tells them what, and how to fix it. Keep each entry to the same shape: what changed, the old code, the new code.
For example, version 2 of a parse function returns an object instead of pairs. In version 1:
import { parse } from "my-lib";
console.log(parse("a=1&b=2"));[ [ 'a', '1' ], [ 'b', '2' ] ]And in version 2:
import { parse } from "my-lib";
console.log(parse("a=1&b=2"));{ a: '1', b: '2' }The guide then says: "parse now returns an object. If you relied on the order of pairs, use Object.entries(parse(input))." One line of change and one line of fix is the standard to meet.
Link the guide from the release notes and from the deprecation message of the old major. The format of keep a changelog puts breaking changes in their own section, which is where users look.
List breaking changes in the order users meet them: imports first, then function signatures, then behavior. A change you did not document is a bug report waiting.