Build: Automatically recompile on branch switch#34930
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional Husky post-checkout Git hook that can reinstall dependencies and recompile the repo when switching branches, gated by STORYBOOK_COMPILE_ON_CHECKOUT.
Changes:
- Introduces
.husky/post-checkoutto runyarnandyarn task compile -s compilewhenSTORYBOOK_COMPILE_ON_CHECKOUTis set.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a conditional Git post-checkout hook ChangesPost-checkout hook
Manager globals export
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.husky/post-checkout:
- Around line 1-2: The post-checkout hook currently uses a non-empty check for
STORYBOOK_COMPILE_ON_CHECKOUT which treats any non-empty value (including
"false") as true; change the if condition in .husky/post-checkout to an explicit
boolean comparison such as [ "$STORYBOOK_COMPILE_ON_CHECKOUT" = "true" ] (or
check for "1" as an alternative) so yarn && yarn task compile -s compile only
runs when the variable is intentionally enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5f23ef26-d3be-427e-b306-cb88665d4112
📒 Files selected for processing (1)
.husky/post-checkout
Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
Co-authored-by: Sidnioulz <5108577+Sidnioulz@users.noreply.github.com>
What I did
Added an optional Git hook on checkout to reinstall deps and recompile the codebase. Ensures you're ready to use the branch without manual intervention.
Gated by
STORYBOOK_COMPILE_ON_CHECKOUTenv.Checklist for Contributors
Testing
Manual testing
git checkout -b dummy-branchand notice no compilationexport STORYBOOK_COMPILE_ON_CHECKOUT=truegit checkout -b dummier-branchand notice that SB now reinstalls deps and recompilesChecklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit