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: Re-Export renderers from frameworks #30771

Merged
merged 29 commits into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e8b9e59
Export Storybook React package in index.ts
ndelangen Mar 7, 2025
d46e15c
Update Storybook imports to use react-vite package
ndelangen Mar 7, 2025
89feffa
Update Storybook preview and bench stories to use react-vite types
ndelangen Mar 7, 2025
217dc11
Update story files to use '@storybook/react-vite' type imports
ndelangen Mar 7, 2025
9d3a70d
Update blocks package stories to use '@storybook/react-vite' imports
ndelangen Mar 7, 2025
9171647
Update Storybook manager stories to use '@storybook/react-vite' imports
ndelangen Mar 7, 2025
ddeea7e
Refactor template file copying to use `templateLocation` parameter
ndelangen Mar 7, 2025
c16f3df
Update Next.js Vite template stories to use '@storybook/experimental-…
ndelangen Mar 7, 2025
b4e0b3d
Update Next.js template stories to use '@storybook/nextjs' imports
ndelangen Mar 7, 2025
9fa6320
Update React Native Web Vite template stories to use '@storybook/reac…
ndelangen Mar 7, 2025
13c5234
Add Storybook template components for React Vite CLI
ndelangen Mar 7, 2025
920f8c2
Add HTML Vite template exports from Storybook HTML package
ndelangen Mar 7, 2025
5592d63
Export HTML Webpack 5 template core functionality from Storybook
ndelangen Mar 7, 2025
41860ed
Add additional exports to Next.js Storybook template index file
ndelangen Mar 7, 2025
4870635
Add Preact Vite template exports from Storybook Preact package
ndelangen Mar 7, 2025
bfedb85
Export Preact Webpack 5 template core functionality from Storybook
ndelangen Mar 7, 2025
660fd78
Export React core functionality in React Native Web Vite template
ndelangen Mar 7, 2025
6e54389
Update framework template index files to export core Storybook packag…
ndelangen Mar 7, 2025
ec7c826
Improve type safety and compatibility in Next.js Vite Storybook frame…
ndelangen Mar 7, 2025
e26712b
Add Storybook template components for Svelte Vite CLI
ndelangen Mar 7, 2025
97d6440
Add Storybook template components for Svelte Vite CLI with multiple v…
ndelangen Mar 7, 2025
7418c0e
Add Storybook template components for Vue3 Vite CLI with multiple var…
ndelangen Mar 7, 2025
543fbba
Add Vue3 Webpack5 Storybook template components for JavaScript and Ty…
ndelangen Mar 7, 2025
92237e7
Add Web Components Storybook template components for Vite and Webpack5
ndelangen Mar 7, 2025
ebf0df0
Merge branch 'norbert/fix-missingStorybookDependencies' into norbert/…
ndelangen Mar 7, 2025
338b629
Update package.json files to include template directory in published …
ndelangen Mar 7, 2025
d522c0b
Merge branch 'norbert/fix-missingStorybookDependencies' into norbert/…
valentinpalkovic Mar 10, 2025
1428150
Merge branch 'norbert/fix-missingStorybookDependencies' into norbert/…
ndelangen Mar 10, 2025
ffbc5d8
Merge branch 'next' into norbert/re-export-renderers-from-frameworks
ndelangen Mar 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion code/.storybook/bench.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta } from '@storybook/react';
import type { Meta } from '@storybook/react-vite';

// @ts-expect-error - TS doesn't know about import.meta.glob from Vite
const allMetafiles = import.meta.glob([
Expand Down
2 changes: 1 addition & 1 deletion code/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {

import { DocsContext } from '@storybook/blocks';
import { global } from '@storybook/global';
import type { Decorator, Loader, ReactRenderer } from '@storybook/react';

import type { Decorator, Loader, ReactRenderer } from '@storybook/react-vite';
// TODO add empty preview
// import * as storysource from '@storybook/addon-storysource';
// import * as designs from '@storybook/addon-designs/preview';
Expand Down
2 changes: 1 addition & 1 deletion code/addons/a11y/src/components/A11YPanel.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { ManagerContext } from 'storybook/internal/manager-api';
import { ThemeProvider, convert, themes } from 'storybook/internal/theming';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import type axe from 'axe-core';
import { fn } from 'storybook/test';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import { ManagerContext } from 'storybook/internal/manager-api';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { fn } from 'storybook/test';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/src/SaveStory.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { action } from '@storybook/addon-actions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CallStates } from 'storybook/internal/instrumenter';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, userEvent, within } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { CallStates } from 'storybook/internal/instrumenter';
import { styled } from 'storybook/internal/theming';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, userEvent, waitFor, within } from 'storybook/test';

Expand Down
1 change: 0 additions & 1 deletion code/addons/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"@neoconfetti/react": "^1.0.0",
"@radix-ui/react-dialog": "^1.0.5",
"@storybook/icons": "^1.2.12",
"@storybook/react": "workspace:*",
"framer-motion": "^11.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { Button } from './Button';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { Confetti } from './Confetti';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, waitFor, within } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, userEvent, waitFor, within } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { fn } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { SplashScreen } from './SplashScreen';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';

import { ManagerContext } from 'storybook/internal/manager-api';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, fn, userEvent, within } from 'storybook/test';
import dedent from 'ts-dedent';
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/Interaction.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CallStates } from 'storybook/internal/instrumenter';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, userEvent, within } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CallStates } from 'storybook/internal/instrumenter';
import { ManagerContext } from 'storybook/internal/manager-api';
import { styled } from 'storybook/internal/theming';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, fn, userEvent, waitFor, within } from 'storybook/test';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/RelativeTime.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { RelativeTime } from './RelativeTime';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { CallStates } from 'storybook/internal/instrumenter';
import { ManagerContext } from 'storybook/internal/manager-api';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { fn } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ManagerContext } from 'storybook/internal/manager-api';
import { styled } from 'storybook/internal/theming';
import { Addon_TypesEnum } from 'storybook/internal/types';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, fn } from 'storybook/test';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/components/TestStatusIcon.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { TestStatusIcon } from './TestStatusIcon';

Expand Down
8 changes: 4 additions & 4 deletions code/core/src/cli/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('Helpers', () => {
filePath === normalizePath('@storybook/react/template/cli')
);
await helpers.copyTemplateFiles({
renderer: 'react',
templateLocation: 'react',
language,
packageManager: packageManagerMock,
commonAssetsDir: normalizePath('create-storybook/rendererAssets/common'),
Expand All @@ -182,7 +182,7 @@ describe('Helpers', () => {
return filePath === normalizePath('@storybook/react/template/cli') || filePath === './src';
});
await helpers.copyTemplateFiles({
renderer: 'react',
templateLocation: 'react',
language: SupportedLanguage.JAVASCRIPT,
packageManager: packageManagerMock,
features: ['dev', 'docs', 'test'],
Expand All @@ -195,7 +195,7 @@ describe('Helpers', () => {
return filePath === normalizePath('@storybook/react/template/cli');
});
await helpers.copyTemplateFiles({
renderer: 'react',
templateLocation: 'react',
language: SupportedLanguage.JAVASCRIPT,
packageManager: packageManagerMock,
features: ['dev', 'docs', 'test'],
Expand All @@ -208,7 +208,7 @@ describe('Helpers', () => {
const expectedMessage = `Unsupported renderer: ${renderer}`;
await expect(
helpers.copyTemplateFiles({
renderer,
templateLocation: renderer,
language: SupportedLanguage.JAVASCRIPT,
packageManager: packageManagerMock,
features: ['dev', 'docs', 'test'],
Expand Down
12 changes: 6 additions & 6 deletions code/core/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function copyTemplate(templateRoot: string, destination = '.') {

type CopyTemplateFilesOptions = {
packageManager: JsPackageManager;
renderer: SupportedFrameworks | SupportedRenderers;
templateLocation: SupportedFrameworks | SupportedRenderers;
language: SupportedLanguage;
commonAssetsDir?: string;
destination?: string;
Expand Down Expand Up @@ -205,7 +205,7 @@ export const cliStoriesTargetPath = async () => {

export async function copyTemplateFiles({
packageManager,
renderer,
templateLocation,
language,
destination,
commonAssetsDir,
Expand All @@ -218,7 +218,7 @@ export async function copyTemplateFiles({
[SupportedLanguage.TYPESCRIPT_4_9]: 'ts-4-9',
};
// FIXME: remove after 9.0
if (renderer === 'svelte') {
if (templateLocation === 'svelte') {
const svelteVersion = await getVersionSafe(packageManager, 'svelte');
if (svelteVersion && major(svelteVersion) >= 5) {
languageFolderMapping = {
Expand All @@ -230,7 +230,7 @@ export async function copyTemplateFiles({
}
}
const templatePath = async () => {
const baseDir = await getRendererDir(packageManager, renderer);
const baseDir = await getRendererDir(packageManager, templateLocation);
const assetsDir = join(baseDir, 'template', 'cli');

const assetsLanguage = join(assetsDir, languageFolderMapping[language]);
Expand All @@ -253,7 +253,7 @@ export async function copyTemplateFiles({
if (existsSync(assetsDir)) {
return assetsDir;
}
throw new Error(`Unsupported renderer: ${renderer} (${baseDir})`);
throw new Error(`Unsupported renderer: ${templateLocation} (${baseDir})`);
};

const destinationPath = destination ?? (await cliStoriesTargetPath());
Expand All @@ -264,7 +264,7 @@ export async function copyTemplateFiles({
await cp(await templatePath(), destinationPath, { recursive: true, filter });

if (commonAssetsDir && features.includes('docs')) {
let rendererType = frameworkToRenderer[renderer] || 'react';
let rendererType = frameworkToRenderer[templateLocation] || 'react';

// This is only used for docs links and the docs site uses `vue` for both `vue` & `vue3` renderers
if (rendererType === 'vue3') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { Badge } from './Badge';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import { LinkIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { Form } from '../form';
import { Button } from './Button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { dedent } from 'ts-dedent';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import { FaceHappyIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { IconButton } from './IconButton';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

import { expect, userEvent, within } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import { StopAltIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { ProgressSpinner } from './ProgressSpinner';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const UnsupportedDark = {
export const Story = {
args: {
language: 'jsx',
children: `import type { Meta, StoryObj } from '@storybook/react';
children: `import type { Meta, StoryObj } from '@storybook/react-vite';
import { Header } from './Header';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import React from 'react';
import { Link } from 'storybook/internal/components';

import { DocumentIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { EmptyTabContent } from './EmptyTabContent';

Expand Down
3 changes: 2 additions & 1 deletion code/core/src/components/components/tabs/tabs.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import { BottomBarIcon, CloseIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { action } from '@storybook/addon-actions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';

import { LinkIcon, LinuxIcon } from '@storybook/icons';
import type { Meta, StoryObj } from '@storybook/react';

import type { Meta, StoryObj } from '@storybook/react-vite';

import { action } from '@storybook/addon-actions';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import type { Meta } from '@storybook/react';
import type { Meta } from '@storybook/react-vite';

import { TooltipMessage } from './TooltipMessage';
import { WithTooltip } from './WithTooltip';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import { styled } from 'storybook/internal/theming';

import type { StoryObj } from '@storybook/react';
import type { StoryObj } from '@storybook/react-vite';

import { expect, screen } from 'storybook/test';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import type { FC } from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

export default {
title: 'MyComponent',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import type { FC } from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

export default {
title: 'MyComponent',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import type { FC } from 'react';

import type { Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react-vite';

export default {
title: 'MyComponent',
Expand Down
Loading