Skip to content

Fix docs Meta resolution for split CSF4 story chunks#34375

Closed
raashish1601 wants to merge 1 commit into
storybookjs:nextfrom
raashish1601:contributor-07/storybook-34373
Closed

Fix docs Meta resolution for split CSF4 story chunks#34375
raashish1601 wants to merge 1 commit into
storybookjs:nextfrom
raashish1601:contributor-07/storybook-34373

Conversation

@raashish1601
Copy link
Copy Markdown

@raashish1601 raashish1601 commented Mar 27, 2026

Fixes #34373.

Summary

  • fall back to named story exports when <Meta of={Stories} /> receives a split namespace object without a default export
  • keep <Meta of={...} /> strict by refusing mixed namespaces whose story exports resolve to different CSF files
  • add docs-context regressions for the split-chunk CSF4 path and the mixed-namespace guard

Testing

  • corepack yarn --cwd code build storybook --no-watch --no-prod
  • corepack yarn --cwd code vitest run --config core/vitest.config.ts core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts core/src/preview-api/modules/preview-web/render/MdxDocsRender.test.ts

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of module namespace objects without default exports in story file resolution.
    • Enhanced module export inference to better resolve stories from namespace objects by scanning exported values.
  • Tests

    • Expanded coverage for scenarios where story modules lack default exports.
    • Added validation for edge cases involving multi-source story exports.
    • Updated test utilities to support optional default export configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 400fcc56-6aff-449b-ae3e-d60a06c47376

📥 Commits

Reviewing files that changed from the base of the PR and between 0efef13 and 183acc5.

📒 Files selected for processing (3)
  • code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts
  • code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts
  • code/core/src/preview-api/modules/preview-web/docs-context/test-utils.ts

📝 Walkthrough

Walkthrough

Enhanced DocsContext module resolution to support namespace objects lacking default exports. Added conditional mapping for default exports, implemented fallback logic to infer CSF files by scanning object values and matching stories, and expanded test coverage accordingly.

Changes

Cohort / File(s) Summary
Implementation
code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.ts
Conditional CSF file mapping for default export presence; added fallback resolution logic scanning object values to infer CSF files when direct lookup fails; minor formatting adjustments.
Test Coverage
code/core/src/preview-api/modules/preview-web/docs-context/DocsContext.test.ts
New test cases for referenceMeta with namespace objects lacking default export; extended resolveOf tests for exports sharing only story references; reformatted existing expectations for readability.
Test Utilities
code/core/src/preview-api/modules/preview-web/docs-context/test-utils.ts
Extended csfFileParts function signature with optional includeDefaultExport parameter (defaults to true) to conditionally shape moduleExports structure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • storybookjs/storybook#33280: Modifies DocsContext's module namespace resolution logic with fallback scanning of object values to map exports to CSF files, directly related to this PR's enhanced export resolution approach.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@valentinpalkovic
Copy link
Copy Markdown
Contributor

Hi @raashish1601 ,

Due to a recent high volume of unreviewed AI-generated PRs, we are requesting verification and proof that the implemented fix actually works. Please provide a simple GIF/Video or image of how the bugfix works, optimally with before-and-after comparisons.

Thank you for your understanding!

@valentinpalkovic
Copy link
Copy Markdown
Contributor

Hi @raashish1601,

We requested verification that this PR works as intended, but haven't received a response in over two weeks. We're closing this PR for now.

If you'd like to continue working on this, feel free to reopen the PR with the requested verification (a GIF/video or screenshot showing before-and-after behavior).

Thank you for your contribution!

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: <Meta of={} /> fails in production build when CSF4 story module is split into a separate chunk

2 participants