From 765bf5ef009f033089aa3b0ab5263f2e0a73033d Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 17:30:10 +0800 Subject: [PATCH 01/13] Merge pull request #28548 from storybookjs/kasper/remove-unused-type Portable stories: Remove unused types (cherry picked from commit 5075c13353ac9690e89ad0211713d2e2f449d614) --- .../src/preview-api/modules/store/csf/portable-stories.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.ts index 647fa492a0e1..37893aa4c035 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.ts @@ -263,10 +263,7 @@ type UnwrappedJSXStoryRef = { __pw_type: 'jsx'; type: UnwrappedImportStoryRef; }; -type UnwrappedImportStoryRef = ComposedStoryFn & { - playPromise?: Promise; - renderingEnded?: PromiseWithResolvers; -}; +type UnwrappedImportStoryRef = ComposedStoryFn; declare global { function __pwUnwrapObject( From 83f7207f58b47fbfbda54f3b193059b9d0ca5ecd Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 22:30:04 +0800 Subject: [PATCH 02/13] Merge pull request #28570 from storybookjs/norbert/cpc-alias-for-theming-create CPC: Add `theming/create` aliases in docs preset (cherry picked from commit 5cb6c6e543f51ed20efa2d3818a5828ccaa31751) --- code/addons/docs/src/preset.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 9f50f7d9a254..0ad19b34bd58 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -70,6 +70,8 @@ async function webpack( */ const cliPath = require.resolve('storybook/package.json'); const themingPath = join(cliPath, '..', 'core', 'theming', 'index.js'); + const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js'); + const componentsPath = join(cliPath, '..', 'core', 'components', 'index.js'); const blocksPath = dirname(require.resolve('@storybook/blocks/package.json')); if (Array.isArray(webpackConfig.resolve?.alias)) { @@ -87,6 +89,10 @@ async function webpack( name: '@mdx-js/react', alias: mdx, }, + { + name: '@storybook/theming/create', + alias: themingCreatePath, + }, { name: '@storybook/theming', alias: themingPath, @@ -104,6 +110,7 @@ async function webpack( alias = { ...webpackConfig.resolve?.alias, react, + '@storybook/theming/create': themingCreatePath, '@storybook/theming': themingPath, '@storybook/components': componentsPath, '@storybook/blocks': blocksPath, @@ -168,6 +175,7 @@ export const viteFinal = async (config: any, options: Options) => { const cliPath = dirname(require.resolve('storybook/package.json')); const themingPath = join(cliPath, 'core', 'theming', 'index.js'); + const themingCreatePath = join(cliPath, 'core', 'theming', 'create.js'); const componentsPath = join(cliPath, 'core', 'components', 'index.js'); const blocksPath = dirname(require.resolve('@storybook/blocks/package.json')); @@ -187,6 +195,7 @@ export const viteFinal = async (config: any, options: Options) => { * * In the future the `@storybook/theming` and `@storybook/components` can be removed, as they should be singletons in the future due to the peerDependency on `storybook` package. */ + '@storybook/theming/create': themingCreatePath, '@storybook/theming': themingPath, '@storybook/components': componentsPath, '@storybook/blocks': blocksPath, From d0ccc2bd54cfc5107587ae10b7174e68dab08a46 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 23:15:57 +0800 Subject: [PATCH 03/13] Merge pull request #28574 from storybookjs/shilman/storybook-82-deps-migration Docs: Add 8.2 implicit dependency migration (cherry picked from commit c730cb7ac01f09f0f98380b417ac568e4fad8f2c) --- MIGRATION.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 33dfe17f0532..d9a85ca06962 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,6 +1,7 @@

Migration

- [From version 8.1.x to 8.2.x](#from-version-81x-to-82x) + - [Failed to resolve import "@storybook/X" error](#failed-to-resolve-import-storybookx-error) - [Preview.js globals renamed to initialGlobals](#previewjs-globals-renamed-to-initialglobals) - [From version 8.0.x to 8.1.x](#from-version-80x-to-81x) - [Portable stories](#portable-stories) @@ -415,6 +416,26 @@ ## From version 8.1.x to 8.2.x +### Failed to resolve import "@storybook/X" error + +Storybook's package structure changed in 8.2. It is a non-breaking change, but can expose missing project dependencies. + +This happens when `@storybook/X` is missing in your `package.json`, but your project references `@storybook/X` in your source code (typically in a story file or in a `.storybook` config file). This is a problem with your project, and if it worked in earlier versions of Storybook, it was purely accidental. + +Now in Storybook 8.2, that incorrect project configuration no longer works. The solution is to install `@storybook/X` as a dev dependency and re-run. + +Example errors: + +```sh +Cannot find module @storybook/preview-api or its corresponding type declarations +``` + +```sh +Internal server error: Failed to resolve import "@storybook/theming/create" from ".storybook/theme.ts". Does the file exist? +``` + +To protect your project from missing dependencies, try [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import). + ### Preview.js globals renamed to initialGlobals Starting in 8.2 `preview.js` `globals` are deprecated and have been renamed to `initialGlobals`. We will remove `preview.js` `globals` in 9.0. From 192dfd23780c0ec3eff453d4853aafc0954b7ce0 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 23:35:13 +0800 Subject: [PATCH 04/13] Merge pull request #28578 from storybookjs/migration-eslint-missing-dependency Docs: Clarify eslint guidance (cherry picked from commit ec7aa6ecaa56668ea9414595137374a4111ada15) --- MIGRATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIGRATION.md b/MIGRATION.md index d9a85ca06962..3dd1311dd620 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -434,7 +434,7 @@ Cannot find module @storybook/preview-api or its corresponding type declarations Internal server error: Failed to resolve import "@storybook/theming/create" from ".storybook/theme.ts". Does the file exist? ``` -To protect your project from missing dependencies, try [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import). +To protect your project from missing dependencies, try the `no-extraneous-dependencies` rule in [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import). ### Preview.js globals renamed to initialGlobals From 0f930a56c0d259d65af366c17772570785848511 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 23:35:45 +0800 Subject: [PATCH 05/13] Merge pull request #28573 from storybookjs/norbert/cpc-incorrect-export-core-events CPC: Fix incorrect re-export in `core-events` (cherry picked from commit bd0969f9e33956fb78d552e987432bf4ae5b791a) --- code/deprecated/core-events/shim.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/deprecated/core-events/shim.js b/code/deprecated/core-events/shim.js index 4c4b44a5716d..217389a630ed 100644 --- a/code/deprecated/core-events/shim.js +++ b/code/deprecated/core-events/shim.js @@ -1 +1 @@ -module.exports = require('storybook/internal/core-errors'); +module.exports = require('storybook/internal/core-events'); From eb83d0d199481a2811c45babf1e29dbd20c7aad6 Mon Sep 17 00:00:00 2001 From: Kyle Gach Date: Fri, 12 Jul 2024 09:46:56 -0600 Subject: [PATCH 06/13] Merge pull request #28560 from storybookjs/fix-configure-page-links Bug: Fix invalid docs links in Configure.mdx template page (cherry picked from commit 0c857155657071638b551a8d0655f109c921cbb5) --- .../nextjs/template/cli/js/Configure.mdx | 20 +++++++++---------- .../nextjs/template/cli/ts-3-8/Configure.mdx | 20 +++++++++---------- .../nextjs/template/cli/ts-4-9/Configure.mdx | 20 +++++++++---------- .../cli/rendererAssets/common/Configure.mdx | 20 +++++++++---------- code/lib/cli/src/helpers.ts | 4 +++- 5 files changed, 43 insertions(+), 41 deletions(-) diff --git a/code/frameworks/nextjs/template/cli/js/Configure.mdx b/code/frameworks/nextjs/template/cli/js/Configure.mdx index 055a3c564efc..cc3292373f73 100644 --- a/code/frameworks/nextjs/template/cli/js/Configure.mdx +++ b/code/frameworks/nextjs/template/cli/js/Configure.mdx @@ -52,7 +52,7 @@ export const RightArrow = () => Add styling and CSS

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

Learn more @@ -67,7 +67,7 @@ export const RightArrow = () => Provide context and mocking

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

Learn more @@ -85,7 +85,7 @@ export const RightArrow = () => Learn more @@ -113,7 +113,7 @@ export const RightArrow = () => Auto-generate living, interactive reference documentation from your components and stories.

Learn more @@ -128,7 +128,7 @@ export const RightArrow = () => Publish to Chromatic

Publish your Storybook to review and collaborate with your entire team.

Learn more @@ -144,7 +144,7 @@ export const RightArrow = () => Embed your stories into Figma to cross-reference the design and live implementation in one place.

Learn more @@ -160,7 +160,7 @@ export const RightArrow = () => Use stories to test a component in all its variations, no matter how complex.

Learn more @@ -175,7 +175,7 @@ export const RightArrow = () => Accessibility

Automatically test your components for a11y issues as you develop.

Learn more @@ -190,7 +190,7 @@ export const RightArrow = () => Theming

Theme Storybook's UI to personalize it to your project.

Learn more @@ -202,7 +202,7 @@ export const RightArrow = () => Addons

Integrate your tools with Storybook to connect workflows.

Discover all addons diff --git a/code/frameworks/nextjs/template/cli/ts-3-8/Configure.mdx b/code/frameworks/nextjs/template/cli/ts-3-8/Configure.mdx index 055a3c564efc..cc3292373f73 100644 --- a/code/frameworks/nextjs/template/cli/ts-3-8/Configure.mdx +++ b/code/frameworks/nextjs/template/cli/ts-3-8/Configure.mdx @@ -52,7 +52,7 @@ export const RightArrow = () => Add styling and CSS

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

Learn more @@ -67,7 +67,7 @@ export const RightArrow = () => Provide context and mocking

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

Learn more @@ -85,7 +85,7 @@ export const RightArrow = () => Learn more @@ -113,7 +113,7 @@ export const RightArrow = () => Auto-generate living, interactive reference documentation from your components and stories.

Learn more @@ -128,7 +128,7 @@ export const RightArrow = () => Publish to Chromatic

Publish your Storybook to review and collaborate with your entire team.

Learn more @@ -144,7 +144,7 @@ export const RightArrow = () => Embed your stories into Figma to cross-reference the design and live implementation in one place.

Learn more @@ -160,7 +160,7 @@ export const RightArrow = () => Use stories to test a component in all its variations, no matter how complex.

Learn more @@ -175,7 +175,7 @@ export const RightArrow = () => Accessibility

Automatically test your components for a11y issues as you develop.

Learn more @@ -190,7 +190,7 @@ export const RightArrow = () => Theming

Theme Storybook's UI to personalize it to your project.

Learn more @@ -202,7 +202,7 @@ export const RightArrow = () => Addons

Integrate your tools with Storybook to connect workflows.

Discover all addons diff --git a/code/frameworks/nextjs/template/cli/ts-4-9/Configure.mdx b/code/frameworks/nextjs/template/cli/ts-4-9/Configure.mdx index 055a3c564efc..cc3292373f73 100644 --- a/code/frameworks/nextjs/template/cli/ts-4-9/Configure.mdx +++ b/code/frameworks/nextjs/template/cli/ts-4-9/Configure.mdx @@ -52,7 +52,7 @@ export const RightArrow = () => Add styling and CSS

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

Learn more @@ -67,7 +67,7 @@ export const RightArrow = () => Provide context and mocking

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

Learn more @@ -85,7 +85,7 @@ export const RightArrow = () => Learn more @@ -113,7 +113,7 @@ export const RightArrow = () => Auto-generate living, interactive reference documentation from your components and stories.

Learn more @@ -128,7 +128,7 @@ export const RightArrow = () => Publish to Chromatic

Publish your Storybook to review and collaborate with your entire team.

Learn more @@ -144,7 +144,7 @@ export const RightArrow = () => Embed your stories into Figma to cross-reference the design and live implementation in one place.

Learn more @@ -160,7 +160,7 @@ export const RightArrow = () => Use stories to test a component in all its variations, no matter how complex.

Learn more @@ -175,7 +175,7 @@ export const RightArrow = () => Accessibility

Automatically test your components for a11y issues as you develop.

Learn more @@ -190,7 +190,7 @@ export const RightArrow = () => Theming

Theme Storybook's UI to personalize it to your project.

Learn more @@ -202,7 +202,7 @@ export const RightArrow = () => Addons

Integrate your tools with Storybook to connect workflows.

Discover all addons diff --git a/code/lib/cli/rendererAssets/common/Configure.mdx b/code/lib/cli/rendererAssets/common/Configure.mdx index a3d3c80985fb..54813ea1f8c3 100644 --- a/code/lib/cli/rendererAssets/common/Configure.mdx +++ b/code/lib/cli/rendererAssets/common/Configure.mdx @@ -48,7 +48,7 @@ export const RightArrow = () => Add styling and CSS

Like with web applications, there are many ways to include CSS within Storybook. Learn more about setting up styling within Storybook.

Learn more @@ -60,7 +60,7 @@ export const RightArrow = () => Provide context and mocking

Often when a story doesn't render, it's because your component is expecting a specific environment or context (like a theme provider) to be available.

Learn more @@ -72,7 +72,7 @@ export const RightArrow = () => Learn more @@ -94,7 +94,7 @@ export const RightArrow = () => Auto-generate living, interactive reference documentation from your components and stories.

Learn more @@ -103,7 +103,7 @@ export const RightArrow = () => Publish to Chromatic

Publish your Storybook to review and collaborate with your entire team.

Learn more @@ -113,7 +113,7 @@ export const RightArrow = () => Embed your stories into Figma to cross-reference the design and live implementation in one place.

Learn more @@ -123,7 +123,7 @@ export const RightArrow = () => Use stories to test a component in all its variations, no matter how complex.

Learn more @@ -132,7 +132,7 @@ export const RightArrow = () => Accessibility

Automatically test your components for a11y issues as you develop.

Learn more @@ -141,7 +141,7 @@ export const RightArrow = () => Theming

Theme Storybook's UI to personalize it to your project.

Learn more @@ -153,7 +153,7 @@ export const RightArrow = () => Addons

Integrate your tools with Storybook to connect workflows.

Discover all addons diff --git a/code/lib/cli/src/helpers.ts b/code/lib/cli/src/helpers.ts index cffea359a871..f2256e11c2b8 100644 --- a/code/lib/cli/src/helpers.ts +++ b/code/lib/cli/src/helpers.ts @@ -221,7 +221,9 @@ export async function copyTemplateFiles({ await fse.copy(await templatePath(), destinationPath, { overwrite: true }); if (includeCommonAssets) { - const rendererType = frameworkToRenderer[renderer] || 'react'; + let rendererType = frameworkToRenderer[renderer] || 'react'; + // This is only used for docs links and the docs site uses `vue` for both `vue` & `vue3` renderers + if (rendererType === 'vue3') rendererType = 'vue'; await adjustTemplate(join(destinationPath, 'Configure.mdx'), { renderer: rendererType }); } } From 9d42bea949e6ea3738134dac89526b2a1d44b86a Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 23:36:31 +0800 Subject: [PATCH 07/13] Merge pull request #28559 from kyletsang/fix-button-story-typo Docs: Fix typo in generated button story (cherry picked from commit 80aa413b087e71746cbd2b0be3afbc34319f6927) --- docs/_snippets/button-story-baseline.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/_snippets/button-story-baseline.md b/docs/_snippets/button-story-baseline.md index b26bdca7ea47..e6862198b815 100644 --- a/docs/_snippets/button-story-baseline.md +++ b/docs/_snippets/button-story-baseline.md @@ -10,7 +10,7 @@ const meta: Meta