fix: replace prepare with prepack to fix git install#8
Merged
Conversation
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
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.
Problem
Installing from git via
pi install git:github.com/mattleong/pi-code-previewsfails with:pi installrunsnpm install --omit=dev, which skips devDependencies. Thepreparelifecycle script still fires and tries to runtsdown, buttsdownis a devDependency and isn't installed.Fix
Replace the
preparescript withprepack. Theprepacklifecycle hook only runs beforenpm pack/npm publish, not duringnpm install. This means:prepackbuildsdist/before the tarball is created, so the published package contains the built outputtsdown: command not founderror./index.tsat runtime, sodist/is never needed at git-install timeWhy not other approaches?
tsdowntodependenciespreparedist/to reponpx tsdownin build script--omit=dev, adds latencyCloses #7