-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Docgen: Update extraction of React docgen #33598
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
|
View your CI Pipeline Execution ↗ for commit 2336b2e
☁️ Nx Cloud last updated this comment at |
📝 WalkthroughWalkthroughextractReactDocgenInfo now reads Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing touches
Comment |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 192 | 192 | 0 |
| Self size | 75 KB | 75 KB | 🎉 -6 B 🎉 |
| Dependency size | 32.24 MB | 32.25 MB | 🚨 +11 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 49 | 49 | 0 |
| Self size | 20.30 MB | 20.32 MB | 🚨 +21 KB 🚨 |
| Dependency size | 16.52 MB | 16.52 MB | 🎉 -4 B 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 196 | 196 | 0 |
| Self size | 15 KB | 15 KB | 🚨 +12 B 🚨 |
| Dependency size | 28.96 MB | 28.97 MB | 🚨 +11 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 538 | 538 | 0 |
| Self size | 646 KB | 646 KB | 🚨 +110 B 🚨 |
| Dependency size | 59.22 MB | 59.73 MB | 🚨 +505 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 127 | 127 | 0 |
| Self size | 1.12 MB | 1.12 MB | 🚨 +14 B 🚨 |
| Dependency size | 21.82 MB | 22.32 MB | 🚨 +496 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-native-web-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 159 | 159 | 0 |
| Self size | 30 KB | 30 KB | 🚨 +8 B 🚨 |
| Dependency size | 23.00 MB | 23.61 MB | 🚨 +610 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 117 | 117 | 0 |
| Self size | 35 KB | 35 KB | 🎉 -8 B 🎉 |
| Dependency size | 19.62 MB | 20.11 MB | 🚨 +496 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 278 | 278 | 0 |
| Self size | 24 KB | 24 KB | 🎉 -10 B 🎉 |
| Dependency size | 44.13 MB | 44.64 MB | 🚨 +505 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 204 | 204 | 0 |
| Self size | 16 KB | 16 KB | 🎉 -10 B 🎉 |
| Dependency size | 33.49 MB | 33.50 MB | 🚨 +11 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 183 | 183 | 0 |
| Self size | 775 KB | 775 KB | 🚨 +219 B 🚨 |
| Dependency size | 67.38 MB | 67.47 MB | 🚨 +92 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 176 | 176 | 0 |
| Self size | 30 KB | 30 KB | 🎉 -4 B 🎉 |
| Dependency size | 65.95 MB | 66.05 MB | 🚨 +92 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 50 | 50 | 0 |
| Self size | 1000 KB | 1000 KB | 🎉 -6 B 🎉 |
| Dependency size | 36.82 MB | 36.84 MB | 🚨 +21 KB 🚨 |
| Bundle Size Analyzer | node | node |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 170 | 170 | 0 |
| Self size | 18 KB | 18 KB | 🚨 +18 B 🚨 |
| Dependency size | 31.26 MB | 31.28 MB | 🚨 +11 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 57 | 57 | 0 |
| Self size | 732 KB | 1.23 MB | 🚨 +494 KB 🚨 |
| Dependency size | 12.94 MB | 12.94 MB | 🚨 +2 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
…mmy value generation logic
|
Failed to publish canary version of this pull request, triggered by @yannbf. See the failed workflow run at: https://github.com/storybookjs/storybook/actions/runs/21175957704 |
…argument generation logic
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@code/core/src/core-server/utils/get-dummy-args-from-argtypes.ts`:
- Around line 229-236: In the 'array' branch handling SBType arrays, the guard
wrongly uses "v?.length < 1" which lets v undefined fallthrough and cause v[0]
access to throw; change the condition to check for missing/empty arrays first
(e.g. use "!v?.length" or an explicit "if (!v || v.length === 0)") so that when
sbType.value (v) is undefined or empty you return [] before checking v[0]?.name;
update the conditional in the case 'array' block surrounding
generateDummyValueFromSBType(v[0], propName, options) accordingly.
| case 'array': { | ||
| const v = sbType.value as unknown as SBType[]; | ||
|
|
||
| // If we don't know what the element is, be conservative and return empty. | ||
| if (sbType.value.name === 'other') { | ||
| if (v?.length < 1 || v[0]?.name === 'other') { | ||
| return []; | ||
| } | ||
| return [generateDummyValueFromSBType(sbType.value, propName, options)]; | ||
| return [generateDummyValueFromSBType(v[0], propName, options)]; |
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.
Guard condition fails when v is undefined.
The condition v?.length < 1 doesn't protect against undefined values. When v is undefined:
v?.lengthevaluates toundefinedundefined < 1isfalse(NaN comparison)- Code proceeds to
v[0]?.name, which throwsTypeError
Use !v?.length instead, which correctly handles both undefined/null and empty arrays.
Proposed fix
case 'array': {
const v = sbType.value as unknown as SBType[];
// If we don't know what the element is, be conservative and return empty.
- if (v?.length < 1 || v[0]?.name === 'other') {
+ if (!v?.length || v[0]?.name === 'other') {
return [];
}
return [generateDummyValueFromSBType(v[0], propName, options)];
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case 'array': { | |
| const v = sbType.value as unknown as SBType[]; | |
| // If we don't know what the element is, be conservative and return empty. | |
| if (sbType.value.name === 'other') { | |
| if (v?.length < 1 || v[0]?.name === 'other') { | |
| return []; | |
| } | |
| return [generateDummyValueFromSBType(sbType.value, propName, options)]; | |
| return [generateDummyValueFromSBType(v[0], propName, options)]; | |
| case 'array': { | |
| const v = sbType.value as unknown as SBType[]; | |
| // If we don't know what the element is, be conservative and return empty. | |
| if (!v?.length || v[0]?.name === 'other') { | |
| return []; | |
| } | |
| return [generateDummyValueFromSBType(v[0], propName, options)]; | |
| } |
🤖 Prompt for AI Agents
In `@code/core/src/core-server/utils/get-dummy-args-from-argtypes.ts` around lines
229 - 236, In the 'array' branch handling SBType arrays, the guard wrongly uses
"v?.length < 1" which lets v undefined fallthrough and cause v[0] access to
throw; change the condition to check for missing/empty arrays first (e.g. use
"!v?.length" or an explicit "if (!v || v.length === 0)") so that when
sbType.value (v) is undefined or empty you return [] before checking v[0]?.name;
update the conditional in the case 'array' block surrounding
generateDummyValueFromSBType(v[0], propName, options) accordingly.
…correct, but the types are wrong, changing the type (we tried) breaks more things
What I did
Noticed a bug in the gathering of
react-docgen-data, we passed the containing-object data, instead of the data.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Caution
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-33598-sha-c91e37ca. Try it out in a new sandbox by runningnpx storybook@0.0.0-pr-33598-sha-c91e37ca sandboxor in an existing project withnpx storybook@0.0.0-pr-33598-sha-c91e37ca upgrade.More information
0.0.0-pr-33598-sha-c91e37canorbert/fix-js-docgen-datac91e37ca1768921209)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 publish.yml --field pr=33598Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.