storybook/MIGRATION.md

226 lines
11 KiB
Markdown
Raw Normal View History

# Migration
## Table of contents
2018-05-22 16:01:16 -07:00
- [From version 3.4.x to 4.0.x](#from-version-34x-to-40x)
- [Keyboard shortcuts moved](#keyboard-shortcuts-moved)
- [Removed addWithInfo](#removed-add-with-info)
2018-05-23 11:20:06 -07:00
- [Removed RN addons](#removed-rn-addons)
2018-03-30 16:26:07 -07:00
- [From version 3.3.x to 3.4.x](#from-version-33x-to-34x)
2017-12-26 14:29:59 -08:00
- [From version 3.2.x to 3.3.x](#from-version-32x-to-33x)
- [Refactored Knobs](#refactored-knobs)
2017-12-27 11:53:50 +11:00
- [Storyshots Jest configuration](#storyshots-jest-configuration)
2017-07-27 16:24:42 -07:00
- [From version 3.1.x to 3.2.x](#from-version-31x-to-32x)
- [Moved TypeScript addons definitions](#moved-typescript-addons-definitions)
- [Updated Addons API](#updated-addons-api)
2017-06-10 00:16:13 +12:00
- [From version 3.0.x to 3.1.x](#from-version-30x-to-31x)
2017-06-09 22:34:41 +12:00
- [Moved TypeScript definitions](#moved-typescript-definitions)
- [Deprecated head.html](#deprecated-headhtml)
- [From version 2.x.x to 3.x.x](#from-version-2xx-to-3xx)
- [Webpack upgrade](#webpack-upgrade)
- [Packages renaming](#packages-renaming)
- [Deprecated embedded addons](#deprecated-embedded-addons)
2018-04-11 15:10:35 -04:00
## From 3.4.x to 4.0
2018-05-23 11:20:06 -07:00
With 4.0 as our first major release in over a year, we've collected a lot of cleanup tasks. All deprecations have been marked for months, so we hope that there will be no significant impact on your project.
2018-05-22 16:01:16 -07:00
### Keyboard shortcuts moved
2018-04-11 15:10:35 -04:00
- Addon Panel to `Z`
- Stories Panel to `X`
- Show Search to `O`
- Addon Panel right side to `G`
2018-05-22 16:01:16 -07:00
### Removed addWithInfo
`Addon-info`'s `addWithInfo` has been marked deprecated since 3.2. In 4.0 we've removed it completely. See the package [README](https://github.com/storybooks/storybook/blob/master/addons/info/README.md) for the proper usage.
2018-05-23 11:20:06 -07:00
### Removed RN addons
The `@storybook/react-native` had built-in addons (`addon-actions` and `addon-links`) that have been marked as deprecated since 3.x. They have been fully removed in 4.x. If your project still uses the built-ins, you'll need to add explicit dependencies on `@storybook/addon-actions` and/or `@storybook/addon-links` and import directly from those packages.
2018-03-30 16:26:07 -07:00
## From version 3.3.x to 3.4.x
There are no expected breaking changes in the 3.4.x release, but 3.4 contains a major refactor to make it easier to support new frameworks, and we will document any breaking changes here if they arise.
2017-12-26 14:29:59 -08:00
## From version 3.2.x to 3.3.x
2018-01-10 16:39:23 +03:00
There wasn't expected be any breaking changes in this release, but unfortunately it turned out that there are some. We're revisiting our [release strategy](https://github.com/storybooks/storybook/blob/master/RELEASES.md) to follow semver more strictly.
Also read on if you're using `addon-knobs`: we advise an update to your code for efficiency's sake.
### `babel-core` is now a peer dependency ([#2494](https://github.com/storybooks/storybook/pull/2494))
This affects you if you don't use babel in your project. You may need to add `babel-core` as dev dependency:
```
npm install --save-dev babel-core
```
This was done to support different major versions of babel.
### Base webpack config now contains vital plugins ([#1775](https://github.com/storybooks/storybook/pull/1775))
This affects you if you use custom webpack config in [Full Control Mode](https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode) while not preserving the plugins from `storybookBaseConfig`. Before `3.3`, preserving them was just a reccomendation, but now it [became](https://github.com/storybooks/storybook/pull/2578) a requirement.
2017-12-26 14:29:59 -08:00
### Refactored Knobs
Knobs users: there was a bug in 3.2.x where using the knobs addon imported all framework runtimes (e.g. React and Vue). To fix the problem, we [refactored knobs](https://github.com/storybooks/storybook/pull/1832). Switching to the new style is easy:
In the case of React or React-Native, import knobs like this:
```js
import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';
```
In the case of Vue: `import { ... } from '@storybook/addon-knobs/vue';`
In the case of Angular: `import { ... } from '@storybook/addon-knobs/angular';`
2017-07-27 16:24:42 -07:00
## From version 3.1.x to 3.2.x
**NOTE:** technically this is a breaking change, but only if you use TypeScript. Sorry people!
### Moved TypeScript addons definitions
TypeScript users: we've moved the rest of our addons type definitions into [DefinitelyTyped](http://definitelytyped.org/). Starting in 3.2.0 make sure to use the right addons types:
```sh
npm install @types/storybook__addon-notes @types/storybook__addon-options @types/storybook__addon-knobs @types/storybook__addon-links --save-dev
```
See also [TypeScript definitions in 3.1.x](#moved-typescript-definitions).
### Updated Addons API
We're in the process of upgrading our addons APIs. As a first step, we've upgraded the Info and Notes addons. The old API will still work with your existing projects, but will be deprecated soon and removed in Storybook 4.0.
Here's an example of using Notes and Info in 3.2 with the new API.
```js
storiesOf('composition', module)
.add('new addons api',
withInfo('see Notes panel for composition info')(
2017-09-02 17:40:51 -05:00
withNotes({ text: 'Composition: Info(Notes())' })(context =>
2017-07-27 16:24:42 -07:00
<MyComponent name={context.story} />
)
)
);
```
It's not beautiful, but we'll be adding a more convenient/idiomatic way of using these [withX primitives](https://gist.github.com/shilman/792dc25550daa9c2bf37238f4ef7a398) in Storybook 3.3.
2017-06-10 00:16:13 +12:00
## From version 3.0.x to 3.1.x
**NOTE:** technically this is a breaking change and should be a 4.0.0 release according to semver. However, we're still figuring things out, and didn't think this change necessitated a major release. Please bear with us!
2017-06-09 22:34:41 +12:00
### Moved TypeScript definitions
2017-06-09 22:34:41 +12:00
TypeScript users: we are in the process of moving our typescript definitions into [DefinitelyTyped](http://definitelytyped.org/). If you're using TypeScript, starting in 3.1.0 you need to make sure your type definitions are installed:
```sh
npm install @types/node @types/react @types/storybook__react --save-dev
```
2017-06-09 22:34:41 +12:00
### Deprecated head.html
We have deprecated the use of `head.html` for including scripts/styles/etc. into stories, though it will still work with a warning.
Now we use:
- `preview-head.html` for including extra content into the preview pane.
- `manager-head.html` for including extra content into the manager window.
[Read our docs](https://storybook.js.org/configurations/add-custom-head-tags/) for more details.
## From version 2.x.x to 3.x.x
This major release is mainly an internal restructuring.
Upgrading requires work on behalf of users, this was unavoidable.
We're sorry if this inconveniences you, we have tried via this document and provided tools to make the process as easy as possible.
### Webpack upgrade
Storybook will now use webpack 2 (and only webpack 2).
If you are using a custom `webpack.config.js` you need to change this to be compatible.
You can find the guide to upgrading your webpack config [on webpack.js.org](https://webpack.js.org/guides/migrating/).
### Packages renaming
2017-05-30 15:17:46 +10:00
All our packages have been renamed and published to npm as version 3.0.0 under the `@storybook` namespace.
To update your app to use the new package names, you can use the cli:
```bash
npm install --global @storybook/cli
# if you run this inside a v2 app, it should perform the necessary codemods.
getstorybook
```
#### Details
If the above doesn't work, or you want to make the changes manually, the details are below:
> We have adopted the same versioning strategy as have been adopted by babel, jest and apollo.
2017-05-27 22:10:34 +02:00
> It's a strategy best suited for ecosystem type tools, which consist of many separately installable features / packages.
> We think this describes storybook pretty well.
The new package names are:
| old | new |
| -------------------------------------------- | -------------------------------- |
| `getstorybook` | `@storybook/cli` |
| `@kadira/getstorybook` | `@storybook/cli` |
| | |
| `@kadira/storybook` | `@storybook/react` |
| `@kadira/react-storybook` | `@storybook/react` |
| `@kadira/react-native-storybook` | `@storybook/react-native` |
| | |
| `storyshots` | `@storybook/addon-storyshots` |
| `@kadira/storyshots` | `@storybook/addon-storyshots` |
| | |
| `@kadira/storybook-ui` | `@storybook/ui` |
| `@kadira/storybook-addons` | `@storybook/addons` |
| `@kadira/storybook-channels` | `@storybook/channels` |
| `@kadira/storybook-channel-postmsg` | `@storybook/channel-postmessage` |
| `@kadira/storybook-channel-websocket` | `@storybook/channel-websocket` |
| | |
| `@kadira/storybook-addon-actions` | `@storybook/addon-actions` |
| `@kadira/storybook-addon-links` | `@storybook/addon-links` |
| `@kadira/storybook-addon-info` | `@storybook/addon-info` |
| `@kadira/storybook-addon-knobs` | `@storybook/addon-knobs` |
| `@kadira/storybook-addon-notes` | `@storybook/addon-notes` |
| `@kadira/storybook-addon-options` | `@storybook/addon-options` |
| `@kadira/storybook-addon-graphql` | `@storybook/addon-graphql` |
| `@kadira/react-storybook-decorator-centered` | `@storybook/addon-centered` |
If your codebase is small, it's probably doable to just replace them by hand. (in your codebase and in `package.json`).
2017-05-27 22:10:34 +02:00
But if you have a lot of occurrences in your codebase, you can use a [codemod we created](./lib/codemod) for you.
2017-05-27 20:03:35 +02:00
> A codemod makes automatic changed to your app's code.
You have to change your `package.json`, prune old and install new dependencies by hand.
2017-05-27 22:10:34 +02:00
`npm prune` will remove all dependencies from `node_modules` which are no longer referenced in `package.json`.
### Deprecated embedded addons
We used to ship 2 addons with every single installation of storybook: `actions` and `links`. But in practice not everyone is using them, so we decided to deprecate this and in the future they will be completely removed. If you use `@storybook/react/addons` you will get a deprecation warning.
If you **are** using these addons, migrating is simple:
- add the addons you use to your `package.json`.
2017-05-27 20:03:35 +02:00
- update your code:
change `addons.js` like so:
```js
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
```
change `x.story.js` like so:
```js
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
2017-07-12 14:16:45 +02:00
import { linkTo } from '@storybook/addon-links';
```