|
1 | 1 | ---
|
2 |
| -title: Addon migration guide for Storybook 7.0 |
| 2 | +title: Addon migration guide for Storybook 8.0 |
3 | 3 | ---
|
4 | 4 |
|
5 |
| -Storybook 7 is our first major release in over two years. While Storybook’s addon API has not changed much in the past couple of years, addons require several changes for compatibility with Storybook 7. This guide will walk you through the upgrade process. |
| 5 | +We deeply appreciate the dedication and effort addon creators put into keeping the Storybook ecosystem vibrant and up-to-date. As Storybook evolves to version 8.0, bringing new features and improvements, this guide is here to assist you in migrating your addons from 7.x to 8.0. If you need to migrate your addon from an earlier version of Storybook, please first refer to the [Addon migration guide for Storybook 7.0](https://storybook.js.org/docs/7.6/addons/addon-migration-guide). |
6 | 6 |
|
7 | 7 | <Callout variant="info">
|
8 | 8 |
|
9 | 9 | As we gather feedback from the community, we’ll update this page. We also have a general [Storybook migration guide](../migration-guide.md) if you’re looking for that.
|
10 | 10 |
|
11 | 11 | </Callout>
|
12 | 12 |
|
13 |
| -## Dependencies |
| 13 | +## Updating dependencies |
14 | 14 |
|
15 |
| -The first thing to do is upgrade any Storybook dependencies in your project. We release the next version of all our packages on the `next` npm tag, so the easiest thing is to reference that in your `package.json`: |
| 15 | +Begin by updating your Storybook dependencies. Use the `next` tag for pre-release versions, `latest` for the most recent stable release, or specify the version directly. |
16 | 16 |
|
17 | 17 | ```json
|
18 | 18 | {
|
19 | 19 | "dependencies": {
|
20 |
| - "@storybook/client-logger": "next" |
| 20 | + "@storybook/client-logger": "next" // or "latest", or "^8.0.0" |
21 | 21 | }
|
22 | 22 | }
|
23 | 23 | ```
|
24 | 24 |
|
25 |
| -If you'd rather depend on the latest version of Storybook, you can use the `latest` tag: |
| 25 | +## Key changes for addons |
26 | 26 |
|
27 |
| -```json |
28 |
| -{ |
29 |
| - "dependencies": { |
30 |
| - "@storybook/client-logger": "latest" |
31 |
| - } |
32 |
| -} |
33 |
| -``` |
| 27 | +Here are the essential changes in version 8.0 that impact addon development. Please check the [full migration note](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#from-version-7x-to-800) for an exhaustive list of changes in 8.0. |
34 | 28 |
|
35 |
| -Or use a version specifier: |
| 29 | +### Node.js 16 support dropped |
36 | 30 |
|
37 |
| -```json |
38 |
| -{ |
39 |
| - "dependencies": { |
40 |
| - "@storybook/client-logger": "^7.0.0" |
41 |
| - } |
42 |
| -} |
43 |
| -``` |
| 31 | +Please upgrade your addon to Node.js 18, as support for Node.js 16 has ended. |
44 | 32 |
|
45 |
| -## Breaking changes |
| 33 | +### React 18 for manager UI |
46 | 34 |
|
47 |
| -### `@storybook/addons` has been split into `@storybook/manager-api` and `@storybook/preview-api` |
| 35 | +UI injected into panels, tools, etc. by addons is now rendered with React 18. Also note that the `key` prop is no longer passed to the render function. |
48 | 36 |
|
49 |
| -The default export from `@storybook/addons` can now be used via named imports from `@storybook/manager-api` and `@storybook/preview-api`, depending on which environment you need the API from. The manager is the Storybook UI and includes your addon's Addon Panel. While the preview is used to render stories and includes your addon's decorators. |
| 37 | +### @storybook/components deprecations |
50 | 38 |
|
51 |
| -You might also depend (and use) these packages in your addon's decorators: `@storybook/store`, `@storybook/preview-web`, `@storybook/core-client`, `@storybook/client-api`. These have all been consolidated into `@storybook/preview-api`. If you use any of these packages, please import what you need from `@storybook/preview-api` instead. |
| 39 | +`Icons` component from `@storybook/components` is now deprecated in favor of [`@storybook/icons`](https://github.com/storybookjs/icons). Additionally, various `Button` component props are also deprecated, with alternatives provided. |
52 | 40 |
|
53 |
| -### Some components were moved from `@storybook/components` to a new package `@storybook/blocks` |
| 41 | +### Storybook layout state API changes |
54 | 42 |
|
55 |
| -Components like `ColorControl`, `ColorPalette`, `ArgsTable`, `ArgRow`, `TabbedArgsTable`, `SectionRow`, `Source`, AND `Code` were moved into a new package. In Storybook 7.0, they should be imported from `@storybook/blocks` instead. |
| 43 | +If you're customizing the Storybook UI configuration with `addons.setConfig({...})`, be aware of [the changes to the layout state API](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#ui-layout-state-has-changed-shape). |
56 | 44 |
|
57 |
| -```js |
58 |
| -// import { ColorControl } from '@storybook/components'; |
59 |
| -import { ColorControl } from '@storybook/blocks'; |
60 |
| -``` |
| 45 | +### Removal of deprecated features |
61 | 46 |
|
62 |
| -## Deprecations and detailed migrations |
| 47 | +Deprecated packages and APIs from 7.0 are now removed in 8.0.Consult the [full migration notes](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecations-which-are-now-removed) for details. Most notably for addons, the removal of the `@storybook/addons` now necessitates a switch to `@storybook/preview-api` and `@storybook/manager-api`. |
63 | 48 |
|
64 |
| -We’ve also deprecated a few packages and APIs in 7.0. After you’ve made your addon working with 7.0, make sure to check the browser console in a Storybook running your addon. If you’re using deprecated packages, you should see warnings that link to migration instructions. |
| 49 | +### Babel-loader removed from webpack |
65 | 50 |
|
66 |
| -There are more technical details available in the [migration notes for addon authors](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#specific-instructions-for-addon-creators). |
| 51 | +Storybook 8 [removes babel-loader from the webpack5 builder](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#removed-babelcore-and-babel-loader-from-storybookbuilder-webpack5). If your addon's preset overrides the `babel()` method, it will break if your users are using SWC to compile their files (which is the new default for Webpack 5-based Storybook projects). |
67 | 52 |
|
68 |
| -Finally, for an exhaustive list of noteworthy changes in 7.0, check [the full migration notes](https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#from-version-65x-to-700). |
| 53 | +To solve for both Babel and SWC, the most robust approach is to create an [unplugin](https://github.com/unjs/unplugin) that will work with both Webpack and Vite builders. That will give you full control to run Babel (or whatever you want) on stories and components as they are loaded. |
69 | 54 |
|
70 |
| -## Releasing |
| 55 | +As a workaround, update your documentation to tell users to opt-in to Babel support. This should fix your addon in their project, at the cost of performance: |
| 56 | + |
| 57 | +```sh |
| 58 | +npx storybook@latest add @storybook/addon-webpack5-compiler-babel |
| 59 | +``` |
71 | 60 |
|
72 |
| -You should release a new major version of this addon that supports Storybook 7. If you want to continue making changes that support Storybook 6, you should release a minor or a patch of the previous major version. |
| 61 | +## Releasing |
73 | 62 |
|
74 |
| -We also recommend releasing your own addon using the `next` tag to test it out in projects. |
| 63 | +Release a new major version of your addon for Storybook 8.0. We recommend you to continue supporting 7.x with minor or patch versions. We also recommend releasing your own addon using the `next` tag to test it out in projects. |
75 | 64 |
|
76 | 65 | ## Support
|
77 | 66 |
|
|
0 commit comments