Skip to content

refactor(config): Replace prepare with prepack lifecycle script#1215

Merged
yamadashy merged 1 commit intomainfrom
refactor/prepare-to-prepack
Mar 10, 2026
Merged

refactor(config): Replace prepare with prepack lifecycle script#1215
yamadashy merged 1 commit intomainfrom
refactor/prepare-to-prepack

Conversation

@yamadashy
Copy link
Copy Markdown
Owner

@yamadashy yamadashy commented Mar 8, 2026

Replace prepare with prepack lifecycle script in package.json to fix the root cause of Docker and CI build failures.

Background

The prepare script (npm run build) runs on npm install and npm ci, which caused failures when devDependencies (rimraf, tsc) were unavailable — notably during Docker builds and CI production dependency steps. PR #1213 worked around this by switching to npm prune --omit=dev, but the root cause remained.

Why prepack

Scenario prepare prepack
npm install / npm ci Runs Does NOT run
npm pack / npm publish Runs Runs
Git dependency install Runs Runs
  • prepack does NOT run on npm ci → Docker/CI issue resolved at the root
  • prepack DOES run on git dependency install → website/server requirement ("repomix": "github:yamadashy/repomix#main") still satisfied
  • prepack DOES run on npm pack / npm publish → release workflow unaffected
  • Dockerfile and CI workflows already have explicit npm run build steps, so no downstream changes needed

Checklist

  • Run npm run test
  • Run npm run lint

🤖 Generated with Claude Code


Open with Devin

The `prepare` script runs on `npm ci` and `npm install`, which caused
Docker and CI failures when devDeps (rimraf, tsc) were unavailable.
`prepack` only runs on `npm pack`, `npm publish`, and git dependency
install — avoiding the issue while still supporting the website/server
git dependency requirement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue causing Docker and CI build failures by refactoring the project's npm lifecycle scripts. By switching from the "prepare" script to "prepack", the build process is now correctly aligned with dependency installation phases, preventing premature execution of build steps that rely on development dependencies. This ensures a more robust and reliable build environment across various deployment scenarios without impacting other essential workflows.

Highlights

  • Build Process Reliability: Replaced the "prepare" npm lifecycle script with "prepack" in package.json to prevent "npm run build" from executing during "npm install" or "npm ci".
  • CI/CD and Docker Fix: This change resolves Docker and CI build failures that occurred when development dependencies were not available, by ensuring the build step is not triggered prematurely.
  • Workflow Compatibility: Confirmed that "prepack" still runs for "npm pack", "npm publish", and Git dependency installations, maintaining compatibility with existing release and dependency workflows.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • package.json
    • Replaced the "prepare" lifecycle script with "prepack" in the "scripts" section.
Activity
  • The pull request was generated using Claude Code, indicating an initial automated creation.
  • No human review comments or activity have been recorded yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: abc324be-dad1-4489-987e-000a28dda73c

📥 Commits

Reviewing files that changed from the base of the PR and between acb744f and e27f719.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

The "prepare" npm lifecycle script in package.json has been replaced with a "prepack" script. Both execute the same "npm run build" command but are triggered at different stages in the npm lifecycle—prepare runs during install, while prepack runs before package creation.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Replaced "prepare" npm lifecycle script with "prepack" script, maintaining the same build command invocation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing the 'prepare' lifecycle script with 'prepack' in package.json configuration.
Description check ✅ Passed The description includes all required template sections with comprehensive context, background, and rationale. Both checklist items are present, though unchecked as expected pre-submission.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/prepare-to-prepack

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying repomix with  Cloudflare Pages  Cloudflare Pages

Latest commit: e27f719
Status: ✅  Deploy successful!
Preview URL: https://f6fa9ae9.repomix.pages.dev
Branch Preview URL: https://refactor-prepare-to-prepack.repomix.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the prepare npm lifecycle script with prepack. This is a well-reasoned change to fix build failures in CI and Docker environments by preventing the build script from running during a standard npm install. The prepack script is the appropriate choice here, as it correctly triggers the build for publishing and git dependency installations without affecting production installs. The change is correct and effectively resolves the issue described.

Note: Security Review has been skipped due to the limited scope of the PR.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.14%. Comparing base (acb744f) to head (e27f719).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1215   +/-   ##
=======================================
  Coverage   87.14%   87.14%           
=======================================
  Files         115      115           
  Lines        4310     4310           
  Branches      998      998           
=======================================
  Hits         3756     3756           
  Misses        554      554           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Mar 8, 2026

PR Review: refactor(config): Replace prepare with prepack lifecycle script

Overall: Approve — This is a clean, well-reasoned one-line change that fixes the root cause of Docker/CI build failures.

Summary

The change from prepare to prepack in package.json is correct and well-justified. The PR description is thorough and accurately documents the behavioral differences.

Verification

I verified the claims in the PR description against the codebase:

Claim Verified
Dockerfiles have explicit npm run build Yes — Dockerfile line 15
CI workflows have explicit build steps Yes — npm-publish.yml, ci.yml all have explicit npm run build
website/server uses git dependency github:yamadashy/repomix#main Yes — website/server/package.json
No downstream consumers rely on prepare auto-build Yes — all paths have explicit builds

The lifecycle behavior table in the PR description is accurate. For git dependencies, npm internally uses npm pack after cloning, so prepack correctly fires during that flow.

Minor Observations

Developer workflow change (informational, no action needed)

With prepare, running npm install after cloning the repo would automatically trigger npm run build. With prepack, developers will need to run npm run build explicitly after npm install.

This is a minor change to the local development setup flow documented in CONTRIBUTING.md (which shows git clonenpm installnpm run repomix). However, since npm run repomix already includes an explicit npm run build step ("repomix": "node --run build && ..."), this doesn't actually break the documented workflow. The only case affected would be developers who expected the project to be pre-built after npm install and tried to run tests or import from lib/ directly — but this is uncommon enough that it doesn't warrant concern.

Premortem Analysis

Potential failure scenarios and mitigations
  1. Git dependency install for website/server: The website/server/package.json uses "repomix": "github:yamadashy/repomix#main". When npm installs this git dependency, it clones the repo, runs npm ci, then runs npm pack — which triggers prepack. This flow is correct and the build will run. Risk: Low.

  2. CI regression: All CI workflows (ci.yml, npm-publish.yml, docker.yml) have explicit npm run build steps before any actions that depend on built artifacts. Risk: None.

  3. Docker build regression: The main Dockerfile runs npm ci && npm run build && npm link && npm prune --omit=dev. The explicit npm run build ensures this works regardless of lifecycle hooks. Risk: None.

  4. npm publish regression: The npm-publish.yml workflow has an explicit npm run build step, and prepack would also fire before npm pack/npm publish. Risk: None — double-covered.

  5. Third-party consumers using npm install github:yamadashy/repomix: These consumers rely on npm's git dependency flow which triggers prepack via the internal npm pack step. Risk: None.

Verdict

Clean change, well-documented rationale, no risks identified. This properly addresses the root cause that PR #1213 worked around.


Review by Claude

@yamadashy yamadashy merged commit 8ed0095 into main Mar 10, 2026
59 checks passed
@yamadashy yamadashy deleted the refactor/prepare-to-prepack branch March 10, 2026 13:34
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.

1 participant