Migrate to storybook 10 for compatibility with Backstage#260
Open
brooke-hamilton wants to merge 3 commits into
Open
Migrate to storybook 10 for compatibility with Backstage#260brooke-hamilton wants to merge 3 commits into
brooke-hamilton wants to merge 3 commits into
Conversation
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found. |
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates @radapp.io/rad-components Storybook tooling to Storybook 10 (Vite-based) to match Backstage’s current direction and fix ESM loading issues introduced by "type": "module" + Storybook’s ESM config loading.
Changes:
- Upgraded Storybook dependencies to
^10.3.6, switched from webpack5 to@storybook/react-vite, and added explicitvite+@babel/preset-typescriptdev dependencies. - Updated
.storybook/main.tsand.storybook/preview.tsto Storybook 10’sdefineMain/definePreviewAPIs and ESM-safecreateRequire. - Updated MDX docs imports from
@storybook/blocksto@storybook/addon-docs/blocksand regeneratedyarn.lock.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rad-components/package.json | Aligns Storybook/dev tooling deps with Storybook 10 + Vite and adds missing Babel TS preset dependency. |
| packages/rad-components/.storybook/main.ts | Migrates Storybook main config to @storybook/react-vite and fixes require.resolve usage under ESM. |
| packages/rad-components/.storybook/preview.ts | Migrates preview config to definePreview and removes deprecated auto-actions config. |
| packages/rad-components/src/components/appgraph/docs/AppGraph.mdx | Updates blocks import path for Storybook 10 docs. |
| packages/rad-components/src/components/resourcenode/docs/ResourceNode.mdx | Updates blocks import path for Storybook 10 docs. |
| yarn.lock | Captures the updated dependency graph for the Storybook 10 migration. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Dependabot PR #257 ("Bump the all group with 17 updates") attempted to upgrade Storybook from
7.6.24to a mix of8.6.xand10.3.6. CI's Build Packages job failed at thebuild-storybookstep with:Why dependabot couldn't fix this on its own
Storybook 9 and 10 introduced two breaking changes that intersect badly with our setup:
@storybook/addon-essentials,@storybook/addon-interactions,@storybook/blocks, and@storybook/testhave no 9.x or 10.x release — their last published version is8.6.x. Their functionality was either folded into@storybook/addon-docs/built-ins, or replaced by@storybook/addon-vitest. That's why dependabot left those packages stuck at8.6.14while bumping the rest to10.3.6, producing an internally inconsistent dependency graph..storybook/main.tsis now loaded as ESM. Combined with"type": "module"inpackages/rad-components/package.json, the existingrequire.resolve(...)calls throwReferenceError: require is not defined in ES module scope. Storybook's own auto-migration message points to this and explicitly instructs users to switch tocreateRequire(import.meta.url).A simple revert to
7.6.24would unblock CI but moves us away from where Backstage is going. Each subsequent dependabot run would re-propose the same broken bump.What Backstage does
Upstream
backstage/backstage(v1.51.0-next.2) has fully migrated to Storybook 10:storybook ^10.3.3with@storybook/react-vite(no longerreact-webpack5).addon-docs,addon-themes,addon-a11y,addon-links(andaddon-vitestfor test integration)..storybook/main.tsusesdefineMainfrom@storybook/react-vite/nodeandcreateRequire(import.meta.url)to keeprequire.resolveworking in ESM scope..storybook/preview.ts(x)usesdefinePreviewfrom@storybook/react-vite.This PR aligns
packages/rad-componentswith that pattern.Changes
packages/rad-components/package.json@storybook/addon-essentials,@storybook/addon-interactions,@storybook/addon-onboarding,@storybook/blocks,@storybook/test,@storybook/react-webpack5.^10.3.6:@storybook/addon-links,@storybook/addon-docs,@storybook/addon-themes,@storybook/addon-a11y,@storybook/react,@storybook/react-vite,storybook.vite ^7.1.5(required by@storybook/react-vite).@babel/preset-typescript ^7.27.1(was satisfied transitively by Storybook 7's dependency tree; now must be declared explicitly becausebabel.config.jsonreferences it).packages/rad-components/.storybook/main.tsStorybookConfigtyping todefineMainfrom@storybook/react-vite/node.require.resolvewithcreateRequire(import.meta.url)so it works under ESM.@storybook/react-webpack5(withuseSWC) to@storybook/react-vite.docs.autodocsoption.packages/rad-components/.storybook/preview.tsdefinePreviewfrom@storybook/react-vite.parameters.actions.argTypesRegex(auto-actions was removed in Storybook 10).AppGraph.mdx,ResourceNode.mdx—import { Canvas, Meta } from '@storybook/blocks'→from '@storybook/addon-docs/blocks'(the v10 location).yarn.lock— regenerated.Scope
These changes are limited to the
rad-componentsStorybook tooling. Norad-componentssource files are modified, so no runtime behavior in the dashboard application changes. The exports consumed byplugin-radius(parseResourceId,AppGraph,ResourceNode, related types) are unchanged.Validation
yarn install— clean.yarn workspace @radapp.io/rad-components run build-storybook— Storybook 10.3.6 + Vite 7.x build succeeds.backstage-cli package testinrad-components— both test suites pass.yarn tsc— clean.AppGraphandResourceNodestories and their.mdxdocs pages.References
.storybook/main.ts: https://github.com/backstage/backstage/blob/master/.storybook/main.tspackage.json(Storybook deps): https://github.com/backstage/backstage/blob/master/package.json