Skip to content

Init: Exclude mdx stories when docs feature isn't selected during init #32142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025

Conversation

valentinpalkovic
Copy link
Contributor

@valentinpalkovic valentinpalkovic commented Jul 28, 2025

Closes #32138

What I did

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 pull request has been released as version 0.0.0-pr-32142-sha-424d5226. Try it out in a new sandbox by running npx [email protected] sandbox or in an existing project with npx [email protected] upgrade.

More information
Published version 0.0.0-pr-32142-sha-424d5226
Triggered by @valentinpalkovic
Repository storybookjs/storybook
Branch valentin/init-storybook-without-mdx-stories
Commit 424d5226
Datetime Mon Jul 28 12:58:55 UTC 2025 (1753707535)
Workflow run 16569685274

To request a new release of this pull request, mention the @storybookjs/core team.

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

Greptile Summary

This PR fixes a bug where Storybook's initialization process was incorrectly including MDX story patterns in the main configuration even when users selected minimal installations without the docs feature. The change addresses issue #32138 by making the story configuration dynamic based on selected features during init.

The core fix involves three coordinated changes:

  1. Type Safety Improvement: The GeneratorOptions.features field is changed from string[] to Array<GeneratorFeature> in types.ts, restricting valid feature values to 'docs', 'test', and 'onboarding'. This provides compile-time checking and prevents invalid feature strings.

  2. Conditional MDX Pattern Logic: The configureMain function in configure.ts is modified to conditionally add MDX story patterns (**/*.mdx) to the stories array only when features.includes('docs') is true. Previously, MDX patterns were always included regardless of feature selection.

  3. Feature Parameter Passing: The baseGenerator.ts file is updated to pass the features array to the configureMain function call, ensuring that feature selection made during initialization is properly communicated to the configuration generation.

This change integrates with Storybook's existing feature system, which allows users to selectively enable functionality like docs, testing, and onboarding during the initialization process. The fix prevents "No story files found" warnings when running minimal Storybook installations that don't need MDX support, while maintaining backward compatibility for full installations that include the docs addon.

Confidence score: 4/5

• This is a targeted bug fix that should resolve the specific issue without introducing new problems
• The implementation follows good practices with type safety improvements and conditional logic
• Need to verify that the feature detection logic works correctly across all initialization scenarios and that no edge cases are missed

Copy link
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.

3 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Jul 28, 2025

View your CI Pipeline Execution ↗ for commit 2875061

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

☁️ Nx Cloud last updated this comment at 2025-07-28 14:16:14 UTC

@valentinpalkovic valentinpalkovic force-pushed the valentin/init-storybook-without-mdx-stories branch from 424d522 to 2875061 Compare July 28, 2025 13:51
@storybook-pr-benchmarking
Copy link

Package Benchmarks

Commit: 2875061, ran on 28 July 2025 at 14:01:25 UTC

The following packages have significant changes to their size or dependencies:

@storybook/builder-webpack5

Before After Difference
Dependency count 198 198 0
Self size 80 KB 80 KB 0 B
Dependency size 31.32 MB 31.35 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 203 203 0
Self size 28 KB 28 KB 0 B
Dependency size 28.05 MB 28.08 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 538 538 0
Self size 903 KB 903 KB 0 B
Dependency size 59.05 MB 59.08 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 286 286 0
Self size 25 KB 25 KB 0 B
Dependency size 43.64 MB 43.67 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 210 210 0
Self size 17 KB 17 KB 0 B
Dependency size 32.59 MB 32.62 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 177 177 0
Self size 24 KB 24 KB 0 B
Dependency size 30.47 MB 30.50 MB 🚨 +29 KB 🚨
Bundle Size Analyzer Link Link

@yannbf yannbf merged commit d6d2191 into next Jul 29, 2025
54 checks passed
@yannbf yannbf deleted the valentin/init-storybook-without-mdx-stories branch July 29, 2025 07:55
@github-actions github-actions bot mentioned this pull request Jul 29, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: 9.1 beta - No story files found for the specified pattern: src/**/*.mdx in minimal installs
2 participants