From de8ab0988a98aaeb4732c010e8ae5860ebd450cf Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Wed, 23 Aug 2023 14:00:19 +0200 Subject: [PATCH 01/11] add migration notes for storyIndexers --- MIGRATION.md | 65 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 5022eefb59bd..0736a8c3e0ed 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,7 +1,9 @@

Migration

+- [From version 7.3.0 to 7.4.0](#from-version-730-to-740) + - [`storyIndexers` is replaced with `experimental_indexers`](#storyindexers-is-replaced-with-experimental_indexers) - [From version 7.0.0 to 7.2.0](#from-version-700-to-720) - - [Addon API is more type-strict](#addon-api-is-more-type-strict) + - [Addon API is more type-strict](#addon-api-is-more-type-strict) - [From version 6.5.x to 7.0.0](#from-version-65x-to-700) - [7.0 breaking changes](#70-breaking-changes) - [Dropped support for Node 15 and below](#dropped-support-for-node-15-and-below) @@ -27,7 +29,7 @@ - [Deploying build artifacts](#deploying-build-artifacts) - [Dropped support for file URLs](#dropped-support-for-file-urls) - [Serving with nginx](#serving-with-nginx) - - [Ignore story files from node\_modules](#ignore-story-files-from-node_modules) + - [Ignore story files from node_modules](#ignore-story-files-from-node_modules) - [7.0 Core changes](#70-core-changes) - [7.0 feature flags removed](#70-feature-flags-removed) - [Story context is prepared before for supporting fine grained updates](#story-context-is-prepared-before-for-supporting-fine-grained-updates) @@ -39,7 +41,7 @@ - [Addon-interactions: Interactions debugger is now default](#addon-interactions-interactions-debugger-is-now-default) - [7.0 Vite changes](#70-vite-changes) - [Vite builder uses Vite config automatically](#vite-builder-uses-vite-config-automatically) - - [Vite cache moved to node\_modules/.cache/.vite-storybook](#vite-cache-moved-to-node_modulescachevite-storybook) + - [Vite cache moved to node_modules/.cache/.vite-storybook](#vite-cache-moved-to-node_modulescachevite-storybook) - [7.0 Webpack changes](#70-webpack-changes) - [Webpack4 support discontinued](#webpack4-support-discontinued) - [Babel mode v7 exclusively](#babel-mode-v7-exclusively) @@ -89,7 +91,7 @@ - [Dropped addon-docs manual babel configuration](#dropped-addon-docs-manual-babel-configuration) - [Dropped addon-docs manual configuration](#dropped-addon-docs-manual-configuration) - [Autoplay in docs](#autoplay-in-docs) - - [Removed STORYBOOK\_REACT\_CLASSES global](#removed-storybook_react_classes-global) + - [Removed STORYBOOK_REACT_CLASSES global](#removed-storybook_react_classes-global) - [7.0 Deprecations and default changes](#70-deprecations-and-default-changes) - [storyStoreV7 enabled by default](#storystorev7-enabled-by-default) - [`Story` type deprecated](#story-type-deprecated) @@ -302,6 +304,50 @@ - [Packages renaming](#packages-renaming) - [Deprecated embedded addons](#deprecated-embedded-addons) +## From version 7.3.0 to 7.4.0 + +#### `storyIndexers` is replaced with `experimental_indexers` + +Defining custom indexers for stories has become a more official - yet still experimental - API which is now configured at `experimental_indexers` instead of `storyIndexers` in `main.ts`. `storyIndexers` has been deprecated and will be fully removed in version 8.0.0. + +The new experimental indexers are documented [here](TODO!!!). The most notable change from `storyIndexers` is that the indexer must now return a list of [`IndexInput`](https://github.com/storybookjs/storybook/blob/next/code/lib/types/src/modules/indexer.ts#L104-L148) instead of `CsfFile`. It's possible to construct an `IndexInput` from a `CsfFile` using the `CsfFile.indexInputs` getter. + +That means you can convert an existing story indexer like this: + +```diff +// .storybook/main.ts + +import { readFileSync } from 'fs'; +import { loadCsf } from '@storybook/csf-tools'; + +export default { +- storyIndexers = (indexers) => { +- const indexer = async (fileName, opts) => { ++ experimental_indexers = (indexers) => { ++ const index = async (fileName, opts) => { + const code = readFileSync(fileName, { encoding: 'utf-8' }); + const makeTitle = (userTitle) => { + // Do something with the auto title retrieved by Storybook + return userTitle; + }; + + // Parse the CSF file with makeTitle as a custom context +- return loadCsf(code, { ...compilationOptions, makeTitle, fileName }).parse(); ++ return loadCsf(code, { ...compilationOptions, makeTitle, fileName }).parse().indexInputs; + }; + + return [ + { + test: /(stories|story)\.[tj]sx?$/, +- indexer, ++ index, + }, + ...(indexers || []), + ]; + }, +}; +``` + ## From version 7.0.0 to 7.2.0 #### Addon API is more type-strict @@ -311,6 +357,7 @@ When registering an addon using `@storybook/manager-api`, the addon API is now m The `type` property is now a required field, and the `id` property should not be set anymore. Here's a correct example: + ```tsx import { addons, types } from '@storybook/manager-api'; @@ -318,7 +365,7 @@ addons.register('my-addon', () => { addons.add('my-addon/panel', { type: types.PANEL, title: 'My Addon', - render: ({ active }) => active ?
Hello World
: null, + render: ({ active }) => (active ?
Hello World
: null), }); }); ``` @@ -869,16 +916,16 @@ Given the following `main.js`: ```js export default { - stories: ['../**/*.stories.*'] -} + stories: ['../**/*.stories.*'], +}; ``` If you want to restore the previous behavior to include `node_modules`, you can update it to: ```js export default { - stories: ['../**/*.stories.*', '../**/node_modules/**/*.stories.*'] -} + stories: ['../**/*.stories.*', '../**/node_modules/**/*.stories.*'], +}; ``` The first glob would have node_modules automatically excluded by Storybook, and the second glob would include all stories that are under a nested `node_modules` directory. From 8b81a5f3657e52384c31f6117372514e1d22026d Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Wed, 23 Aug 2023 14:03:22 +0200 Subject: [PATCH 02/11] deprecate storyIndexers --- code/lib/core-server/src/utils/StoryIndexGenerator.ts | 10 +++++----- code/lib/types/src/modules/core-common.ts | 2 +- code/lib/types/src/modules/indexer.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index d2a195a31463..7a501a95a5f0 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -25,7 +25,7 @@ import type { } from '@storybook/types'; import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/preview-api'; import { commonGlobOptions, normalizeStoryPath } from '@storybook/core-common'; -import { logger, once } from '@storybook/node-logger'; +import { deprecate, logger, once } from '@storybook/node-logger'; import { getStorySortParameter } from '@storybook/csf-tools'; import { storyNameFromExport, toId } from '@storybook/csf'; import { analyze } from '@storybook/docs-mdx'; @@ -120,10 +120,10 @@ export class StoryIndexGenerator { ) { this.specifierToCache = new Map(); if (options.storyIndexers.length > 1) { - // TODO: write migration notes before enabling this warning - // deprecate( - // "'storyIndexers' is deprecated, please use 'indexers' instead. See migration notes at XXX" - // ); + deprecate( + dedent`'storyIndexers' is deprecated, please use 'experimental_indexers' instead. + Please refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` + ); } } diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 45d94e585eb3..0f2a9f54c271 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -369,7 +369,7 @@ export interface StorybookConfig { /** * Process CSF files for the story index. - * @soonDeprecated use {@link experimental_indexers} instead + * @deprecated use {@link experimental_indexers} instead */ storyIndexers?: PresetValue; diff --git a/code/lib/types/src/modules/indexer.ts b/code/lib/types/src/modules/indexer.ts index ccd1ddaef206..5346f7d41f5a 100644 --- a/code/lib/types/src/modules/indexer.ts +++ b/code/lib/types/src/modules/indexer.ts @@ -68,7 +68,7 @@ export type Indexer = BaseIndexer & { */ index: (fileName: string, options: IndexerOptions) => Promise; /** - * @soonDeprecated Use {@link index} instead + * @deprecated Use {@link index} instead */ indexer?: never; }; @@ -79,7 +79,7 @@ export type DeprecatedIndexer = BaseIndexer & { }; /** - * @soonDeprecated Use {@link Indexer} instead + * @deprecated Use {@link Indexer} instead */ export type StoryIndexer = Indexer | DeprecatedIndexer; From 01dea7ccf7d8524fb27f56dbe33456be352ef423 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 24 Aug 2023 10:58:04 +0200 Subject: [PATCH 03/11] add deprecation warnings and migration notes for storyStoreV6 --- MIGRATION.md | 21 +++++++++++++++++++ .../src/utils/StoryIndexGenerator.ts | 8 ++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/MIGRATION.md b/MIGRATION.md index 0736a8c3e0ed..31c92a7a8ca0 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,6 +1,7 @@

Migration

- [From version 7.3.0 to 7.4.0](#from-version-730-to-740) + - [`storyStoreV6` and `storiesOf` is deprecated](#storystorev6-and-storiesof-is-deprecated) - [`storyIndexers` is replaced with `experimental_indexers`](#storyindexers-is-replaced-with-experimental_indexers) - [From version 7.0.0 to 7.2.0](#from-version-700-to-720) - [Addon API is more type-strict](#addon-api-is-more-type-strict) @@ -306,6 +307,26 @@ ## From version 7.3.0 to 7.4.0 +#### `storyStoreV6` and `storiesOf` is deprecated + +`storyStoreV6` and `storiesOf` is deprecated and will be completely removed in Storybook 8.0.0. + +If you're using `storiesOf` we recommend you migrate your stories to CSF3 for a better story writing experience. +In many cases you can get started with the migration by using two migration scripts: + +```bash + +# 1. convert storiesOf to CSF +npx storybook@latest migrate storiesof-to-csf --glob="**/*.stories.tsx" --parser=tsx + +# 2. Convert CSF 2 to CSF 3 +npx storybook@latest migrate csf-2-to-3 --glob="**/*.stories.tsx" --parser=tsx +``` + +They won't do a perfect migration so we recommend that you manually go through each file afterwards. + +Alternatively you can build your own `storiesOf` implementation by leveraging the new (experimental) indexer API ([documentation](TODO), [migration](#storyindexers-is-replaced-with-experimental_indexers)). A proof of concept of such an implementation can be seen in [this StackBlitz demo](https://stackblitz.com/edit/github-h2rgfk?file=README.md). See the demo's `README.md` for a deeper explanation of the implementation. + #### `storyIndexers` is replaced with `experimental_indexers` Defining custom indexers for stories has become a more official - yet still experimental - API which is now configured at `experimental_indexers` instead of `storyIndexers` in `main.ts`. `storyIndexers` has been deprecated and will be fully removed in version 8.0.0. diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 7a501a95a5f0..88393bde2e6a 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -122,7 +122,13 @@ export class StoryIndexGenerator { if (options.storyIndexers.length > 1) { deprecate( dedent`'storyIndexers' is deprecated, please use 'experimental_indexers' instead. - Please refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` + Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` + ); + } + if (options.storyStoreV7 === false) { + deprecate( + dedent`storyStoreV6 is deprecated, please migrate to storyStoreV7 instead. + Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystorev6-and-storiesof-is-deprecated` ); } } From 1a5e4eea04c574dd30c3c40f84f1a610319fb920 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 24 Aug 2023 11:10:37 +0200 Subject: [PATCH 04/11] move deprecation warning to build and dev --- code/lib/core-server/src/build-static.ts | 10 +++++++++- code/lib/core-server/src/dev-server.ts | 9 +++++++++ code/lib/core-server/src/utils/StoryIndexGenerator.ts | 8 +------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/code/lib/core-server/src/build-static.ts b/code/lib/core-server/src/build-static.ts index 810c871724fd..659dbf834767 100644 --- a/code/lib/core-server/src/build-static.ts +++ b/code/lib/core-server/src/build-static.ts @@ -2,7 +2,7 @@ import chalk from 'chalk'; import { copy, emptyDir, ensureDir } from 'fs-extra'; import { dirname, isAbsolute, join, resolve } from 'path'; import { global } from '@storybook/global'; -import { logger } from '@storybook/node-logger'; +import { deprecate, logger } from '@storybook/node-logger'; import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry'; import type { BuilderOptions, @@ -23,6 +23,7 @@ import { import { ConflictingStaticDirConfigError } from '@storybook/core-events/server-errors'; import isEqual from 'lodash/isEqual.js'; +import dedent from 'ts-dedent'; import { outputStats } from './utils/output-stats'; import { copyAllStaticFiles, @@ -122,6 +123,13 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption presets.apply('docs', {}), ]); + if (features?.storyStoreV7 === false) { + deprecate( + dedent`storyStoreV6 is deprecated, please migrate to storyStoreV7 instead. + - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystorev6-and-storiesof-is-deprecated` + ); + } + const fullOptions: Options = { ...options, presets, diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts index 2eb1ea420cda..2941c1a06c73 100644 --- a/code/lib/core-server/src/dev-server.ts +++ b/code/lib/core-server/src/dev-server.ts @@ -5,7 +5,9 @@ import invariant from 'tiny-invariant'; import type { CoreConfig, Options, StorybookConfig } from '@storybook/types'; import { logConfig } from '@storybook/core-common'; +import { deprecate } from '@storybook/node-logger'; +import dedent from 'ts-dedent'; import { getMiddleware } from './utils/middleware'; import { getServerAddresses } from './utils/server-address'; import { getServer } from './utils/server-init'; @@ -35,6 +37,13 @@ export async function storybookDevServer(options: Options) { getServerChannel(server) ); + if (features?.storyStoreV7 === false) { + deprecate( + dedent`storyStoreV6 is deprecated, please migrate to storyStoreV7 instead. + - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystorev6-and-storiesof-is-deprecated` + ); + } + let indexError: Error | undefined; // try get index generator, if failed, send telemetry without storyCount, then rethrow the error const initializedStoryIndexGenerator: Promise = diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 88393bde2e6a..bdcb626a3132 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -122,13 +122,7 @@ export class StoryIndexGenerator { if (options.storyIndexers.length > 1) { deprecate( dedent`'storyIndexers' is deprecated, please use 'experimental_indexers' instead. - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` - ); - } - if (options.storyStoreV7 === false) { - deprecate( - dedent`storyStoreV6 is deprecated, please migrate to storyStoreV7 instead. - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystorev6-and-storiesof-is-deprecated` + - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` ); } } From eb4d699434bd760a6833aa03e68596007335e502 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 24 Aug 2023 11:24:56 +0200 Subject: [PATCH 05/11] update docs snippets for indexers --- docs/snippets/common/storybook-main-csf-indexer.ts.mdx | 8 ++++---- .../common/storybook-main-story-indexer-main.ts.mdx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/snippets/common/storybook-main-csf-indexer.ts.mdx b/docs/snippets/common/storybook-main-csf-indexer.ts.mdx index 09f6f85f02e9..0c533f8152ee 100644 --- a/docs/snippets/common/storybook-main-csf-indexer.ts.mdx +++ b/docs/snippets/common/storybook-main-csf-indexer.ts.mdx @@ -5,16 +5,16 @@ import { readFileSync } from 'fs'; import { loadCsf } from '@storybook/csf-tools'; export default { - storyIndexers = (indexers) => { - const indexer = async (fileName, opts) => { + experimental_indexers = (indexers) => { + const index = async (fileName, opts) => { const code = readFileSync(fileName, { encoding: 'utf-8' }); - return loadCsf(code, { ...opts, fileName }).parse(); + return loadCsf(code, { ...opts, fileName }).parse().indexInputs; }; return [ { test: /(stories|story)\.[tj]sx?$/, - indexer, + index, }, ...(indexers || []), ]; diff --git a/docs/snippets/common/storybook-main-story-indexer-main.ts.mdx b/docs/snippets/common/storybook-main-story-indexer-main.ts.mdx index 7c4885028a5d..77c9363b4f62 100644 --- a/docs/snippets/common/storybook-main-story-indexer-main.ts.mdx +++ b/docs/snippets/common/storybook-main-story-indexer-main.ts.mdx @@ -9,8 +9,8 @@ import type { StorybookConfig } from '@storybook/your-framework'; import { parseCode } from './parseCode'; const config: StorybookConfig = { - storyIndexers: (indexers, addonOptions) => { - const indexer = async (fileName, compilationOptions) => { + experimental_indexers: (indexers, addonOptions) => { + const index = async (fileName, compilationOptions) => { const code = parseCode(fileName, addonOptions); const makeTitle = (userTitle) => { // Do something with the auto title retrieved by Storybook @@ -18,13 +18,13 @@ const config: StorybookConfig = { }; // Parse the CSF file with makeTitle as a custom context - return loadCsf(code, { ...compilationOptions, makeTitle, fileName }).parse(); + return loadCsf(code, { ...compilationOptions, makeTitle, fileName }).parse().indexInputs; }; return [ { test: /\.(md|html)$/, - indexer, + index, }, ...(indexers || []), ]; From b53e602e7562dca61b0d45539ad3d8f71a199a1e Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Tue, 5 Sep 2023 10:44:04 +0200 Subject: [PATCH 06/11] rename `index` to `indexFn` --- MIGRATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 31c92a7a8ca0..33268d612c97 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -345,7 +345,7 @@ export default { - storyIndexers = (indexers) => { - const indexer = async (fileName, opts) => { + experimental_indexers = (indexers) => { -+ const index = async (fileName, opts) => { ++ const indexFn = async (fileName, opts) => { const code = readFileSync(fileName, { encoding: 'utf-8' }); const makeTitle = (userTitle) => { // Do something with the auto title retrieved by Storybook @@ -361,7 +361,7 @@ export default { { test: /(stories|story)\.[tj]sx?$/, - indexer, -+ index, ++ indexFn, }, ...(indexers || []), ]; From 214b6ec65c4c4d808f0a4a5c67679d405dfea54b Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Tue, 5 Sep 2023 14:28:43 +0200 Subject: [PATCH 07/11] indexFn -> createIndex --- MIGRATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 33268d612c97..fc7c93c87ffb 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -345,7 +345,7 @@ export default { - storyIndexers = (indexers) => { - const indexer = async (fileName, opts) => { + experimental_indexers = (indexers) => { -+ const indexFn = async (fileName, opts) => { ++ const createIndex = async (fileName, opts) => { const code = readFileSync(fileName, { encoding: 'utf-8' }); const makeTitle = (userTitle) => { // Do something with the auto title retrieved by Storybook @@ -361,7 +361,7 @@ export default { { test: /(stories|story)\.[tj]sx?$/, - indexer, -+ indexFn, ++ createIndex, }, ...(indexers || []), ]; From bbe075a18ae07f15d67cede6fc048a8192498d6e Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 25 Sep 2023 05:44:59 -0500 Subject: [PATCH 08/11] deprecate storyIndexers on usage --- code/lib/core-server/src/utils/StoryIndexGenerator.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 418ba796d375..0f847b8917a1 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -119,12 +119,6 @@ export class StoryIndexGenerator { public readonly options: StoryIndexGeneratorOptions ) { this.specifierToCache = new Map(); - if (options.storyIndexers.length > 1) { - deprecate( - dedent`'storyIndexers' is deprecated, please use 'experimental_indexers' instead. - - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` - ); - } } async initialize() { @@ -298,6 +292,10 @@ export class StoryIndexGenerator { invariant(indexer, `No matching indexer found for ${absolutePath}`); if (indexer.indexer) { + deprecate( + dedent`'storyIndexers' is deprecated, please use 'experimental_indexers' instead. Found a deprecated indexer with matcher: ${indexer.test} + - Refer to the migration guide at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storyindexers-is-replaced-with-experimental_indexers` + ); return this.extractStoriesFromDeprecatedIndexer({ indexer: indexer.indexer, indexerOptions: { makeTitle: defaultMakeTitle }, From 0b7f436ac01c54342a32c5f883f57feec6a377e6 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 25 Sep 2023 05:54:50 -0500 Subject: [PATCH 09/11] add docs link to migration --- MIGRATION.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index b529325aac69..acb9780812d8 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -325,13 +325,13 @@ npx storybook@latest migrate csf-2-to-3 --glob="**/*.stories.tsx" --parser=tsx They won't do a perfect migration so we recommend that you manually go through each file afterwards. -Alternatively you can build your own `storiesOf` implementation by leveraging the new (experimental) indexer API ([documentation](TODO), [migration](#storyindexers-is-replaced-with-experimental_indexers)). A proof of concept of such an implementation can be seen in [this StackBlitz demo](https://stackblitz.com/edit/github-h2rgfk?file=README.md). See the demo's `README.md` for a deeper explanation of the implementation. +Alternatively you can build your own `storiesOf` implementation by leveraging the new (experimental) indexer API ([documentation](https://storybook.js.org/docs/react/api/main-config-indexers), [migration](#storyindexers-is-replaced-with-experimental_indexers)). A proof of concept of such an implementation can be seen in [this StackBlitz demo](https://stackblitz.com/edit/github-h2rgfk?file=README.md). See the demo's `README.md` for a deeper explanation of the implementation. #### `storyIndexers` is replaced with `experimental_indexers` Defining custom indexers for stories has become a more official - yet still experimental - API which is now configured at `experimental_indexers` instead of `storyIndexers` in `main.ts`. `storyIndexers` has been deprecated and will be fully removed in version 8.0.0. -The new experimental indexers are documented [here](TODO!!!). The most notable change from `storyIndexers` is that the indexer must now return a list of [`IndexInput`](https://github.com/storybookjs/storybook/blob/next/code/lib/types/src/modules/indexer.ts#L104-L148) instead of `CsfFile`. It's possible to construct an `IndexInput` from a `CsfFile` using the `CsfFile.indexInputs` getter. +The new experimental indexers are documented [here](https://storybook.js.org/docs/react/api/main-config-indexers). The most notable change from `storyIndexers` is that the indexer must now return a list of [`IndexInput`](https://github.com/storybookjs/storybook/blob/next/code/lib/types/src/modules/indexer.ts#L104-L148) instead of `CsfFile`. It's possible to construct an `IndexInput` from a `CsfFile` using the `CsfFile.indexInputs` getter. That means you can convert an existing story indexer like this: @@ -1114,7 +1114,7 @@ Starting in 7.0, we drop support for Angular < 14 _Has automigration_ -In Storybook 6.4 we deprecated calling Storybook directly (e.g. `npm run storybook`) for Angular. In Storybook 7.0, we've removed it entirely. Instead, you have to set up the Storybook builder in your `angular.json` and execute `ng run :storybook` to start Storybook. +In Storybook 6.4 we deprecated calling Storybook directly (e.g. `npm run storybook`) for Angular. In Storybook 7.0, we've removed it entirely. Instead, you have to set up the Storybook builder in your `angular.json` and execute `ng run :storybook` to start Storybook. You can run `npx storybook@next automigrate` to automatically fix your configuration, or visit https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular/README.md#how-do-i-migrate-to-an-angular-storybook-builder for instructions on how to set up Storybook for Angular manually. From 130154b338667957d561fac45de9d9f2c711c6a4 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 25 Sep 2023 06:00:49 -0500 Subject: [PATCH 10/11] fix migration title --- MIGRATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index acb9780812d8..767ca41326d2 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,6 +1,6 @@

Migration

-- [From version 7.3.0 to 7.4.0](#from-version-730-to-740) +- [From version 7.4.0 to 7.5.0](#from-version-740-to-750) - [`storyStoreV6` and `storiesOf` is deprecated](#storystorev6-and-storiesof-is-deprecated) - [`storyIndexers` is replaced with `experimental_indexers`](#storyindexers-is-replaced-with-experimental_indexers) - [From version 7.0.0 to 7.2.0](#from-version-700-to-720) @@ -305,7 +305,7 @@ - [Packages renaming](#packages-renaming) - [Deprecated embedded addons](#deprecated-embedded-addons) -## From version 7.3.0 to 7.4.0 +## From version 7.4.0 to 7.5.0 #### `storyStoreV6` and `storiesOf` is deprecated From 7e6b56a40559c7cdbf6563d75dca7078b5e13853 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 25 Sep 2023 06:14:24 -0500 Subject: [PATCH 11/11] add migration note about support both versions --- MIGRATION.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 767ca41326d2..1708f26a3dbe 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -369,6 +369,8 @@ export default { }; ``` +As an addon author you can support previous versions of Storybook by setting both `storyIndexers` and `indexers_experimental`, without triggering the deprecation warning. + ## From version 7.0.0 to 7.2.0 #### Addon API is more type-strict