From 9d5e205850ab251f2530f055e9f1313d281b2e39 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 22:23:37 +0800 Subject: [PATCH 1/2] Docs: Add 8.2 implicit dependency migration --- MIGRATION.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 33dfe17f0532..fc645a9f1401 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,19 @@ ## 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 `.storybok` 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, it no longer works. The workaround is to install `@storybook/X` as a dev dependency and re-run. + +Example errors: + +- "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?" + ### 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 69637cb27efe3276453ea51265d2366d3a723192 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Fri, 12 Jul 2024 23:01:08 +0800 Subject: [PATCH 2/2] Update MIGRATION.md Co-Authored-By: Kyle Gach --- MIGRATION.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index fc645a9f1401..d9a85ca06962 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -420,14 +420,21 @@ 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 `.storybok` config file). This is a problem with your project, and if it worked in earlier versions of Storybook, it was purely accidental. +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, it no longer works. The workaround is to install `@storybook/X` as a dev dependency and re-run. +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: -- "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?" +```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