-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
CSF Factories: Add parameters/globals types, extend API, portable stories
#30601
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
Conversation
# Conflicts: # code/core/src/csf/csf-factories.ts
|
View your CI Pipeline Execution ↗ for commit d70f67e.
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
37 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile
3f0aa55 to
526ce10
Compare
# Conflicts: # code/addons/a11y/src/index.ts # code/addons/a11y/src/types.ts # code/addons/actions/src/index.ts # code/addons/backgrounds/src/index.ts # code/addons/controls/src/index.ts # code/addons/docs/src/index.ts # code/addons/essentials/src/index.ts # code/addons/essentials/src/types.ts # code/addons/highlight/src/index.ts # code/addons/highlight/src/types.ts # code/addons/interactions/src/types.ts # code/addons/links/src/index.ts # code/addons/measure/src/index.ts # code/addons/outline/src/index.ts # code/addons/pseudo-states/src/index.ts # code/addons/test/src/index.ts # code/addons/test/src/types.ts # code/addons/themes/src/index.ts # code/addons/viewport/src/index.ts # code/core/src/backgrounds/types.ts # code/core/src/csf/csf-factories.ts # code/core/src/viewport/types.ts # code/frameworks/nextjs-vite/src/index.ts # code/frameworks/nextjs/src/index.ts # code/renderers/react/src/csf-factories.test.tsx # code/renderers/react/src/preview.tsx
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 31.40 MB | 31.22 MB | 🎉 -185 KB 🎉 |
| Dependency size | 17.41 MB | 17.41 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
sb
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1 KB | 1 KB | 0 B |
| Dependency size | 48.81 MB | 48.63 MB | 🎉 -185 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 324 | 324 | 0 |
| Self size | 244 KB | 244 KB | 🎉 -137 B 🎉 |
| Dependency size | 97.90 MB | 98.82 MB | 🚨 +920 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 267 | 267 | 0 |
| Self size | 31 KB | 31 KB | 0 B |
| Dependency size | 82.29 MB | 82.11 MB | 🎉 -185 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 1 | 1 | 0 |
| Self size | 11.02 MB | 12.13 MB | 🚨 +1.11 MB 🚨 |
| Dependency size | 98 KB | 98 KB | 0 B |
| Bundle Size Analyzer | Link | Link |
# Conflicts: # code/addons/vitest/src/types.ts
| } | ||
|
|
||
| export type InferTypes<T extends PreviewAddon<never>[]> = T extends PreviewAddon<infer C>[] | ||
| ? C & { csf4: true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
csf: number
| }, | ||
| }); | ||
|
|
||
| await Basic.play(meta.input as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this
extend, automatic portable stories
extend, automatic portable storiesextend API, portable stories
extend API, portable storiesextend API, portable stories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for a few minor comments e.g. csf: versionNumber instead of csf4: true. Let's get @kylegach to look at the docs changes, but those look good to me too! Great job @kasperpeulen !!!!
extend API, portable storiesextend API, portable stories
|
Thanks for all the work on this @kasperpeulen! I'm trying the canary, and it's let me remove at least one I have a preview with: definePreview({
parameters: {
docs: {
canvas: {
sourceState: 'shown',
}
}
}
});and it's complaining that: I'm also getting a couple of errors from within It seems like tsup is eating the |
# Conflicts: # docs/api/csf/csf-factories.mdx
|
@mrginglymus Fixed the docs types, thanks! I'm gonna look how to configure tsup to keep the comments, but for now I would recommend turning on |
|
Thanks!
Unfortunately I have my own locally crafted If you do succeed, it'd be a great help on #31555, where that's the last remaining hurdle; preserving the ts-expect-errors. |
|
@mrginglymus This is an interesting read from Matt Pocock:
|
|
It's an interesting approach, but after a quick play looks like it'll have too many unwanted side effects that would need dealing with (e.g. removing the stub files from the compiled code), as well as obfuscating their intent. On the whole I don't mind the burden of dealing with downstream type errors; they're usually trivial but ocassionaly point at an underlying problem that's worth fixing. |
|
Failed to publish canary version of this pull request, triggered by @kasperpeulen. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/16138593936 |
|
Failed to publish canary version of this pull request, triggered by @kasperpeulen. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/16195630556 |
What I did
This adds a couple of points from this RFC:
#30112
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake 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 pull request has been released as version
0.0.0-pr-30601-sha-d70f67e1. Try it out in a new sandbox by runningnpx [email protected] sandboxor in an existing project withnpx [email protected] upgrade.More information
0.0.0-pr-30601-sha-d70f67e1kasper/csf-parametersd70f67e11751963285)To request a new release of this pull request, mention the
@storybookjs/coreteam.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=30601Greptile Summary
Enhanced type safety across Storybook addons by introducing consistent parameter typing and addon definition patterns.
definePreviewwithdefinePreviewAddonfromstorybook/internal/csffor better type inference*Typesinterfaces (e.g.A11yTypes,ActionsTypes) to wrap parameters and globals for each addon?modifier for better flexibilityPreviewAddoninterface andInferTypesutility incsf-factories.tsfor improved addon type safety