Skip to content

Build: Fix critical bug in the pre-build hook#32468

Merged
ndelangen merged 1 commit into
nextfrom
norbert/fix-pre-compile-hook-core
Sep 16, 2025
Merged

Build: Fix critical bug in the pre-build hook#32468
ndelangen merged 1 commit into
nextfrom
norbert/fix-pre-compile-hook-core

Conversation

@ndelangen
Copy link
Copy Markdown
Member

@ndelangen ndelangen commented Sep 16, 2025

What I did

Fix critical bug in pre-build script

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make 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/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

Updated On: 2025-09-16 09:03:53 UTC

This PR addresses a critical bug in Storybook's pre-build hook system by making key fixes and dependency updates. The core issue was that the generate-source-files.ts script wasn't self-executing when called by the pre-build hook in build-config.ts. The main changes include:

  1. Fixed the pre-build script execution: Added a direct function call generateSourceFiles() at the end of generate-source-files.ts to make it self-executing when run via jiti. Without this, the pre-build hook would load the script but not actually generate the critical source files needed for the build.

  2. Code cleanup and organization: Removed unused fs import from build-config.ts and refactored path construction in the generator script to use a shared CODE_DIR constant for better maintainability.

  3. Major dependency updates: Updated commander (v12 → v14), boxen (v7 → v8), and giget (v1 → v2) across multiple packages (@storybook/core, @storybook/cli, and @storybook/create-storybook). These updates likely resolve compatibility issues that were contributing to the pre-build failures.

The pre-build hook is critical to Storybook's build process as it generates framework types, version mappings, and export configurations that other parts of the system depend on. The script uses esbuild to compile TypeScript files, generates framework metadata, and formats output with prettier. Without proper execution, this would cause silent failures leading to stale or missing generated files that could break the entire build pipeline.

Confidence score: 4/5

  • This PR addresses a critical build system issue with a focused fix that directly resolves the root cause
  • Score reflects the straightforward nature of the core fix (adding function execution) combined with uncertainty about major dependency updates
  • Pay close attention to the dependency updates in package.json files as they involve major version bumps that could introduce breaking changes

@ndelangen ndelangen enabled auto-merge September 16, 2025 09:02
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@ndelangen ndelangen changed the title Fix critical bug in the pre-build hook PreBuild: Fix critical bug in the pre-build hook Sep 16, 2025
@ndelangen ndelangen self-assigned this Sep 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 16, 2025

Fails
🚫 PR title must be in the format of "Area: Summary", With both Area and Summary starting with a capital letter Good examples: - "Docs: Describe Canvas Doc Block" - "Svelte: Support Svelte v4" Bad examples: - "add new api docs" - "fix: Svelte 4 support" - "Vue: improve docs"

Generated by 🚫 dangerJS against 7c56bea

@ndelangen ndelangen force-pushed the norbert/fix-pre-compile-hook-core branch from 4e4b9d8 to 7c56bea Compare September 16, 2025 09:09
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Sep 16, 2025

View your CI Pipeline Execution ↗ for commit 7c56bea

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 50s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-16 09:32:04 UTC

@ndelangen ndelangen added core build Internal-facing build tooling & test updates ci:normal labels Sep 16, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical bug in Storybook's pre-build hook system where the source file generation script wasn't executing properly, and includes major dependency updates for several core packages.

  • Added execution call to make the generate-source-files.ts script self-executing
  • Refactored path construction for better maintainability using a shared CODE_DIR constant
  • Updated major dependencies (commander v12→v14, boxen v7→v8, giget v1→v2) across multiple packages

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
code/core/scripts/generate-source-files.ts Fixed script execution and improved path handling with CODE_DIR constant
code/core/build-config.ts Removed unused fs import

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread code/core/scripts/generate-source-files.ts
@ndelangen ndelangen changed the title PreBuild: Fix critical bug in the pre-build hook Build: Fix critical bug in the pre-build hook Sep 16, 2025
@ndelangen ndelangen disabled auto-merge September 16, 2025 09:38
@ndelangen ndelangen merged commit a6d0d4b into next Sep 16, 2025
64 of 66 checks passed
@ndelangen ndelangen deleted the norbert/fix-pre-compile-hook-core branch September 16, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants