I’m setting up a new npm library to be published in a private registry. I have these scripts:
"build": "tsc --p ./tsconfig-build.json && vite build",
"release": "commit-and-tag-version --no-verify",
"prepublishOnly": "npm run release && npm run build"
The problem is that, even though release
effectively runs before publishing when I do npm publish
, the package that gets published has the previous version. So the timeline goes something like this:
- My current
package.json
has"version": "0.0.10"
- I run
npm publish
- Triggers
prepublishOnly
that runsnpm run release && npm run build
commit-and-tag-version
correctly bumpspackage.json
andpackage-lock.json
and tags my repo withv0.0.11
vite build
bundles the librarypublish
packs my library as[email protected]
, ignoring the recent bump triggered duringprepublishOnly
Everything works as expected if I delete the prepublishOnly
script and manually do:
npm run release && npm run build && npm publish
Is this the expected behavior of prepublishOnly
? Any suggestions on how to make this work properly, without having a custom publish script like:
"publishLibrary" : "npm run release && npm run build && npm publish"
1