Skip to content
Draft
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ For additional help, share your issue in [the repo's GitHub Discussions](https:/
| [Qwik](https://github.com/literalpie/storybook-framework-qwik) | [![](https://img.shields.io/npm/v/storybook-framework-qwik/latest?style=flat-square&color=blue&label)](/) | [![Qwik](https://img.shields.io/npm/dm/storybook-framework-qwik?style=flat-square&color=eee)](https://github.com/literalpie/storybook-framework-qwik) |
| [SolidJS](https://github.com/solidjs-community/storybook) | [![](https://img.shields.io/npm/v/storybook-solidjs-vite/latest?style=flat-square&color=blue&label)](/) | [![SolidJS](https://img.shields.io/npm/dm/storybook-solidjs-vite?style=flat-square&color=eee)](https://github.com/solidjs-community/storybook) |
| [Android, iOS, Flutter](https://github.com/storybookjs/native) | [![](https://img.shields.io/npm/v/@storybook/native/latest?style=flat-square&color=blue&label)](/) | [![Native](https://img.shields.io/npm/dm/@storybook/native?style=flat-square&color=eee)](https://github.com/storybookjs/native) |
| [StencilJS](https://github.com/stenciljs/storybook) | [![](https://img.shields.io/npm/v/@stencil/storybook-plugin/latest?style=flat-square&color=blue&label)](/) | [![Stencil](https://img.shields.io/npm/dm/@stencil/storybook-plugin?style=flat-square&color=eee)](https://github.com/stenciljs/storybook) |

### Addons

Expand Down
1 change: 1 addition & 0 deletions code/core/scripts/generate-source-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async function generateFrameworksFile(prettierConfig: prettier.Options | null):
'solid',
'vue3-rsbuild',
'web-components-rsbuild',
'stencil',
];
const destination = join(CORE_ROOT_DIR, 'src', 'types', 'modules', 'frameworks.ts');
const frameworksDirectory = join(CODE_DIR, 'frameworks');
Expand Down
1 change: 1 addition & 0 deletions code/core/src/cli/projectTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum ProjectType {
SERVER = 'server',
SOLID = 'solid',
SVELTE = 'svelte',
STENCIL = 'stencil',
SVELTEKIT = 'sveltekit',
UNDETECTED = 'undetected',
UNSUPPORTED = 'unsupported',
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/common/utils/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const frameworkToRenderer: Record<
[SupportedRenderer.SVELTE]: SupportedRenderer.SVELTE,
[SupportedRenderer.VUE3]: SupportedRenderer.VUE3,
[SupportedRenderer.WEB_COMPONENTS]: SupportedRenderer.WEB_COMPONENTS,
[SupportedRenderer.STENCIL]: SupportedRenderer.STENCIL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, find the type definition files
fd -t f "renderers.ts|frameworks.ts" code/

Repository: storybookjs/storybook

Length of output: 213


🏁 Script executed:

# Check if those specific files exist and their locations
find code -name "renderers.ts" -o -name "frameworks.ts" 2>/dev/null

Repository: storybookjs/storybook

Length of output: 147


🏁 Script executed:

# Also check the framework.ts file to see context around lines 39 and 65
wc -l code/core/src/common/utils/framework.ts
head -n 80 code/core/src/common/utils/framework.ts

Repository: storybookjs/storybook

Length of output: 3487


🏁 Script executed:

cat -n code/core/src/types/modules/renderers.ts

Repository: storybookjs/storybook

Length of output: 484


🏁 Script executed:

cat -n code/core/src/types/modules/frameworks.ts

Repository: storybookjs/storybook

Length of output: 989


STENCIL types are not defined in the type system.

The enums SupportedRenderer.STENCIL and SupportedFramework.STENCIL do not exist in code/core/src/types/modules/renderers.ts or code/core/src/types/modules/frameworks.ts. These type definitions must be added before the mappings at lines 39 and 65 in framework.ts can be used. Note that frameworks.ts is marked as auto-generated and should not be edited directly.

🤖 Prompt for AI Agents
In code/core/src/common/utils/framework.ts around line 39, the mapping
references SupportedRenderer.STENCIL and SupportedFramework.STENCIL but those
enum members are missing from code/core/src/types/modules/renderers.ts and
code/core/src/types/modules/frameworks.ts (frameworks.ts is auto-generated and
must not be edited directly). Add the STENCIL member to the canonical type
definitions: update code/core/src/types/modules/renderers.ts to export
SupportedRenderer.STENCIL and update the source that generates
code/core/src/types/modules/frameworks.ts so SupportedFramework.STENCIL is
generated (or, if changing the generator is not possible, add a separate
declaration augmentation file that extends the SupportedFramework enum/type with
STENCIL) so the mappings in framework.ts resolve cleanly.

};

export const frameworkToBuilder: Record<SupportedFramework, SupportedBuilder> = {
Expand All @@ -61,4 +62,5 @@ export const frameworkToBuilder: Record<SupportedFramework, SupportedBuilder> =
[SupportedFramework.VUE3_RSBUILD]: SupportedBuilder.RSBUILD,
[SupportedFramework.HTML_RSBUILD]: SupportedBuilder.RSBUILD,
[SupportedFramework.WEB_COMPONENTS_RSBUILD]: SupportedBuilder.RSBUILD,
[SupportedFramework.STENCIL]: SupportedBuilder.VITE,
};
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 @@ -34,6 +34,7 @@ export const rendererPackages: Record<string, SupportedRenderer> = {
// community (outside of monorepo)
'storybook-framework-qwik': SupportedRenderer.QWIK,
'storybook-solidjs-vite': SupportedRenderer.SOLID,
'@stencil/storybook-plugin': SupportedRenderer.STENCIL,
};

export const frameworkPackages: Record<string, SupportedFramework> = {
Expand All @@ -59,6 +60,7 @@ export const frameworkPackages: Record<string, SupportedFramework> = {
'storybook-web-components-rsbuild': SupportedFramework.WEB_COMPONENTS_RSBUILD,
'storybook-html-rsbuild': SupportedFramework.HTML_RSBUILD,
'@storybook-vue/nuxt': SupportedFramework.NUXT,
'@stencil/storybook-plugin': SupportedFramework.STENCIL,
};

export const builderPackages: Record<string, SupportedBuilder> = {
Expand Down
1 change: 1 addition & 0 deletions code/core/src/types/modules/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum SupportedFramework {
QWIK = 'qwik',
REACT_RSBUILD = 'react-rsbuild',
SOLID = 'solid',
STENCIL = 'stencil',
VUE3_RSBUILD = 'vue3-rsbuild',
WEB_COMPONENTS_RSBUILD = 'web-components-rsbuild',
}
1 change: 1 addition & 0 deletions code/core/src/types/modules/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export enum SupportedRenderer {
SERVER = 'server',
SOLID = 'solid',
NUXT = 'nuxt',
STENCIL = 'stencil',
}
14 changes: 14 additions & 0 deletions code/lib/cli-storybook/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,19 @@ export const baseTemplates = {
type: ProjectType.REACT_NATIVE_WEB,
},
},
'stencil/default-ts': {
name: 'StencilJS CLI Latest (Vite | TypeScript)',
script: 'npm init stencil@latest component {{beforeDir}}',
// TODO: The community template does not provide standard stories, which is required for e2e tests. Reenable once it does.
inDevelopment: true,
expected: {
framework: '@stencil/storybook-plugin',
renderer: '@stencil/storybook-plugin',
builder: '@stencil/storybook-plugin',
},
// TODO: The community template does not provide standard stories, which is required for e2e tests.
skipTasks: ['e2e-tests', 'e2e-tests-dev', 'bench', 'vitest-integration'],
},
} satisfies Record<string, BaseTemplates>;

/**
Expand Down Expand Up @@ -1036,6 +1049,7 @@ export const daily: TemplateKey[] = [
'lit-rsbuild/default-ts',
'html-rsbuild/default-ts',
// 'react-native-web-vite/rn-cli-ts',
// 'stencil/default-ts',
];

export const templatesByCadence = { normal, merged, daily };
3 changes: 3 additions & 0 deletions code/lib/create-storybook/src/bin/modernInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const supportedFrameworks = [
'react-webpack5',
'server-webpack5',
'solid',
'stencil',
'svelte-vite',
'sveltekit',
'vue3-rsbuild',
Expand Down Expand Up @@ -45,6 +46,7 @@ export const supportedFrameworksPackages = {
nuxt: '@storybook/vue3-vite',
qwik: 'storybook-framework-qwik',
solid: 'storybook-solidjs-vite',
stencil: '@stencil/storybook-plugin',
sveltekit: '@storybook/sveltekit',
'react-native': '@storybook/react-native',
} satisfies Record<Framework, string>;
Expand All @@ -68,6 +70,7 @@ export const supportedFrameworksNames = {
nuxt: 'Nuxt',
qwik: 'Qwik',
solid: 'Solid',
stencil: 'Stencil',
sveltekit: 'SvelteKit',
'react-native': 'React Native',
} satisfies Record<Framework, string>;
16 changes: 16 additions & 0 deletions code/lib/create-storybook/src/generators/STENCIL/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ProjectType } from 'storybook/internal/cli';
import { SupportedRenderer } from 'storybook/internal/types';

import { defineGeneratorModule } from '../modules/GeneratorModule';

export default defineGeneratorModule({
metadata: {
projectType: ProjectType.STENCIL,
renderer: SupportedRenderer.STENCIL,
},
configure: async () => {
return {
extraPackages: ['@stencil/storybook-plugin'],
};
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import reactNativeWebGenerator from './REACT_NATIVE_WEB';
import reactScriptsGenerator from './REACT_SCRIPTS';
import serverGenerator from './SERVER';
import solidGenerator from './SOLID';
import stencilGenerator from './STENCIL';
import svelteGenerator from './SVELTE';
import svelteKitGenerator from './SVELTEKIT';
import vue3Generator from './VUE3';
Expand All @@ -38,6 +39,7 @@ const setOfGenerators = new Set<GeneratorModule>([
solidGenerator,
serverGenerator,
qwikGenerator,
stencilGenerator,
]);

/** Register all framework generators with the central registry */
Expand Down
1 change: 0 additions & 1 deletion code/lib/create-storybook/src/initiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from 'storybook/internal/common';
import { withTelemetry } from 'storybook/internal/core-server';
import { logTracker, logger } from 'storybook/internal/node-logger';
import { ErrorCollector } from 'storybook/internal/telemetry';

import {
executeAddonConfiguration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { dedent } from 'ts-dedent';
const viteConfigFiles = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];
const webpackConfigFiles = ['webpack.config.js'];
const rsbuildConfigFiles = ['rsbuild.config.ts', 'rsbuild.config.js', 'rsbuild.config.mjs'];
const stencilConfigFiles = ['stencil.config.ts'];

export class FrameworkDetectionService {
constructor(private jsPackageManager: JsPackageManager) {}
Expand All @@ -31,16 +32,18 @@ export class FrameworkDetectionService {
const viteConfig = find.any(viteConfigFiles, { last: getProjectRoot() });
const webpackConfig = find.any(webpackConfigFiles, { last: getProjectRoot() });
const rsbuildConfig = find.any(rsbuildConfigFiles, { last: getProjectRoot() });
const stencilConfig = find.any(stencilConfigFiles, { last: getProjectRoot() });
const dependencies = this.jsPackageManager.getAllDependencies();

// Detect which builders are present
const hasVite = viteConfig || !!dependencies.vite;
const hasWebpack = webpackConfig || !!dependencies.webpack;
const hasRsbuild = rsbuildConfig || !!dependencies['@rsbuild/core'];
const hasStencil = stencilConfig || !!dependencies['@stencil/core'];

const detectedBuilders: SupportedBuilder[] = [];

if (hasVite) {
if (hasVite || hasStencil) {
detectedBuilders.push(SupportedBuilder.VITE);
}

Expand Down
7 changes: 7 additions & 0 deletions code/lib/create-storybook/src/services/ProjectTypeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export class ProjectTypeService {
return dependencies?.every(Boolean) ?? true;
},
},
{
preset: ProjectType.STENCIL,
dependencies: ['@stencil/core'],
matcherFunction: ({ dependencies }) => {
return dependencies?.every(Boolean) ?? true;
},
},
// DO NOT MOVE ANY TEMPLATES BELOW THIS LINE
// React is part of every Template, after Storybook is initialized once
{
Expand Down