Skip to content

CLI: Support peerDependencies in framework detection for component libraries#34516

Open
zhyd1997 wants to merge 1 commit intostorybookjs:nextfrom
zhyd1997:fix/yadong-issue-34493-1775786283
Open

CLI: Support peerDependencies in framework detection for component libraries#34516
zhyd1997 wants to merge 1 commit intostorybookjs:nextfrom
zhyd1997:fix/yadong-issue-34493-1775786283

Conversation

@zhyd1997
Copy link
Copy Markdown
Contributor

@zhyd1997 zhyd1997 commented Apr 10, 2026

Closes #34493

What I did

Component libraries often expose react as a peer dependency, and React Native libraries commonly do the same for react-native. Before this change, those projects
could fail framework detection entirely, or be incorrectly classified as plain React.

  • Fix framework detection for React component libraries that declare react as a peerDependency
  • Also fix the same issue for React Native libraries (react-native / react-native-scripts as peerDeps)

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

Caution

This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!

CleanShot 2026-04-10 at 10 31 53@2x

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

  • Bug Fixes

    • Enhanced project type detection to recognize React and React Native dependencies declared in peer dependencies, in addition to regular dependencies. This ensures more accurate project type identification across different package configuration setups.
  • Tests

    • Expanded test coverage for project type detection, validating React and React Native identification across various dependency configurations and precedence scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 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: a1254876-6bbf-4c70-9673-89850b27159f

📥 Commits

Reviewing files that changed from the base of the PR and between aae6c95 and 55611ea.

📒 Files selected for processing (2)
  • code/lib/create-storybook/src/services/ProjectTypeService.test.ts
  • code/lib/create-storybook/src/services/ProjectTypeService.ts

📝 Walkthrough

Walkthrough

Extended the ProjectTypeService to detect React and React Native project types across both dependencies and peerDependencies sections of package.json. Updated the template matching logic and added comprehensive test cases validating the new detection behavior.

Changes

Cohort / File(s) Summary
ProjectTypeService updates
code/lib/create-storybook/src/services/ProjectTypeService.ts, code/lib/create-storybook/src/services/ProjectTypeService.test.ts
Modified template matching for React and React Native detection to check both dependencies and peerDependencies arrays. Added 69 lines of test cases covering React Native precedence, peerDependencies detection, and failure scenarios when insufficient markers exist.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] yarn create storybook fails to detect react framework

1 participant