Skip to content

Commit

Permalink
Next.js: Make RSC portable-stories compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jul 30, 2024
1 parent 61b8fc3 commit d271575
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions code/frameworks/nextjs/src/portable-stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {

// ! ATTENTION: This needs to be a relative import so it gets prebundled. This is to avoid ESM issues in Nextjs + Jest setups
import { INTERNAL_DEFAULT_PROJECT_ANNOTATIONS as reactAnnotations } from '../../../renderers/react/src/portable-stories';
import * as rscAnnotations from '../../../renderers/react/src/entry-preview-rsc';
import * as nextJsAnnotations from './preview';

import type { ReactRenderer, Meta } from '@storybook/react';
Expand Down Expand Up @@ -46,6 +47,7 @@ export function setProjectAnnotations(
// This will not be necessary once we have auto preset loading
const defaultProjectAnnotations: ProjectAnnotations<ReactRenderer> = composeConfigs([
reactAnnotations,
rscAnnotations,
nextJsAnnotations,
]);

Expand Down
3 changes: 2 additions & 1 deletion code/renderers/react/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export const previewAnnotations: PresetProperty<'previewAnnotations'> = async (
options
) => {
const docsConfig = await options.presets.apply('docs', {}, options);
const features = await options.presets.apply('features', {}, options);
const docsEnabled = Object.keys(docsConfig).length > 0;
const result: string[] = [];

return result
.concat(input)
.concat([join(__dirname, 'entry-preview.mjs')])
.concat(docsEnabled ? [join(__dirname, 'entry-preview-docs.mjs')] : [])
.concat(FEATURES?.experimentalRSC ? [join(__dirname, 'entry-preview-rsc.mjs')] : []);
.concat(features?.experimentalRSC ? [join(__dirname, 'entry-preview-rsc.mjs')] : []);
};

/**
Expand Down

0 comments on commit d271575

Please sign in to comment.