Reference for publishing NPM packages

Just a guy who loves to write code and watch anime.
Search for a command to run...

Just a guy who loves to write code and watch anime.
No comments yet. Be the first to comment.
Qualities that make outstanding builders.

Bipedal vs quadrupedal: how many legs This is about the number of legs the creature walks on. Bipedal. Two legs. Humans, ostriches, T-rex, kangaroos, most fantasy humanoids. Quadrupedal. Four legs. Do

Intro You hear "lerp" and "smoothstep" everywhere in game dev. They sound like math jargon. They're not. Both are small tools that do the same job: smoothly move from one value to another. The problem

What is Kinematics Kinematics is the math field. It's the study of how things move without worrying about forces (which would be dynamics). FK and IK are the two branches: forward kinematics and inver

Intro Textures are usually the biggest cost in a 3D scene. Memory, bandwidth, and load time all get eaten by them. Resizing them is the obvious lever. There's more. This post is about the less obvious

A reference for myself. Hence the use of pnpm which I use most of the time. 🤷
# Initialize package
pnpm init
# Set up typescript, tests, etc
pnpm add -D typescript tsup vitest ... etc
# Setup GitHub repo
git init
git add .
git commit -m "Initial commit"
git remote add origin <repo-url>
git push -u origin main
# Update package.json
{
"name": "@yourscope/package-name",
"version": "1.0.0",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": ["dist"],
"scripts": {
"build": "tsup",
"test": "vitest",
"prepublishOnly": "pnpm test && pnm build"
}
}
# Login to npm (one-time)
pnpm login
# Version bump (automatically creates git tag)
pnpm version patch # 0.0.1 -> 0.0.2
# or
pnpm version minor # 0.0.1 -> 0.1.0
# or
pnpm version major # 0.0.1 -> 1.0.0
# Push code and tags
git push
git push --tags
# Publish to npm
pnpm publish --access public # --access public only needed first time for scoped packages
Go to GitHub after pushing tags
Releases > Draft new release
Choose the tag
Write release notes
Publish release
# Make changes
git commit -m "feat: new feature"
# Version and publish
pnpm version minor
git push && git push --tags
pnpm publish
# Create GitHub release
patch: Bug fixes (1.0.0 -> 1.0.1)
minor: New features, backward compatible (1.0.0 -> 1.1.0)
major: Breaking changes (1.0.0 -> 2.0.0)
Always run tests before publishing
Keep consistent version numbers between git tags and npm
Write clear release notes
Consider semantic versioning (semver)
Use a .npmignore or files array to control published contents
Set up CI/CD for automated testing/publishing
This workflow ensures:
Version control is in sync with package versions
Changes are properly documented
Package is tested before publishing
GitHub and npm stay in sync