From 172c44a547c6ee891243e594a18a5223e2631054 Mon Sep 17 00:00:00 2001 From: satoshai-dev <262845409+satoshai-dev@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:00:16 +0000 Subject: [PATCH 1/2] fix: inline version at build time instead of createRequire Replace runtime `createRequire` + `package.json` read with tsup's `define` option to inline the version string at build time. This removes the dependency on package.json being on disk next to dist/ and works correctly in bundled/deploy environments. Closes #10 Co-Authored-By: Claude Opus 4.6 --- src/cli.ts | 6 ++---- tsup.config.ts | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index 68b0ebc..c88733a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,14 +1,12 @@ -import { createRequire } from 'node:module'; import { defineCommand, runMain } from 'citty'; import { fetchCommand } from './commands/fetch.js'; -const require = createRequire(import.meta.url); -const { version } = require('../package.json') as { version: string }; +declare const __VERSION__: string; const main = defineCommand({ meta: { name: 'abi-cli', - version, + version: __VERSION__, description: 'Fetch Stacks contract ABIs and generate TypeScript definitions', }, subCommands: { diff --git a/tsup.config.ts b/tsup.config.ts index 15f676a..a379221 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'tsup'; +import pkg from './package.json'; export default defineConfig([ { @@ -14,6 +15,7 @@ export default defineConfig([ { entry: ['src/cli.ts'], format: ['esm'], + define: { __VERSION__: JSON.stringify(pkg.version) }, banner: { js: '#!/usr/bin/env node' }, sourcemap: true, splitting: false, From 7e8466e9a8494cf2ac4a36fce2435d14dc63fcff Mon Sep 17 00:00:00 2001 From: satoshai-dev <262845409+satoshai-dev@users.noreply.github.com> Date: Tue, 24 Feb 2026 18:12:15 +0000 Subject: [PATCH 2/2] chore: add changeset Co-Authored-By: Claude Opus 4.6 --- .changeset/fix-inline-version.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-inline-version.md diff --git a/.changeset/fix-inline-version.md b/.changeset/fix-inline-version.md new file mode 100644 index 0000000..ab01f5f --- /dev/null +++ b/.changeset/fix-inline-version.md @@ -0,0 +1,5 @@ +--- +"@satoshai/abi-cli": patch +--- + +Inline version at build time via tsup define instead of runtime createRequire