Skip to content

Core: Improve globbing using dynamic CWD#32990

Merged
ndelangen merged 4 commits into
storybookjs:nextfrom
ia319:bug/32835-correct-glob-working-directory
Nov 12, 2025
Merged

Core: Improve globbing using dynamic CWD#32990
ndelangen merged 4 commits into
storybookjs:nextfrom
ia319:bug/32835-correct-glob-working-directory

Conversation

@ia319
Copy link
Copy Markdown
Member

@ia319 ia319 commented Nov 8, 2025

Closes #32835

What I did

  • calculate dynamic CWD for each story specifier
  • ensure globby correctly excludes node_modules when glob pattern references parent directories

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

After the change, the repository mentioned in the issue runs normally, and no errors were found.

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 publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Refactor
    • Improved file-pattern matching and per-pattern directory resolution so file discovery handles patterns that reference locations outside the current working directory more reliably, reducing missed or mis-resolved files during searches. No public APIs or exported interfaces were changed.

- calculate dynamic CWD for each story specifier
- ensure globby correctly excludes `node_modules` when glob pattern references parent directories
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Nov 8, 2025

View your CI Pipeline Execution ↗ for commit c464c38

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

☁️ Nx Cloud last updated this comment at 2025-11-12 09:44:51 UTC

@valentinpalkovic valentinpalkovic added core ci:normal Run our default set of CI jobs (choose this for most PRs). bug labels Nov 10, 2025
@coderabbitai

This comment was marked as spam.

@storybook-app-bot
Copy link
Copy Markdown

storybook-app-bot Bot commented Nov 10, 2025

Package Benchmarks

Commit: c464c38, ran on 21 November 2025 at 11:16:11 UTC

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

@storybook/addon-a11y

Before After Difference
Dependency count 2 2 0
Self size 181 KB 509 KB 🚨 +328 KB 🚨
Dependency size 2.97 MB 2.97 MB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/addon-docs

Before After Difference
Dependency count 18 18 0
Self size 1.65 MB 1.89 MB 🚨 +232 KB 🚨
Dependency size 9.25 MB 10.21 MB 🚨 +963 KB 🚨
Bundle Size Analyzer Link Link

storybook-addon-pseudo-states

Before After Difference
Dependency count 0 0 0
Self size 21 KB 24 KB 🚨 +3 KB 🚨
Dependency size 692 B 689 B 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/addon-themes

Before After Difference
Dependency count 1 1 0
Self size 18 KB 20 KB 🚨 +2 KB 🚨
Dependency size 28 KB 28 KB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/addon-vitest

Before After Difference
Dependency count 2 6 🚨 +4 🚨
Self size 376 KB 509 KB 🚨 +134 KB 🚨
Dependency size 338 KB 1.53 MB 🚨 +1.19 MB 🚨
Bundle Size Analyzer Link Link

@storybook/builder-vite

Before After Difference
Dependency count 17 11 🎉 -6 🎉
Self size 304 KB 330 KB 🚨 +25 KB 🚨
Dependency size 2.00 MB 1.30 MB 🎉 -700 KB 🎉
Bundle Size Analyzer Link Link

@storybook/builder-webpack5

Before After Difference
Dependency count 191 187 🎉 -4 🎉
Self size 75 KB 73 KB 🎉 -3 KB 🎉
Dependency size 32.19 MB 31.98 MB 🎉 -214 KB 🎉
Bundle Size Analyzer Link Link

storybook

Before After Difference
Dependency count 39 43 🚨 +4 🚨
Self size 19.65 MB 23.02 MB 🚨 +3.37 MB 🚨
Dependency size 16.40 MB 17.36 MB 🚨 +959 KB 🚨
Bundle Size Analyzer Link Link

@storybook/angular

Before After Difference
Dependency count 191 187 🎉 -4 🎉
Self size 118 KB 126 KB 🚨 +8 KB 🚨
Dependency size 30.31 MB 30.00 MB 🎉 -309 KB 🎉
Bundle Size Analyzer Link Link

@storybook/ember

Before After Difference
Dependency count 195 191 🎉 -4 🎉
Self size 15 KB 17 KB 🚨 +1 KB 🚨
Dependency size 28.91 MB 28.70 MB 🎉 -216 KB 🎉
Bundle Size Analyzer Link Link

@storybook/html-vite

Before After Difference
Dependency count 20 14 🎉 -6 🎉
Self size 22 KB 23 KB 🚨 +906 B 🚨
Dependency size 2.34 MB 1.67 MB 🎉 -674 KB 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs

Before After Difference
Dependency count 537 533 🎉 -4 🎉
Self size 645 KB 749 KB 🚨 +104 KB 🚨
Dependency size 59.13 MB 59.04 MB 🎉 -93 KB 🎉
Bundle Size Analyzer Link Link

@storybook/nextjs-vite

Before After Difference
Dependency count 128 124 🎉 -4 🎉
Self size 1.12 MB 3.83 MB 🚨 +2.71 MB 🚨
Dependency size 21.95 MB 21.88 MB 🎉 -66 KB 🎉
Bundle Size Analyzer Link Link

@storybook/preact-vite

Before After Difference
Dependency count 20 14 🎉 -6 🎉
Self size 13 KB 14 KB 🚨 +979 B 🚨
Dependency size 2.33 MB 1.65 MB 🎉 -674 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 160 156 🎉 -4 🎉
Self size 30 KB 31 KB 🚨 +1 KB 🚨
Dependency size 23.13 MB 23.06 MB 🎉 -68 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 118 114 🎉 -4 🎉
Self size 35 KB 37 KB 🚨 +2 KB 🚨
Dependency size 19.75 MB 19.68 MB 🎉 -67 KB 🎉
Bundle Size Analyzer Link Link

@storybook/react-webpack5

Before After Difference
Dependency count 277 273 🎉 -4 🎉
Self size 24 KB 25 KB 🚨 +1 KB 🚨
Dependency size 44.08 MB 43.98 MB 🎉 -93 KB 🎉
Bundle Size Analyzer Link Link

@storybook/server-webpack5

Before After Difference
Dependency count 203 199 🎉 -4 🎉
Self size 16 KB 17 KB 🚨 +962 B 🚨
Dependency size 33.45 MB 33.24 MB 🎉 -214 KB 🎉
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 24 19 🎉 -5 🎉
Self size 56 KB 59 KB 🚨 +3 KB 🚨
Dependency size 27.00 MB 26.79 MB 🎉 -212 KB 🎉
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 25 20 🎉 -5 🎉
Self size 56 KB 58 KB 🚨 +2 KB 🚨
Dependency size 27.06 MB 26.85 MB 🎉 -209 KB 🎉
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 114 109 🎉 -5 🎉
Self size 35 KB 38 KB 🚨 +3 KB 🚨
Dependency size 44.15 MB 43.95 MB 🎉 -209 KB 🎉
Bundle Size Analyzer Link Link

@storybook/web-components-vite

Before After Difference
Dependency count 21 15 🎉 -6 🎉
Self size 19 KB 20 KB 🚨 +888 B 🚨
Dependency size 2.37 MB 1.70 MB 🎉 -673 KB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 173 187 🚨 +14 🚨
Self size 773 KB 928 KB 🚨 +155 KB 🚨
Dependency size 66.62 MB 73.00 MB 🚨 +6.38 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 166 169 🚨 +3 🚨
Self size 30 KB 35 KB 🚨 +5 KB 🚨
Dependency size 65.19 MB 69.43 MB 🚨 +4.24 MB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 40 44 🚨 +4 🚨
Self size 999 KB 1.55 MB 🚨 +549 KB 🚨
Dependency size 36.05 MB 40.38 MB 🚨 +4.33 MB 🚨
Bundle Size Analyzer node node

@storybook/csf-plugin

Before After Difference
Dependency count 9 9 0
Self size 8 KB 9 KB 🚨 +1 KB 🚨
Dependency size 1.27 MB 1.27 MB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/react-dom-shim

Before After Difference
Dependency count 0 0 0
Self size 18 KB 22 KB 🚨 +4 KB 🚨
Dependency size 791 B 788 B 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/preset-create-react-app

Before After Difference
Dependency count 68 68 0
Self size 32 KB 36 KB 🚨 +4 KB 🚨
Dependency size 5.98 MB 5.98 MB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

@storybook/preset-react-webpack

Before After Difference
Dependency count 170 170 0
Self size 18 KB 21 KB 🚨 +2 KB 🚨
Dependency size 31.32 MB 31.32 MB 🚨 +1 KB 🚨
Bundle Size Analyzer Link Link

@storybook/preset-server-webpack

Before After Difference
Dependency count 10 10 0
Self size 7 KB 8 KB 🚨 +2 KB 🚨
Dependency size 1.20 MB 1.20 MB 🚨 +1 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react

Before After Difference
Dependency count 57 57 0
Self size 716 KB 833 KB 🚨 +117 KB 🚨
Dependency size 12.92 MB 12.92 MB 🚨 +4 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3

Before After Difference
Dependency count 3 3 0
Self size 55 KB 61 KB 🚨 +6 KB 🚨
Dependency size 211 KB 211 KB 🎉 -3 B 🎉
Bundle Size Analyzer Link Link

Comment thread code/core/src/core-server/utils/StoryIndexGenerator.ts
@ia319 ia319 requested a review from ndelangen November 11, 2025 12:40
@ndelangen ndelangen changed the title fix(core): calculate dynamic CWD for story globbing Core: Improve globbing using dynamic CWD Nov 12, 2025
@ndelangen ndelangen merged commit 9c3a8f7 into storybookjs:next Nov 12, 2025
56 of 58 checks passed
@yannbf yannbf removed the needs qa label Nov 25, 2025
@ndelangen
Copy link
Copy Markdown
Member

@ia319 I'm reverting this PR, it seems it caused issues with some negated globs, see this issue:
#33197

I'd welcome this being fixed still, are you open to work on this still, but in such a way negated globs do not break? 🙏

@ia319
Copy link
Copy Markdown
Member Author

ia319 commented Nov 28, 2025

I'd welcome this being fixed still, are you open to work on this still, but in such a way negated globs do not break? 🙏

I have some guesses, and I want to wait for his reply at "#33197 (comment)".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ci:normal Run our default set of CI jobs (choose this for most PRs). core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Stories glob should exclude node_modules

4 participants