Easily bump your packages versions

Easily bump your packages versions

This is a quick article about configuring a simple yet effective way to manage your scripts. Let's say you are using esbuild, your probably have some kind of build command.

Recently, I added a bump command to make my life easier. The package.json looks something like this

  ...
  "scripts": {
    "build": "esbuild --bundle --minify --format=esm --sourcemap mylib.js --outfile=mylib.min.js",
    "start": "npm run build -- --servedir=.",
    "watch": "npm run build -- --watch",
    "bump": "npm run build && npm version patch"
  },
  ...

So now, it's simple as running this when I want to push some updates

npm run bump
npm publish
git push

You can either push the tag or use the GitHub release tool.

Quick warning about the "v" prefix

By default, npm version will add the "v" prefix to the version. Maybe you don't like that. Simply create a .npmrc with the following line:

tag-version-prefix=""

What if you didn't noticed the prefix so far ? You can remove them easily

git tag -d $(git tag -l "v*")