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

Core: Enable RSC support when parameters.react is set to true #28865

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

kasperpeulen
Copy link
Contributor

@kasperpeulen kasperpeulen commented Aug 12, 2024

What I did

Enable RSC support when parameters.react is set to true

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/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 76.3 MB 76.3 MB 0 B -0.33 0%
initSize 167 MB 167 MB 361 B -0.85 0%
diffSize 91.2 MB 91.2 MB 361 B -0.85 0%
buildSize 7.43 MB 7.46 MB 24 kB -0.42 0.3%
buildSbAddonsSize 1.61 MB 1.61 MB 0 B -0.7 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 2.3 MB 2.3 MB 0 B -0.63 0%
buildSbPreviewSize 350 kB 350 kB 0 B 0.41 0%
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.46 MB 4.46 MB 0 B -0.68 0%
buildPreviewSize 2.97 MB 3 MB 24 kB -0.37 0.8%
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 16.1s 8.9s -7s -233ms -0.99 -81.1%
generateTime 19.3s 23.5s 4.1s 0.37 17.6%
initTime 16.6s 18.7s 2.1s -0.67 11.4%
buildTime 12s 13.1s 1.1s -0.03 8.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 8.1s 7.5s -629ms -1.22 -8.3%
devManagerResponsive 4.9s 4.6s -238ms -1.48 🔰-5.1%
devManagerHeaderVisible 810ms 731ms -79ms -1.1 -10.8%
devManagerIndexVisible 840ms 772ms -68ms -1.02 -8.8%
devStoryVisibleUncached 1.1s 1.2s 50ms -0.7 4.1%
devStoryVisible 853ms 788ms -65ms -1.08 -8.2%
devAutodocsVisible 742ms 774ms 32ms -0.29 4.1%
devMDXVisible 701ms 692ms -9ms -0.78 -1.3%
buildManagerHeaderVisible 849ms 807ms -42ms -0.23 -5.2%
buildManagerIndexVisible 850ms 809ms -41ms -0.31 -5.1%
buildStoryVisible 890ms 849ms -41ms -0.28 -4.8%
buildAutodocsVisible 696ms 684ms -12ms -0.64 -1.8%
buildMDXVisible 711ms 701ms -10ms -0.53 -1.4%

Greptile Summary

The pull request focuses on enabling React Server Components (RSC) support when parameters.react is set to true. Key changes include updates to type definitions, decorators, and ensuring compatibility with React versions 18.3 and above.

  • code/core/src/preview-api/modules/store/csf/composeConfigs.ts: Updated to use NormalizedProjectAnnotations for RSC support.
  • code/renderers/react/src/entry-preview-rsc.tsx: Simplified to set parameters.react.rsc to true, removing previous decorator logic.
  • code/renderers/react/src/entry-preview.tsx: Added decorator to check React version and wrap story in React.Suspense if RSC is enabled.
  • code/renderers/react/src/portable-stories.tsx: Updated setProjectAnnotations to return NormalizedProjectAnnotations<ReactRenderer>.
  • code/frameworks/nextjs/src/portable-stories.ts: Updated setProjectAnnotations to return NormalizedProjectAnnotations, aligning with other frameworks.

@kasperpeulen kasperpeulen changed the base branch from vitest-integration to beforeall August 12, 2024 08:44
Copy link

nx-cloud bot commented Aug 12, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit f747943. 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.

@kasperpeulen kasperpeulen changed the base branch from beforeall to vitest-integration August 12, 2024 08:46
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.

11 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential runtime error if React version is less than 18.3.


export const decorators: Decorator[] = [
(Story, context) => {
if (!context.parameters?.react?.rsc) return <Story />;
Copy link
Member

Choose a reason for hiding this comment

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

Can you change it to experimentalRsc? and update any documentation related to this, also potentially deprecate the main.js flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we still want to call it experimental? @shilman

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with @shilman, we are not gonna remove the experimentalRsc flag, as in the future, we need to use it to for example register a webpack plugin that resolves the react-server condition for imports in server component files.

@yannbf yannbf self-assigned this Aug 12, 2024
@yannbf yannbf added the react label Aug 12, 2024
@kasperpeulen kasperpeulen merged commit be894e9 into vitest-integration Aug 12, 2024
47 of 50 checks passed
@kasperpeulen kasperpeulen deleted the kasper/refactor-rsc-support branch August 12, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants