Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portable stories: Support multiple annotation notations from preview #29733

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Nov 28, 2024

Closes #29732

What I did

This PR makes it so that portable stories use the same mechanism as Storybook when loading annotations. This allows for supporting both notations at the same time coming from the preview file.

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

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

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

name before after diff z %
createSize 0 B 0 B 0 B - -
generateSize 77.7 MB 77.7 MB 0 B -0.82 0%
initSize 143 MB 143 MB -69 B -0.81 0%
diffSize 65.2 MB 65.2 MB -69 B 0.86 0%
buildSize 6.83 MB 6.83 MB -59 B 1.3 0%
buildSbAddonsSize 1.51 MB 1.51 MB -36 B 0.77 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.86 MB 1.86 MB 0 B 1.3 0%
buildSbPreviewSize 271 kB 271 kB -23 B 0.66 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 3.84 MB 3.84 MB -59 B 1.16 0%
buildPreviewSize 3 MB 3 MB 0 B 2.99 0%
testBuildSize 0 B 0 B 0 B - -
testBuildSbAddonsSize 0 B 0 B 0 B - -
testBuildSbCommonSize 0 B 0 B 0 B - -
testBuildSbManagerSize 0 B 0 B 0 B - -
testBuildSbPreviewSize 0 B 0 B 0 B - -
testBuildStaticSize 0 B 0 B 0 B - -
testBuildPrebuildSize 0 B 0 B 0 B - -
testBuildPreviewSize 0 B 0 B 0 B - -
name before after diff z %
createTime 18.3s 7s -11s -353ms -1.21 -161.2%
generateTime 24s 19.4s -4s -654ms -0.39 -24%
initTime 15.1s 14.7s -351ms -0.1 -2.4%
buildTime 11.2s 8s -3s -245ms -0.94 -40.4%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 6.1s 5.8s -288ms -0.12 -4.9%
devManagerResponsive 3.6s 3.4s -205ms -0.35 -5.9%
devManagerHeaderVisible 634ms 620ms -14ms 0 -2.3%
devManagerIndexVisible 657ms 654ms -3ms -0.13 -0.5%
devStoryVisibleUncached 1s 983ms -17ms -0.16 -1.7%
devStoryVisible 655ms 652ms -3ms -0.09 -0.5%
devAutodocsVisible 510ms 580ms 70ms 0.23 12.1%
devMDXVisible 591ms 553ms -38ms -0.1 -6.9%
buildManagerHeaderVisible 511ms 549ms 38ms -0.31 6.9%
buildManagerIndexVisible 523ms 569ms 46ms -0.3 8.1%
buildStoryVisible 513ms 548ms 35ms -0.31 6.4%
buildAutodocsVisible 450ms 456ms 6ms -0.31 1.3%
buildMDXVisible 446ms 412ms -34ms -0.57 -8.3%

Greptile Summary

Enhanced portable stories to support simultaneous handling of both named and default export annotations from preview files, matching Storybook's core behavior.

  • Modified code/core/src/preview-api/modules/store/csf/portable-stories.ts to use composeConfigs for combining all module annotations
  • Added test cases in portable-stories.test.ts to verify proper merging of named exports (e.g. initialGlobals) and default exports (e.g. parameters)
  • Fixed issue [Bug]: Portable stories don't respect both annotations notations at the same time #29732 where annotations were being ignored when using both export types
  • Maintains backward compatibility while supporting the dual annotation pattern

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Nov 28, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 924d095. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@yannbf yannbf added the patch:yes Bugfix & documentation PR that need to be picked to main branch label Nov 28, 2024
@shilman shilman merged commit 020074b into next Nov 29, 2024
62 of 68 checks passed
@shilman shilman deleted the yann/improve-ps-annotations branch November 29, 2024 01:25
yannbf pushed a commit that referenced this pull request Nov 29, 2024
Portable stories: Support multiple annotation notations from preview

(cherry picked from commit 020074b)
@github-actions github-actions bot added the patch:done Patch/release PRs already cherry-picked to main/release branch label Nov 29, 2024
@yannbf yannbf self-assigned this Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ci:normal patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch portable stories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Portable stories don't respect both annotations notations at the same time
2 participants