Skip to content
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

Core: Add Rsbuild frameworks to known frameworks #28694

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/core/scripts/helpers/sourcefiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function generateVersionsFile(prettierConfig: prettier.Options | null): Pr
}

async function generateFrameworksFile(prettierConfig: prettier.Options | null): Promise<void> {
const thirdPartyFrameworks = ['qwik', 'solid'];
const thirdPartyFrameworks = ['qwik', 'solid', 'react-rsbuild', 'vue3-rsbuild'];
const location = join(__dirname, '..', '..', 'src', 'types', 'modules', 'frameworks.ts');
const frameworksDirectory = join(__dirname, '..', '..', '..', 'frameworks');

Expand Down
10 changes: 8 additions & 2 deletions code/core/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import stripJsonComments from 'strip-json-comments';
import invariant from 'tiny-invariant';

import { getRendererDir } from './dirs';
import { CoreBuilder, SupportedLanguage } from './project_types';
import { CommunityBuilder, CoreBuilder, SupportedLanguage } from './project_types';

const logger = console;

Expand Down Expand Up @@ -144,7 +144,10 @@ type CopyTemplateFilesOptions = {
/** @deprecated Please use `frameworkToRenderer` from `@storybook/core-common` instead */
export const frameworkToRenderer = CoreFrameworkToRenderer;

export const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder> = {
export const frameworkToDefaultBuilder: Record<
SupportedFrameworks,
CoreBuilder | CommunityBuilder
> = {
angular: CoreBuilder.Webpack5,
ember: CoreBuilder.Webpack5,
'html-vite': CoreBuilder.Vite,
Expand All @@ -165,6 +168,9 @@ export const frameworkToDefaultBuilder: Record<SupportedFrameworks, CoreBuilder>
'vue3-webpack5': CoreBuilder.Webpack5,
'web-components-vite': CoreBuilder.Vite,
'web-components-webpack5': CoreBuilder.Webpack5,
// Only to pass type checking, will never be used
'react-rsbuild': CommunityBuilder.Rsbuild,
'vue3-rsbuild': CommunityBuilder.Rsbuild,
};

export async function copyTemplateFiles({
Expand Down
4 changes: 4 additions & 0 deletions code/core/src/cli/project_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export enum CoreWebpackCompilers {
SWC = 'swc',
}

export enum CommunityBuilder {
Rsbuild = 'rsbuild',
}

export const compilerNameToCoreCompiler: Record<string, CoreWebpackCompilers> = {
'@storybook/addon-webpack5-compiler-babel': CoreWebpackCompilers.Babel,
'@storybook/addon-webpack5-compiler-swc': CoreWebpackCompilers.SWC,
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/common/utils/framework-to-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const frameworkToRenderer: Record<
'vue3-webpack5': 'vue3',
'web-components-vite': 'web-components',
'web-components-webpack5': 'web-components',
'react-rsbuild': 'react',
'vue3-rsbuild': 'vue3',
// renderers
html: 'html',
preact: 'preact',
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/common/utils/get-storybook-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const frameworkPackages: Record<string, SupportedFrameworks> = {
// community (outside of monorepo)
'storybook-framework-qwik': 'qwik',
'storybook-solidjs-vite': 'solid',
'storybook-react-rsbuild': 'react-rsbuild',
'storybook-vue3-rsbuild': 'vue3-rsbuild',
};

export const builderPackages = ['@storybook/builder-webpack5', '@storybook/builder-vite'];
Expand Down
4 changes: 3 additions & 1 deletion code/core/src/types/modules/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ export type SupportedFrameworks =
| 'web-components-vite'
| 'web-components-webpack5'
| 'qwik'
| 'solid';
| 'solid'
| 'react-rsbuild'
| 'vue3-rsbuild';
Loading