Docgen: Register service runtime, payload argTypes, and bundler guardrails#35108
Docgen: Register service runtime, payload argTypes, and bundler guardrails#35108JReinhold wants to merge 8 commits into
Conversation
…rails Wire preview/manager registration behind experimentalDocgenServer, add renderer- converted argTypes to the docgen payload, and skip preview __docgenInfo injection when the flag is enabled. Does not enable the flag by default. Co-authored-by: Cursor <cursoragent@cursor.com>
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 184 | 184 | 0 |
| Self size | 79 KB | 79 KB | 🎉 -48 B 🎉 |
| Dependency size | 33.98 MB | 34.02 MB | 🚨 +45 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 72 | 72 | 0 |
| Self size | 20.74 MB | 20.86 MB | 🚨 +121 KB 🚨 |
| Dependency size | 36.12 MB | 36.12 MB | 0 B |
| Bundle Size Analyzer | Link | Link |
@storybook/angular
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 185 | 185 | 0 |
| Self size | 160 KB | 160 KB | 🚨 +54 B 🚨 |
| Dependency size | 31.32 MB | 31.35 MB | 🚨 +32 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/ember
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 189 | 189 | 0 |
| Self size | 15 KB | 15 KB | 🎉 -18 B 🎉 |
| Dependency size | 30.80 MB | 30.84 MB | 🚨 +45 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/nextjs
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 534 | 534 | 0 |
| Self size | 662 KB | 662 KB | 0 B |
| Dependency size | 62.16 MB | 62.21 MB | 🚨 +46 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/react-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 271 | 271 | 0 |
| Self size | 23 KB | 23 KB | 0 B |
| Dependency size | 46.70 MB | 46.74 MB | 🚨 +46 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/server-webpack5
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 196 | 196 | 0 |
| Self size | 16 KB | 16 KB | 0 B |
| Dependency size | 35.24 MB | 35.29 MB | 🚨 +45 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 203 | 203 | 0 |
| Self size | 948 KB | 948 KB | 0 B |
| Dependency size | 88.99 MB | 89.11 MB | 🚨 +123 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 196 | 196 | 0 |
| Self size | 32 KB | 32 KB | 0 B |
| Dependency size | 87.48 MB | 87.60 MB | 🚨 +123 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 73 | 73 | 0 |
| Self size | 1.08 MB | 1.08 MB | 🚨 +132 B 🚨 |
| Dependency size | 56.85 MB | 56.97 MB | 🚨 +121 KB 🚨 |
| Bundle Size Analyzer | node | node |
@storybook/preset-react-webpack
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 164 | 164 | 0 |
| Self size | 18 KB | 18 KB | 🎉 -24 B 🎉 |
| Dependency size | 32.48 MB | 32.53 MB | 🚨 +44 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR extends the experimental docgen open-service to support optional ChangesDocgen service with argTypes support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
code/core/src/core-server/presets/common-manager.ts (1)
14-14: 💤 Low valueConsider documenting the placement rationale.
docgenManageris placed first in the registration array, which the comments indicate affects panel and tool order. While the manager addon currently only registers a service (no UI panels in this PR per the summary), this placement could affect ordering when the UI is added. Since this is experimental and feature-flagged, the impact is limited, but documenting why it's first would help future maintainers.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@code/core/src/core-server/presets/common-manager.ts` at line 14, Add a short comment explaining why docgenManager is intentionally placed first in the registration array: note that registration order influences panel and tool ordering, that docgenManager currently only registers a service (no UI in this PR), and that it’s experimental/feature-flagged so placement is deliberate to reserve first position for future UI additions; place this comment immediately above the array containing docgenManager to make the rationale clear to future maintainers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@code/core/src/core-server/presets/common-manager.ts`:
- Line 14: Add a short comment explaining why docgenManager is intentionally
placed first in the registration array: note that registration order influences
panel and tool ordering, that docgenManager currently only registers a service
(no UI in this PR), and that it’s experimental/feature-flagged so placement is
deliberate to reserve first position for future UI additions; place this comment
immediately above the array containing docgenManager to make the rationale clear
to future maintainers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7eb2aa46-6278-4b64-a1d0-29302858a4f7
📒 Files selected for processing (13)
code/core/scripts/generate-source-files.tscode/core/src/core-server/presets/common-manager.tscode/core/src/csf/core-annotations.tscode/core/src/shared/open-service/index.tscode/core/src/shared/open-service/services/docgen/definition.tscode/core/src/shared/open-service/services/docgen/manager.tsxcode/core/src/shared/open-service/services/docgen/preview.tscode/core/src/shared/open-service/services/docgen/types.tscode/frameworks/react-vite/src/preset.tscode/presets/react-webpack/src/framework-preset-react-docs.tscode/renderers/react/src/docgen/buildDocgen.test.tscode/renderers/react/src/docgen/buildDocgen.tsscripts/build/utils/generate-bundle.ts
The instance-type alias was declared twice (before and after docgenServiceDef), causing TS2300 duplicate identifier in the production dts build. Keep the declaration after the service def, matching ModuleGraphService. Co-authored-by: Cursor <cursoragent@cursor.com>
TypeScript models `boolean` as `true | false`, so an optional boolean prop (`true | false | undefined`) fell through serializeType to `typeToString` as `boolean | undefined`, which downstream argType mapping treated as `other`. Collapse the boolean-literal pair back to `boolean`, and update the RCM extraction snapshots that captured the old output. Co-authored-by: Cursor <cursoragent@cursor.com>
Disabling react-docgen __docgenInfo injection when experimentalDocgenServer is on belongs with the docs-block service consumption (it's the other half of the same swap). Without the consumer, dropping injection regresses argTypes and descriptions in any Storybook with the flag enabled (including our internal one). Move both preset early-returns to the UI consumption PR. Co-authored-by: Cursor <cursoragent@cursor.com>
Closes #
What I did
Wires the
core/docgenopen service for preview and manager registration (behindfeatures.experimentalDocgenServer), adds renderer-convertedargTypesto the docgen payload at write time, and skips preview__docgenInfoinjection in React Vite/Webpack when the flag is on.Does not enable
experimentalDocgenServerin any config. Does not include docs/manager UI consumption (follow-up PR #35109).Recommended merge order: after #35106 (open-service load routing). #35107 (RCM subcomponents) improves subcomponent argTypes in the payload but is not required to compile.
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!
No manual QA without enabling
experimentalDocgenServer. Unit tests coverbuildDocgenPayloadargTypes conversion.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.tsDeclare whether manual QA will be needed for this PR during the next release, through
qa:neededorqa:skipMake 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/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Made with Cursor
Summary by CodeRabbit
New Features
Refactor
Tests