Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add Stencil support across various modules
- Added 'stencil' to the list of supported frameworks in generate-source-files.ts and frameworks.ts.
- Updated ProjectType enum to include STENCIL.
- Enhanced framework detection service to recognize Stencil configurations.
- Registered Stencil generator in registerGenerators.ts.
- Updated builder and renderer mappings to include Stencil.
- Added necessary imports and configurations in the Stencil generator module.
  • Loading branch information
valentinpalkovic committed Dec 9, 2025
commit 36e23c215daf940edc0df5b0a87bb16fd50466f2
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
Copy Markdown
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.STENCIL,
};
3 changes: 3 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,13 +60,15 @@ 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> = {
'@storybook/builder-webpack5': SupportedBuilder.WEBPACK5,
'@storybook/builder-vite': SupportedBuilder.VITE,
// community (outside of monorepo)
'storybook-builder-rsbuild': SupportedBuilder.RSBUILD,
'@stencil/storybook-plugin': SupportedBuilder.STENCIL,
};

export const compilerPackages: Record<string, CoreWebpackCompiler> = {
Expand Down
1 change: 1 addition & 0 deletions code/core/src/types/modules/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum SupportedBuilder {
VITE = 'vite',
// COMMUNITY
RSBUILD = 'rsbuild',
STENCIL = 'stencil',
}
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',
}
20 changes: 14 additions & 6 deletions code/lib/create-storybook/src/generators/STENCIL/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { baseGenerator } from '../baseGenerator';
import type { Generator } from '../types';
import { ProjectType } from 'storybook/internal/cli';
import { SupportedRenderer } from 'storybook/internal/types';

const generator: Generator = async (packageManager, npmOptions, options) => {
await baseGenerator(packageManager, npmOptions, options, 'stencil', {}, 'stencil');
};
import { defineGeneratorModule } from '../modules/GeneratorModule';

export default generator;
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
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,12 +32,14 @@ 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[] = [];

Expand All @@ -52,6 +55,10 @@ export class FrameworkDetectionService {
detectedBuilders.push(SupportedBuilder.RSBUILD);
}

if (hasStencil) {
detectedBuilders.push(SupportedBuilder.STENCIL);
}

// If exactly one builder is detected, return it
if (detectedBuilders.length === 1) {
return detectedBuilders[0];
Expand All @@ -62,6 +69,7 @@ export class FrameworkDetectionService {
{ label: 'Vite', value: SupportedBuilder.VITE },
{ label: 'Webpack 5', value: SupportedBuilder.WEBPACK5 },
{ label: 'Rsbuild', value: SupportedBuilder.RSBUILD },
{ label: 'Stencil', value: SupportedBuilder.STENCIL },
];

return prompt.select({
Expand Down