Skip to content

Commit 47e1a9c

Browse files
authored
fix(storybook): handle hyphenated framework names in pnpm dependency installation (#31760)
## Current Behavior When installing Storybook dependencies with pnpm, the regex for extracting base framework names from compound framework packages (e.g., @storybook/web-components-vite) was not properly handling hyphens in framework names. This caused it to extract incorrect base framework names like @storybook/web instead of @storybook/web-components, leading to attempts to install non-existent packages. ## Expected Behavior The regex should properly extract base framework names that include hyphens, correctly identifying @storybook/web-components as the base framework for packages like @storybook/web-components-vite. This ensures that only valid Storybook packages are installed during dependency resolution. ## Related Issue(s) Fixes #31292
1 parent e78f9e3 commit 47e1a9c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/storybook/src/generators/configuration/lib/ensure-dependencies.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,16 @@ export function ensureDependencies(
7171
if (isPnpm) {
7272
// If it's pnpm, it needs the framework without the builder
7373
// as a dependency too (eg. @storybook/react)
74-
const matchResult = options.uiFramework?.match(/^@storybook\/(\w+)/);
75-
const uiFrameworkWithoutBuilder = matchResult ? matchResult[0] : null;
76-
if (uiFrameworkWithoutBuilder) {
74+
const matchResult = options.uiFramework?.match(
75+
/^@storybook\/([\w-]+?)(?:-(?:vite|webpack5|webpack))?$/
76+
);
77+
const uiFrameworkWithoutBuilder = matchResult
78+
? `@storybook/${matchResult[1]}`
79+
: null;
80+
if (
81+
uiFrameworkWithoutBuilder &&
82+
uiFrameworkWithoutBuilder !== options.uiFramework
83+
) {
7784
devDependencies[uiFrameworkWithoutBuilder] = storybookVersionToInstall;
7885
}
7986
}

0 commit comments

Comments
 (0)