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: Re-Export renderers from frameworks #30771

Merged
merged 29 commits into from
Mar 10, 2025

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Mar 7, 2025

What I did

Users of storybook have been needing to use both the framework package and renderer package, for different purposes.
In their config files they'd use the framework package, in their client code they'd use the renderer package.

This has created confusion this PR tries to remove.

From now on, users should import all their types from the frameworks.

The renderer packages still exist, and export the same, but users can use a single package (the framework package) for all their needs.

Part of this work has meant duplicating a lot of files for the init command to be able to generate the appropriate files.

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 79.9 MB 79.9 MB 0 B -1 0%
initSize 79.9 MB 79.9 MB 0 B -1 0%
diffSize 97 B 97 B 0 B - 0%
buildSize 7.47 MB 7.47 MB 0 B -1 0%
buildSbAddonsSize 1.98 MB 1.98 MB 0 B -1 0%
buildSbCommonSize 195 kB 195 kB 0 B - 0%
buildSbManagerSize 1.88 MB 1.88 MB 0 B - 0%
buildSbPreviewSize 0 B 0 B 0 B - -
buildStaticSize 0 B 0 B 0 B - -
buildPrebuildSize 4.06 MB 4.06 MB 0 B -1 0%
buildPreviewSize 3.42 MB 3.42 MB 0 B -1 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 7.6s 21.7s 14s 98.13 🔺64.8%
generateTime 20s 19.4s -612ms 0.23 -3.1%
initTime 4.6s 4.4s -176ms 0.2 -3.9%
buildTime 9.7s 12.2s 2.5s 7.17 🔺20.7%
testBuildTime 0ms 0ms 0ms - -
devPreviewResponsive 4.8s 5.4s 620ms 0.45 11.3%
devManagerResponsive 4.6s 5.2s 607ms 0.58 11.5%
devManagerHeaderVisible 702ms 742ms 40ms -0.5 5.4%
devManagerIndexVisible 757ms 810ms 53ms -0.4 6.5%
devStoryVisibleUncached 2.4s 2.6s 247ms 1.66 🔺9.2%
devStoryVisible 1.1s 1.1s -5ms -1.06 -0.4%
devAutodocsVisible 1s 1.2s 144ms 0.4 11.8%
devMDXVisible 1.1s 1.1s 67ms 0.3 5.7%
buildManagerHeaderVisible 646ms 691ms 45ms -0.64 6.5%
buildManagerIndexVisible 648ms 696ms 48ms -0.63 6.9%
buildStoryVisible 638ms 666ms 28ms -0.78 4.2%
buildAutodocsVisible 725ms 562ms -163ms -2.34 🔰-29%
buildMDXVisible 566ms 660ms 94ms -0.16 14.2%

Add additional export for Storybook React package to improve module compatibility and provide more direct access to core React-related exports

Greptile Summary

This PR updates import paths across multiple story files to use '@storybook/react-vite' instead of '@storybook/react', aiming to simplify dependency management by having users import from framework packages rather than renderers.

  • Added wildcard export in code/frameworks/react-vite/src/index.ts to re-export all contents from '@storybook/react'
  • Modified import statements in 90+ story files to use '@storybook/react-vite' for Meta and StoryObj types
  • Removed direct '@storybook/react' dependency from code/addons/onboarding/package.json
  • PR is in transitional state and needs further discussion on migration strategy
  • Potential compatibility concerns for projects not using Vite as their build tool

Add additional export for Storybook React package to improve module compatibility and provide more direct access to core React-related exports
Migrate story files to use '@storybook/react-vite' instead of '@storybook/react' for type imports. Also remove direct '@storybook/react' dependency from package.json.
Migrate Storybook configuration files to use '@storybook/react-vite' type imports in preview.tsx and bench.stories.tsx
Migrate multiple story files across addons to use '@storybook/react-vite' for type imports, replacing '@storybook/react' type imports
Migrate all story files in the blocks package to use '@storybook/react-vite' for type imports, replacing '@storybook/react' type imports across multiple components and examples
Migrate story files in the manager package to use '@storybook/react-vite' for type imports, replacing '@storybook/react' type imports across multiple components and settings
Copy link

nx-cloud bot commented Mar 7, 2025

View your CI Pipeline Execution ↗ for commit ffbc5d8.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 56s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-10 09:32:47 UTC

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.

109 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

ndelangen added 19 commits March 7, 2025 13:58
Update `copyTemplateFiles` function and related tests to replace `renderer` parameter with `templateLocation`, improving clarity and flexibility of template file copying mechanism
…nextjs-vite' imports

Migrate story files in the experimental Next.js Vite template to use '@storybook/experimental-nextjs-vite' for type imports, replacing '@storybook/react' type imports across multiple stories
Migrate story files in the Next.js template to use '@storybook/nextjs' for type imports, replacing '@storybook/react' type imports across multiple stories and template variations
…t-native-web-vite' imports

Migrate story files in the React Native Web Vite template to use '@storybook/react-native-web-vite' for type imports, replacing '@storybook/react' type imports across Button, Header, and Page stories
Add Button, Header, and Page components with stories for both JavaScript and TypeScript (4.9) variations in the React Vite CLI template. Include ESLint configuration and CSS files to support the components.
Export types and core functionality from '@storybook/html' in the HTML Vite template index file
Add export for '@storybook/html' in the HTML Webpack 5 template index file to provide core HTML framework support
Export core React functionality and suppress TypeScript error for double exports in the Next.js Storybook template
Export core Preact functionality from '@storybook/preact' in the Preact Vite template index file
Add export for '@storybook/preact' in the Preact Webpack 5 template index file to provide core Preact framework support
Add full export of '@storybook/react' in the React Native Web Vite template index file to provide comprehensive React framework support
…e functionality

Add exports for respective Storybook framework packages across multiple framework templates, including HTML, Preact, React, Server, Svelte, Vue3, and Web Components for both Vite and Webpack5 configurations
…work template

- Add explicit type imports for Storybook and React types
- Enhance type casting for decorators and loaders
- Improve type handling for Next.js preview configuration
Add Button, Header, and Page components with stories for multiple Svelte variations:
- JavaScript
- Svelte 5 JavaScript
- Svelte 5 TypeScript (3.8 and 4.9)
- TypeScript (4.9)

Include stories, components, and CSS files to support the Storybook template components across different Svelte configurations
…ariations

Expand the Svelte Storybook template with comprehensive component support:
- Add Button, Header, and Page components
- Support multiple Svelte configurations:
  * JavaScript
  * Svelte 5 JavaScript
  * Svelte 5 TypeScript (3.8 and 4.9)
  * TypeScript (4.9)
- Include stories, components, and CSS files
- Implement Storybook best practices with autodocs and component testing
…iations

Expand the Vue3 Storybook template with comprehensive component support:
- Add Button, Header, and Page components
- Support multiple Vue3 configurations:
  * JavaScript
  * TypeScript (4.9)
- Include stories, components, and CSS files
- Implement Storybook best practices with autodocs and component testing
…peScript

Expand the Vue3 Webpack5 Storybook template with comprehensive component support:
- Add Button, Header, and Page components for JavaScript and TypeScript (4.9)
- Include stories, components, and CSS files
- Implement Storybook best practices with autodocs and component testing
Expand the Web Components Storybook template with comprehensive component support:
- Add Button, Header, and Page components for JavaScript and TypeScript (4.9)
- Support multiple configurations for Vite and Webpack5
- Include stories, components, and CSS files
- Add ESLint configuration to disable import/extensions rule
- Implement Storybook best practices with autodocs and component testing
@ndelangen ndelangen self-assigned this Mar 7, 2025
@ndelangen ndelangen added maintenance User-facing maintenance tasks cli labels Mar 7, 2025
…files

Include template directories in the files array for multiple framework packages to ensure template files are packaged and distributed correctly
@storybook-pr-benchmarking
Copy link

storybook-pr-benchmarking bot commented Mar 7, 2025

Package Benchmarks

Commit: ffbc5d8, ran on 10 March 2025 at 09:35:58 UTC

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

@storybook/experimental-nextjs-vite

Before After Difference
Dependency count 141 141 0
Self size 215 KB 215 KB 🚨 +667 B 🚨
Dependency size 39.37 MB 39.38 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-native-web-vite

Before After Difference
Dependency count 172 172 0
Self size 35 KB 35 KB 🚨 +344 B 🚨
Dependency size 24.30 MB 24.32 MB 🚨 +17 KB 🚨
Bundle Size Analyzer Link Link

@storybook/react-vite

Before After Difference
Dependency count 122 122 0
Self size 15 KB 31 KB 🚨 +17 KB 🚨
Dependency size 20.47 MB 20.47 MB 0 B
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 131 131 0
Self size 23 KB 61 KB 🚨 +38 KB 🚨
Dependency size 36.55 MB 36.55 MB 0 B
Bundle Size Analyzer Link Link

@storybook/svelte-webpack5

Before After Difference
Dependency count 311 311 0
Self size 7 KB 9 KB 🚨 +2 KB 🚨
Dependency size 40.61 MB 40.61 MB 0 B
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 139 139 0
Self size 48 KB 100 KB 🚨 +52 KB 🚨
Dependency size 39.86 MB 39.90 MB 🚨 +38 KB 🚨
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 104 104 0
Self size 17 KB 34 KB 🚨 +17 KB 🚨
Dependency size 42.74 MB 42.74 MB 0 B
Bundle Size Analyzer Link Link

@storybook/vue3-webpack5

Before After Difference
Dependency count 495 495 0
Self size 7 KB 24 KB 🚨 +17 KB 🚨
Dependency size 57.01 MB 57.01 MB 0 B
Bundle Size Analyzer Link Link

@storybook/web-components-vite

Before After Difference
Dependency count 12 12 0
Self size 6 KB 20 KB 🚨 +14 KB 🚨
Dependency size 1.94 MB 1.94 MB 0 B
Bundle Size Analyzer Link Link

@storybook/web-components-webpack5

Before After Difference
Dependency count 245 245 0
Self size 7 KB 20 KB 🚨 +14 KB 🚨
Dependency size 32.62 MB 32.62 MB 0 B
Bundle Size Analyzer Link Link

@ndelangen ndelangen changed the title Export Storybook React package in index.ts Core: Re-Export renderers from frameworks Mar 7, 2025
Base automatically changed from norbert/fix-missingStorybookDependencies to next March 10, 2025 09:27
@ndelangen ndelangen merged commit 0d738c9 into next Mar 10, 2025
51 of 55 checks passed
@ndelangen ndelangen deleted the norbert/re-export-renderers-from-frameworks branch March 10, 2025 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal cli maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants