Skip to content

fix: replace prepare with prepack to fix git install#8

Merged
mattleong merged 1 commit into
mattleong:mainfrom
monotykamary:fix/prepare-to-prepack
May 10, 2026
Merged

fix: replace prepare with prepack to fix git install#8
mattleong merged 1 commit into
mattleong:mainfrom
monotykamary:fix/prepare-to-prepack

Conversation

@monotykamary

Copy link
Copy Markdown
Contributor

Problem

Installing from git via pi install git:github.com/mattleong/pi-code-previews fails with:

> pi-code-previews@0.1.25 prepare
> npm run build

> pi-code-previews@0.1.25 build
> tsdown

sh: tsdown: command not found

pi install runs npm install --omit=dev, which skips devDependencies. The prepare lifecycle script still fires and tries to run tsdown, but tsdown is a devDependency and isn't installed.

Fix

Replace the prepare script with prepack. The prepack lifecycle hook only runs before npm pack / npm publish, not during npm install. This means:

  • npm publish still works — prepack builds dist/ before the tarball is created, so the published package contains the built output
  • git install via pi no longer triggers a build, avoiding the tsdown: command not found error
  • pi loads the extension via jiti from ./index.ts at runtime, so dist/ is never needed at git-install time

Why not other approaches?

Approach Drawback
Move tsdown to dependencies Semantically wrong (build tool ≠ runtime dep), bloats installs
Conditional prepare Complex, noisy
Commit dist/ to repo Messy git diffs, merge conflicts in generated files
npx tsdown in build script Defeats --omit=dev, adds latency

Closes #7

The prepare lifecycle script runs during npm install, which triggers
npm run build -> tsdown. When pi installs from git, it uses
npm install --omit=dev, so tsdown (a devDependency) is not available,
causing 'sh: tsdown: command not found'.

pi loads extensions via jiti from ./index.ts directly, so the dist/
output from npm run build is never needed at git-install time. The
built output is only needed for npm publish, where prepack runs before
npm pack, ensuring dist/ is included in the tarball.

Fixes mattleong#7
@mattleong mattleong merged commit 6b7e6a3 into mattleong:main May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsdown command not found for github install

2 participants