Core: Ignore story-like directories in indexer#34806
Merged
valentinpalkovic merged 2 commits intoMay 19, 2026
Merged
Conversation
valentinpalkovic
approved these changes
May 15, 2026
Contributor
|
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)
📝 WalkthroughWalkthroughfindMatchingFiles now passes ChangesStory File Indexing
Sequence Diagram(s)sequenceDiagram
participant Test
participant FS
participant StoryIndexGenerator
participant globby
Test->>FS: ensure Primary.png exists at src/__screenshots__/Button.stories.tsx/Primary.png
Test->>StoryIndexGenerator: invoke findMatchingFiles('stories.tsx')
StoryIndexGenerator->>globby: call globby(...) with onlyFiles: true
globby-->>StoryIndexGenerator: returns file-only paths
StoryIndexGenerator-->>Test: returns files map (no directory or Primary.png keys)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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. Comment |
aa14d2f to
5ee7e9a
Compare
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 72 | 60 | 🎉 -12 🎉 |
| Self size | 20.30 MB | 20.52 MB | 🚨 +221 KB 🚨 |
| Dependency size | 36.17 MB | 32.84 MB | 🎉 -3.34 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 536 | 536 | 0 |
| Self size | 662 KB | 651 KB | 🎉 -12 KB 🎉 |
| Dependency size | 61.20 MB | 61.20 MB | 🎉 -103 B 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 203 | 194 | 🎉 -9 🎉 |
| Self size | 908 KB | 908 KB | 0 B |
| Dependency size | 87.59 MB | 84.57 MB | 🎉 -3.02 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 196 | 187 | 🎉 -9 🎉 |
| Self size | 32 KB | 32 KB | 0 B |
| Dependency size | 86.08 MB | 83.06 MB | 🎉 -3.02 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 73 | 61 | 🎉 -12 🎉 |
| Self size | 1.08 MB | 1.08 MB | 🎉 -2 KB 🎉 |
| Dependency size | 56.48 MB | 53.36 MB | 🎉 -3.12 MB 🎉 |
| Bundle Size Analyzer | node | node |
The original PR added `${globPattern}/**` as a globby ignore pattern to
prevent story-like directories from being indexed. However, micromatch's
`/**` suffix can match zero-length trailing paths, causing the pattern to
also match the story files themselves. This caused ALL stories to be
ignored, resulting in 44 test failures and all sandbox dev/e2e/chromatic
CI failures.
The correct fix is to rely on globby's `onlyFiles: true` option (which is
the fast-glob default but is now explicit) to prevent directories from
being returned. This correctly excludes the `Button.stories.tsx` directory
from being indexed while keeping all legitimate story files.
Note: A secondary attempt with `${globPattern}/**/*` also failed because
globby tries to stat() the ignore pattern path and throws ENOTDIR when
the pattern resolves through an actual file (e.g., errors/A.mdx/**/*).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
valentinpalkovic
approved these changes
May 19, 2026
ndelangen
approved these changes
May 19, 2026
This was referenced May 19, 2026
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.
What I did
StoryIndexGenerator.findMatchingFilesfrom returning files nested inside directories whose names match the configured story glob.node_modulesignore.Button.stories.tsxand assert neither the directory nor its nestedPrimary.pngfile is indexed.Fixes #28954.
Testing
git diff --checkyarn oxfmt --check code/core/src/core-server/utils/StoryIndexGenerator.ts code/core/src/core-server/utils/StoryIndexGenerator.test.tsnode --input-type=moduleglobby check confirming**/*.stories.tsx/**ignores nested files underButton.stories.tsx/Local test note
I installed dependencies with
yarn install --immutable, then tried the focused Vitest file. The root config failed locally because@storybook/addon-vitest/dist/vitest-plugin/index.jswas not resolvable, and the direct core config failed to resolvestorybook/internal/commonfrom the unbuilt workspace. I did not claim the full Vitest suite as passing locally.Summary by CodeRabbit
Bug Fixes
Tests