Skip to content
jshacks.dev
Packages

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.

1 min read
Summarize in AI

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:

v1-usage.mjsJavaScript
import { parse } from "my-lib";
console.log(parse("a=1&b=2"));
Text
[ [ 'a', '1' ], [ 'b', '2' ] ]

And in version 2:

v2-usage.mjsJavaScript
import { parse } from "my-lib";
console.log(parse("a=1&b=2"));
Text
{ 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.

Share

More snippets

Packages

Initialize a package with npm init

Initialize a package.json with npm init, skip the questions with the yes flag, and set your own defaults for author and license in npm config.

1 min read
Packages

Generate a changelog from commits

Turn conventional commit messages into a CHANGELOG.md section with conventional-changelog, grouped by feature and fix. Works with any Git history.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.