Skip to content

Conversation

@yannbf
Copy link
Member

@yannbf yannbf commented Jan 19, 2026

Closes #

What I did

The component transformer was not account for components like memo(() => </>) so this PR fixes that.
See tests for example cases.

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

See tests

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

Release Notes

  • New Features

    • Added support for wrapped component default exports (e.g., components exported via wrapper functions).
    • Improved test generation for wrapped exports with proper metadata handling.
  • Tests

    • Added comprehensive test coverage for wrapped export scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit a614c73

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ✅ Succeeded 10m 31s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 09:56:13 UTC

@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit 36293f0


☁️ Nx Cloud last updated this comment at 2026-01-19 09:38:52 UTC

@nx-cloud
Copy link

nx-cloud bot commented Jan 19, 2026

View your CI Pipeline Execution ↗ for commit a614c73

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ⏳ In Progress ... View ↗

☁️ Nx Cloud last updated this comment at 2026-01-19 09:45:42 UTC

@ndelangen ndelangen self-requested a review January 19, 2026 09:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

The changes add support for handling wrapped default exports (e.g., export default someWrapper(Component)) in the CSF vitest plugin's component transformer. The transformer now detects CallExpression default exports, hoists them to const declarations, and generates appropriate test scaffolding. A corresponding test case validates this behavior.

Changes

Cohort / File(s) Summary
Component Transformer Implementation
code/core/src/csf-tools/vitest-plugin/component-transformer.ts
Adds logic to detect and handle default exports that are CallExpressions. Generates a unique identifier from the file name, creates a const wrapper variable, replaces the export default with the identifier, and registers the component. Notes that JSX detection is not performed for wrapped exports.
Component Transformer Tests
code/core/src/csf-tools/vitest-plugin/component-transformer.test.ts
Introduces new test case "generates tests for wrapped exports" that verifies the transformer correctly hoists wrapped default exports (e.g., someWrapper(Component)) to const declarations, preserves the export, and generates vitest/storybook test blocks with inline snapshots for wrapped named exports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • storybookjs/storybook#33479: Directly extends the same component-transformer implementation with handling and tests for wrapped default exports.
✨ Finishing touches
  • 📝 Generate docstrings

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

@storybook-app-bot
Copy link

Package Benchmarks

Commit: a614c73, ran on 19 January 2026 at 09:56:47 UTC

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

@storybook/react-native-web-vite

Before After Difference
Dependency count 159 159 0
Self size 30 KB 30 KB 🎉 -10 B 🎉
Dependency size 23.00 MB 23.12 MB 🚨 +115 KB 🚨
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 183 183 0
Self size 775 KB 775 KB 🚨 +139 B 🚨
Dependency size 67.38 MB 67.46 MB 🚨 +74 KB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 176 176 0
Self size 30 KB 30 KB 🎉 -40 B 🎉
Dependency size 65.95 MB 66.03 MB 🚨 +74 KB 🚨
Bundle Size Analyzer Link Link
@yannbf yannbf merged commit c837a18 into next Jan 19, 2026
123 checks passed
@yannbf yannbf deleted the yann/ghost-stories-wrapped-components branch January 19, 2026 13:25
@github-actions github-actions bot mentioned this pull request Jan 19, 2026
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants