Skip to content
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
3 changes: 3 additions & 0 deletions code/core/src/core-server/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export async function storybookDevServer(options: Options) {

(await getMiddleware(options.configDir))(app);

// Apply experimental_devServer preset to allow addons/frameworks to extend the dev server with middlewares, etc.
await options.presets.apply('experimental_devServer', app);

const { port, host, initialPath } = options;
invariant(port, 'expected options to have a port');
const proto = options.https ? 'https' : 'http';
Expand Down
4 changes: 3 additions & 1 deletion code/core/src/types/modules/core-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export type Middleware<T extends IncomingMessage = IncomingMessage> = (
next: (err?: string | Error) => Promise<void> | void
) => Promise<void> | void;

interface ServerApp<T extends IncomingMessage = IncomingMessage> {
export interface ServerApp<T extends IncomingMessage = IncomingMessage> {
server: NetServer;

use(pattern: RegExp | string, ...handlers: Middleware<T>[]): this;
Expand Down Expand Up @@ -498,6 +498,8 @@ export interface StorybookConfigRaw {

experimental_indexers?: Indexer[];

experimental_devServer?: ServerApp;

Comment on lines +501 to +502
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add corresponding entry in StorybookConfig interface for type completeness.

The experimental_devServer field is defined in StorybookConfigRaw but is missing from the StorybookConfig interface (lines 520-619). Following the pattern of other experimental fields like experimental_indexers (line 586), this should be added to StorybookConfig wrapped with PresetValue for proper type safety when users or addons define this in their configuration files.

Add this entry to the StorybookConfig interface (around line 587, after experimental_indexers):

  /** Process CSF files for the story index. */
  experimental_indexers?: PresetValue<StorybookConfigRaw['experimental_indexers']>;
  
+  /** Extend the dev server with custom middleware and handlers. */
+  experimental_devServer?: PresetValue<StorybookConfigRaw['experimental_devServer']>;

  /** Docs related features in index generation */
  docs?: PresetValue<StorybookConfigRaw['docs']>;

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In code/core/src/types/modules/core-common.ts around lines 501-502, the
experimental_devServer property exists on StorybookConfigRaw but is missing from
the StorybookConfig interface; add an entry to StorybookConfig (around line
~587, immediately after experimental_indexers) named experimental_devServer with
the same wrapping pattern as other experimental fields (i.e., use PresetValue
keyed to the ServerApp type or ServerApp | undefined) so the interface matches
StorybookConfigRaw and maintains type safety for user/addon configs.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shilman I don't want this to be exposed to users' config types, it's too early for that. experimental_indexers is different, because honestly that's not really experimental anymore.

docs?: DocsOptions;

previewHead?: string;
Expand Down
Loading