Simplify version management by reading from package.json#210
Merged
Conversation
Collaborator
|
@senechko this won't work—some environments don't include the |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 58a0f9f. Configure here.
6 tasks
e14db4f to
22f180c
Compare
mike-engel
approved these changes
Jun 1, 2026
Replace the hardcoded version string in lib/version.ts with a direct import from package.json, eliminating the manual sync machinery: - Delete update-version.js (npm version hook that wrote lib/version.ts) - Delete check-version.ts (pre-commit guard against version drift) - Remove the "version" script from package.json - Remove the check-version pre-commit hook This works because npm always includes package.json in published tarballs regardless of the "files" field, so the runtime require from dist/lib/version.js resolves correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback from @mike-engel: some environments (e.g. Rollup-bundled Lambda) don't include package.json at runtime, so importing it directly breaks. See #100 for the original issue. Instead, keep the hardcoded version string in lib/version.ts and sync it automatically via scripts/sync-version.js: - prebuild: runs before tsc to ensure version.ts matches package.json - version: runs during npm version to update and stage version.ts This preserves the bundler-safe hardcoded string while eliminating the manual check-version.ts pre-commit guard and the separate update-version.js script. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
22f180c to
2981747
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
lib/version.tswithimport packageJson from '../package.json', so the version is always derived frompackage.jsonat runtimeupdate-version.js(npm version hook) andcheck-version.ts(pre-commit guard) — both are no longer needed"version"script frompackage.jsonand thecheck-version.tspre-commit hookThis works because npm always includes
package.jsonin published tarballs regardless of the"files"field, sodist/lib/version.js'srequire("../package.json")resolves correctly in consumers'node_modules.Test plan
npm run buildsucceedsnpm run lintpassesnpm testpasses (162 tests, 100% coverage)dist/lib/version.jsemitsrequire("../package.json")which resolves to the package root🤖 Generated with Claude Code
Note
Low Risk
Build/release tooling and developer hooks only; runtime API behavior is unchanged aside from keeping
lib/version.tsin sync at build time.Overview
Version sync is centralized in
scripts/sync-version.js(replacing rootupdate-version.js), which rewriteslib/version.tsfrompackage.json.prebuildruns that script beforetsc, and theversionnpm lifecycle script now syncs and stageslib/version.tsfor release commits.Manual drift checks are removed:
check-version.tsis deleted, the Husky pre-commit hook no longer runs it (onlylint-staged), and ESLint/TS eslint configs stop treatingcheck-version.tsas a project file.Reviewed by Cursor Bugbot for commit 2981747. Bugbot is set up for automated code reviews on this repo. Configure here.