From a80b47cf255c25e6af4207cab4f07626fdfdfcc2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 1 Nov 2023 17:59:32 +0100 Subject: [PATCH] remove all references of storyStoreV7 --- .../src/codegen-importfn-script.ts | 4 - .../src/plugins/code-generator-plugin.ts | 15 +- .../src/preview/iframe-webpack.config.ts | 81 ++------ code/lib/cli/src/sandbox-templates.ts | 2 +- .../core-server/src/__for-testing__/main.ts | 3 - code/lib/core-server/src/build-static.ts | 11 +- code/lib/core-server/src/dev-server.ts | 7 - .../core-server/src/presets/common-preset.ts | 1 - .../StoryIndexGenerator.deprecated.test.ts | 2 - .../src/utils/StoryIndexGenerator.test.ts | 2 - .../src/utils/StoryIndexGenerator.ts | 43 +---- .../utils/__tests__/index-extraction.test.ts | 1 - .../src/utils/getStoryIndexGenerator.ts | 6 - .../src/utils/stories-json.test.ts | 177 ------------------ code/lib/csf-tools/src/CsfFile.ts | 3 +- code/lib/manager-api/src/modules/stories.ts | 6 +- .../lib/manager-api/src/tests/stories.test.ts | 2 +- .../src/modules/client-api/ClientApi.ts | 9 - .../modules/client-api/StoryStoreFacade.ts | 7 +- .../src/modules/core-client/start.test.ts | 7 +- .../src/modules/core-client/start.ts | 107 +---------- .../src/modules/preview-web/Preview.tsx | 18 +- .../PreviewWeb.integration.test.ts | 4 +- .../modules/preview-web/PreviewWeb.test.ts | 5 +- .../preview-web/PreviewWithSelection.tsx | 34 ++-- .../telemetry/src/storybook-metadata.test.ts | 4 +- code/lib/types/src/modules/core-common.ts | 5 - .../src/components/preview/Preview.tsx | 2 +- code/ui/manager/src/runtime.ts | 2 +- scripts/event-log-checker.ts | 20 -- scripts/tasks/test-runner-build.ts | 5 - test-storybooks/ember-cli/.storybook/main.js | 1 - .../external-docs/.storybook/main.cjs | 1 - .../server-kitchen-sink/.storybook/main.ts | 4 +- 34 files changed, 66 insertions(+), 535 deletions(-) diff --git a/code/builders/builder-vite/src/codegen-importfn-script.ts b/code/builders/builder-vite/src/codegen-importfn-script.ts index 5df14d875f25..39ee3e2d42ef 100644 --- a/code/builders/builder-vite/src/codegen-importfn-script.ts +++ b/code/builders/builder-vite/src/codegen-importfn-script.ts @@ -28,11 +28,7 @@ function toImportPath(relativePath: string) { async function toImportFn(stories: string[]) { const { normalizePath } = await import('vite'); const objectEntries = stories.map((file) => { - const ext = path.extname(file); const relativePath = normalizePath(path.relative(process.cwd(), file)); - if (!['.js', '.jsx', '.ts', '.tsx', '.mdx', '.svelte', '.vue'].includes(ext)) { - logger.warn(`Cannot process ${ext} file with storyStoreV7: ${relativePath}`); - } return ` '${toImportPath(relativePath)}': async () => import('/@fs/${file}')`; }); diff --git a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts index c27d7c73ea4a..52399c744768 100644 --- a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts +++ b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts @@ -90,27 +90,16 @@ export function codeGeneratorPlugin(options: Options): Plugin { return undefined; }, async load(id, config) { - const storyStoreV7 = options.features?.storyStoreV7; if (id === virtualStoriesFile) { - if (storyStoreV7) { - return generateImportFnScriptCode(options); - } - return generateVirtualStoryEntryCode(options); + return generateImportFnScriptCode(options); } if (id === virtualAddonSetupFile) { return generateAddonSetupCode(); } - if (id === virtualPreviewFile && !storyStoreV7) { - return generatePreviewEntryCode(options); - } - if (id === virtualFileId) { - if (storyStoreV7) { - return generateModernIframeScriptCode(options, projectRoot); - } - return generateIframeScriptCode(options, projectRoot); + return generateModernIframeScriptCode(options, projectRoot); } if (id === iframeId) { diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index 55e0d733aa9e..a1a820b1b6e2 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -13,16 +13,14 @@ import type { Options, CoreConfig, DocsOptions, PreviewAnnotation } from '@story import { globals } from '@storybook/preview/globals'; import { getBuilderOptions, - getRendererName, stringifyProcessEnvs, handlebars, - interpolate, normalizeStories, readTemplate, loadPreviewOrConfigFile, isPreservingSymlinks, } from '@storybook/core-common'; -import { toRequireContextString, toImportFn } from '@storybook/core-webpack'; +import { toImportFn } from '@storybook/core-webpack'; import { dedent } from 'ts-dedent'; import type { BuilderOptions, TypescriptOptions } from '../types'; import { createBabelLoader, createSWCLoader } from './loaders'; @@ -132,68 +130,25 @@ export default async ( ].filter(Boolean); const virtualModuleMapping: Record = {}; - if (features?.storyStoreV7) { - const storiesFilename = 'storybook-stories.js'; - const storiesPath = resolve(join(workingDir, storiesFilename)); + const storiesFilename = 'storybook-stories.js'; + const storiesPath = resolve(join(workingDir, storiesFilename)); - const needPipelinedImport = !!builderOptions.lazyCompilation && !isProd; - virtualModuleMapping[storiesPath] = toImportFn(stories, { needPipelinedImport }); - const configEntryPath = resolve(join(workingDir, 'storybook-config-entry.js')); - virtualModuleMapping[configEntryPath] = handlebars( - await readTemplate( - require.resolve( - '@storybook/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars' - ) - ), - { - storiesFilename, - previewAnnotations, - } - // We need to double escape `\` for webpack. We may have some in windows paths - ).replace(/\\/g, '\\\\'); - entries.push(configEntryPath); - } else { - const rendererName = await getRendererName(options); - - const rendererInitEntry = resolve(join(workingDir, 'storybook-init-renderer-entry.js')); - virtualModuleMapping[rendererInitEntry] = `import '${slash(rendererName)}';`; - entries.push(rendererInitEntry); - - const entryTemplate = await readTemplate( - join(__dirname, '..', '..', 'templates', 'virtualModuleEntry.template.js') - ); - - previewAnnotations.forEach((previewAnnotationFilename: string | undefined) => { - if (!previewAnnotationFilename) return; - - // Ensure that relative paths end up mapped to a filename in the cwd, so a later import - // of the `previewAnnotationFilename` in the template works. - const entryFilename = previewAnnotationFilename.startsWith('.') - ? `${previewAnnotationFilename.replace(/(\w)(\/|\\)/g, '$1-')}-generated-config-entry.js` - : `${previewAnnotationFilename}-generated-config-entry.js`; - // NOTE: although this file is also from the `dist/cjs` directory, it is actually a ESM - // file, see https://github.com/storybookjs/storybook/pull/16727#issuecomment-986485173 - virtualModuleMapping[entryFilename] = interpolate(entryTemplate, { - previewAnnotationFilename, - }); - entries.push(entryFilename); - }); - if (stories.length > 0) { - const storyTemplate = await readTemplate( - join(__dirname, '..', '..', 'templates', 'virtualModuleStory.template.js') - ); - // NOTE: this file has a `.cjs` extension as it is a CJS file (from `dist/cjs`) and runs - // in the user's webpack mode, which may be strict about the use of require/import. - // See https://github.com/storybookjs/storybook/issues/14877 - const storiesFilename = resolve(join(workingDir, `generated-stories-entry.cjs`)); - virtualModuleMapping[storiesFilename] = interpolate(storyTemplate, { - rendererName, - }) - // Make sure we also replace quotes for this one - .replace("'{{stories}}'", stories.map(toRequireContextString).join(',')); - entries.push(storiesFilename); + const needPipelinedImport = !!builderOptions.lazyCompilation && !isProd; + virtualModuleMapping[storiesPath] = toImportFn(stories, { needPipelinedImport }); + const configEntryPath = resolve(join(workingDir, 'storybook-config-entry.js')); + virtualModuleMapping[configEntryPath] = handlebars( + await readTemplate( + require.resolve( + '@storybook/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars' + ) + ), + { + storiesFilename, + previewAnnotations, } - } + // We need to double escape `\` for webpack. We may have some in windows paths + ).replace(/\\/g, '\\\\'); + entries.push(configEntryPath); const shouldCheckTs = typescriptOptions.check && !typescriptOptions.skipBabel; const tsCheckOptions = typescriptOptions.checkOptions || {}; diff --git a/code/lib/cli/src/sandbox-templates.ts b/code/lib/cli/src/sandbox-templates.ts index 88190caaa6b1..e5cb876472d1 100644 --- a/code/lib/cli/src/sandbox-templates.ts +++ b/code/lib/cli/src/sandbox-templates.ts @@ -62,7 +62,7 @@ export type Template = { inDevelopment?: boolean; /** * Some sandboxes might need extra modifications in the initialized Storybook, - * such as extend main.js, for setting specific feature flags like storyStoreV7, etc. + * such as extend main.js, for setting specific feature flags. */ modifications?: { skipTemplateStories?: boolean; diff --git a/code/lib/core-server/src/__for-testing__/main.ts b/code/lib/core-server/src/__for-testing__/main.ts index 988f5ba319fd..2643a4582bd5 100644 --- a/code/lib/core-server/src/__for-testing__/main.ts +++ b/code/lib/core-server/src/__for-testing__/main.ts @@ -29,9 +29,6 @@ const config: StorybookConfig = { disableTelemetry: true, }, logLevel: 'debug', - features: { - storyStoreV7: false, - }, framework: { name: '@storybook/react-webpack5', options: { diff --git a/code/lib/core-server/src/build-static.ts b/code/lib/core-server/src/build-static.ts index 55dc59fbaac1..d2c63f033efe 100644 --- a/code/lib/core-server/src/build-static.ts +++ b/code/lib/core-server/src/build-static.ts @@ -124,13 +124,6 @@ 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, @@ -164,7 +157,7 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption let initializedStoryIndexGenerator: Promise = Promise.resolve(undefined); - if ((features?.buildStoriesJson || features?.storyStoreV7) && !options.ignorePreview) { + if (features?.buildStoriesJson && !options.ignorePreview) { const workingDir = process.cwd(); const directories = { configDir: options.configDir, @@ -176,8 +169,6 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption storyIndexers: deprecatedStoryIndexers, indexers, docs: docsOptions, - storiesV2Compatibility: !features?.storyStoreV7, - storyStoreV7: !!features?.storyStoreV7, }); initializedStoryIndexGenerator = generator.initialize().then(() => generator); diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts index 1e8de546880e..97993a1dcc17 100644 --- a/code/lib/core-server/src/dev-server.ts +++ b/code/lib/core-server/src/dev-server.ts @@ -38,13 +38,6 @@ 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/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index 39511aef6be4..fa548c3a2c0e 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -191,7 +191,6 @@ export const features = async ( ...existing, warnOnLegacyHierarchySeparator: true, buildStoriesJson: false, - storyStoreV7: true, argTypeTargetsV7: true, legacyDecoratorFileOrder: false, }); diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts index 60d700bad62e..e86119accda2 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.deprecated.test.ts @@ -53,8 +53,6 @@ const options: StoryIndexGeneratorOptions = { { test: /\.stories\.(m?js|ts)x?$/, indexer: csfIndexer }, ], indexers: [], - storiesV2Compatibility: false, - storyStoreV7: true, docs: { defaultName: 'docs', autodocs: false }, }; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index fad7090789fe..f11b584e67f2 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -48,8 +48,6 @@ const options: StoryIndexGeneratorOptions = { workingDir: path.join(__dirname, '__mockdata__'), storyIndexers: [], indexers: [csfIndexer, createStoriesMdxIndexer(false)], - storiesV2Compatibility: false, - storyStoreV7: true, docs: { defaultName: 'docs', autodocs: false }, }; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 0f847b8917a1..584f3098af76 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -53,8 +53,6 @@ type SpecifierStoriesCache = Record; export type StoryIndexGeneratorOptions = { workingDir: Path; configDir: Path; - storiesV2Compatibility: boolean; - storyStoreV7: boolean; storyIndexers: StoryIndexer[]; indexers: Indexer[]; docs: DocsOptions; @@ -429,11 +427,6 @@ export class StoryIndexGenerator { async extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); try { - invariant( - this.options.storyStoreV7, - `You cannot use \`.mdx\` files without using \`storyStoreV7\`.` - ); - const normalizedPath = normalizeStoryPath(relativePath); const importPath = slash(normalizedPath); @@ -613,13 +606,9 @@ export class StoryIndexGenerator { async sortStories(entries: StoryIndex['entries']) { const sortableStories = Object.values(entries); - // Skip sorting if we're in v6 mode because we don't have - // all the info we need here - if (this.options.storyStoreV7) { - const storySortParameter = await this.getStorySortParameter(); - const fileNameOrder = this.storyFileNames(); - sortStoriesV7(sortableStories, storySortParameter, fileNameOrder); - } + const storySortParameter = await this.getStorySortParameter(); + const fileNameOrder = this.storyFileNames(); + sortStoriesV7(sortableStories, storySortParameter, fileNameOrder); return sortableStories.reduce((acc, item) => { acc[item.id] = item; @@ -659,31 +648,7 @@ export class StoryIndexGenerator { const sorted = await this.sortStories(indexEntries); - let compat = sorted; - if (this.options.storiesV2Compatibility) { - const titleToStoryCount = Object.values(sorted).reduce((acc, story) => { - acc[story.title] = (acc[story.title] || 0) + 1; - return acc; - }, {} as Record); - - // @ts-expect-error (Converted from ts-ignore) - compat = Object.entries(sorted).reduce((acc, entry) => { - const [id, story] = entry; - if (story.type === 'docs') return acc; - - acc[id] = { - ...story, - kind: story.title, - story: story.name, - parameters: { - __id: story.id, - docsOnly: titleToStoryCount[story.title] === 1 && story.name === 'Page', - fileName: story.importPath, - }, - }; - return acc; - }, {} as Record); - } + const compat = sorted; this.lastIndex = { v: 4, diff --git a/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts b/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts index 39820b3e2c17..84ff37e2219e 100644 --- a/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts +++ b/code/lib/core-server/src/utils/__tests__/index-extraction.test.ts @@ -19,7 +19,6 @@ const options: StoryIndexGeneratorOptions = { storyIndexers: [], indexers: [], storiesV2Compatibility: false, - storyStoreV7: true, docs: { defaultName: 'docs', autodocs: false }, }; diff --git a/code/lib/core-server/src/utils/getStoryIndexGenerator.ts b/code/lib/core-server/src/utils/getStoryIndexGenerator.ts index 952edb507824..ba0a15ae642a 100644 --- a/code/lib/core-server/src/utils/getStoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/getStoryIndexGenerator.ts @@ -8,16 +8,12 @@ import { router } from './router'; export async function getStoryIndexGenerator( features: { buildStoriesJson?: boolean; - storyStoreV7?: boolean; argTypeTargetsV7?: boolean; warnOnLegacyHierarchySeparator?: boolean; }, options: Options, serverChannel: ServerChannel ): Promise { - if (!features?.buildStoriesJson && !features?.storyStoreV7) { - return undefined; - } const workingDir = process.cwd(); const directories = { configDir: options.configDir, @@ -35,8 +31,6 @@ export async function getStoryIndexGenerator( indexers: await indexers, docs: await docsOptions, workingDir, - storiesV2Compatibility: !features?.storyStoreV7, - storyStoreV7: features.storyStoreV7 ?? false, }); const initializedStoryIndexGenerator = generator.initialize().then(() => generator); diff --git a/code/lib/core-server/src/utils/stories-json.test.ts b/code/lib/core-server/src/utils/stories-json.test.ts index e1f0b1f6d613..2936f4689d36 100644 --- a/code/lib/core-server/src/utils/stories-json.test.ts +++ b/code/lib/core-server/src/utils/stories-json.test.ts @@ -49,8 +49,6 @@ const getInitializedStoryIndexGenerator = async ( indexers: [csfIndexer, createStoriesMdxIndexer(false)], configDir: workingDir, workingDir, - storiesV2Compatibility: false, - storyStoreV7: true, docs: { defaultName: 'docs', autodocs: false }, ...overrides, }; @@ -710,181 +708,6 @@ describe('useStoriesJson', () => { `); }); - it('disallows .mdx files without storyStoreV7', async () => { - const mockServerChannel = { emit: jest.fn() } as any as ServerChannel; - useStoriesJson({ - router, - initializedStoryIndexGenerator: getInitializedStoryIndexGenerator({ - storyStoreV7: false, - }), - workingDir, - serverChannel: mockServerChannel, - normalizedStories, - }); - - expect(use).toHaveBeenCalledTimes(2); - const route = use.mock.calls[1][1]; - - await route(request, response); - - expect(send).toHaveBeenCalledTimes(1); - expect(send.mock.calls[0][0]).toMatchInlineSnapshot(` - "Unable to index files: - - ./src/docs2/ComponentReference.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`. - - ./src/docs2/MetaOf.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`. - - ./src/docs2/NoTitle.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`. - - ./src/docs2/SecondMetaOf.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`. - - ./src/docs2/Template.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`. - - ./src/docs2/Title.mdx: Invariant failed: You cannot use \`.mdx\` files without using \`storyStoreV7\`." - `); - }); - - it('allows disabling storyStoreV7 if no .mdx files are used', async () => { - const mockServerChannel = { emit: jest.fn() } as any as ServerChannel; - useStoriesJson({ - router, - initializedStoryIndexGenerator: getInitializedStoryIndexGenerator( - { storyStoreV7: false }, - normalizedStories.slice(0, 1) - ), - workingDir, - serverChannel: mockServerChannel, - normalizedStories, - }); - - expect(use).toHaveBeenCalledTimes(2); - const route = use.mock.calls[1][1]; - - await route(request, response); - - expect(send).toHaveBeenCalledTimes(1); - expect(JSON.parse(send.mock.calls[0][0])).toMatchInlineSnapshot(` - Object { - "stories": Object { - "a--story-one": Object { - "id": "a--story-one", - "importPath": "./src/A.stories.js", - "kind": "A", - "name": "Story One", - "parameters": Object { - "__id": "a--story-one", - "docsOnly": false, - "fileName": "./src/A.stories.js", - }, - "story": "Story One", - "tags": Array [ - "component-tag", - "story-tag", - "story", - ], - "title": "A", - }, - "b--story-one": Object { - "id": "b--story-one", - "importPath": "./src/B.stories.ts", - "kind": "B", - "name": "Story One", - "parameters": Object { - "__id": "b--story-one", - "docsOnly": false, - "fileName": "./src/B.stories.ts", - }, - "story": "Story One", - "tags": Array [ - "autodocs", - "story", - ], - "title": "B", - }, - "d--story-one": Object { - "id": "d--story-one", - "importPath": "./src/D.stories.jsx", - "kind": "D", - "name": "Story One", - "parameters": Object { - "__id": "d--story-one", - "docsOnly": false, - "fileName": "./src/D.stories.jsx", - }, - "story": "Story One", - "tags": Array [ - "autodocs", - "story", - ], - "title": "D", - }, - "first-nested-deeply-f--story-one": Object { - "id": "first-nested-deeply-f--story-one", - "importPath": "./src/first-nested/deeply/F.stories.js", - "kind": "first-nested/deeply/F", - "name": "Story One", - "parameters": Object { - "__id": "first-nested-deeply-f--story-one", - "docsOnly": false, - "fileName": "./src/first-nested/deeply/F.stories.js", - }, - "story": "Story One", - "tags": Array [ - "story", - ], - "title": "first-nested/deeply/F", - }, - "h--story-one": Object { - "id": "h--story-one", - "importPath": "./src/H.stories.mjs", - "kind": "H", - "name": "Story One", - "parameters": Object { - "__id": "h--story-one", - "docsOnly": false, - "fileName": "./src/H.stories.mjs", - }, - "story": "Story One", - "tags": Array [ - "autodocs", - "story", - ], - "title": "H", - }, - "nested-button--story-one": Object { - "id": "nested-button--story-one", - "importPath": "./src/nested/Button.stories.ts", - "kind": "nested/Button", - "name": "Story One", - "parameters": Object { - "__id": "nested-button--story-one", - "docsOnly": false, - "fileName": "./src/nested/Button.stories.ts", - }, - "story": "Story One", - "tags": Array [ - "component-tag", - "story", - ], - "title": "nested/Button", - }, - "second-nested-g--story-one": Object { - "id": "second-nested-g--story-one", - "importPath": "./src/second-nested/G.stories.ts", - "kind": "second-nested/G", - "name": "Story One", - "parameters": Object { - "__id": "second-nested-g--story-one", - "docsOnly": false, - "fileName": "./src/second-nested/G.stories.ts", - }, - "story": "Story One", - "tags": Array [ - "story", - ], - "title": "second-nested/G", - }, - }, - "v": 3, - } - `); - }); - it('can handle simultaneous access', async () => { const mockServerChannel = { emit: jest.fn() } as any as ServerChannel; diff --git a/code/lib/csf-tools/src/CsfFile.ts b/code/lib/csf-tools/src/CsfFile.ts index 15ab39abdc45..83d33d598857 100644 --- a/code/lib/csf-tools/src/CsfFile.ts +++ b/code/lib/csf-tools/src/CsfFile.ts @@ -455,8 +455,7 @@ export class CsfFile { throw new Error(dedent` Unexpected \`storiesOf\` usage: ${formatLocation(node, self._fileName)}. - In SB7, we use the next-generation \`storyStoreV7\` by default, which does not support \`storiesOf\`. - More info, with details about how to opt-out here: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystorev7-enabled-by-default + SB8 does not support \`storiesOf\`. `); } }, diff --git a/code/lib/manager-api/src/modules/stories.ts b/code/lib/manager-api/src/modules/stories.ts index 795f9460b108..ad32444d39fd 100644 --- a/code/lib/manager-api/src/modules/stories.ts +++ b/code/lib/manager-api/src/modules/stories.ts @@ -818,10 +818,8 @@ export const init: ModuleFn = ({ filters: config?.sidebar?.filters || {}, }, init: async () => { - if (FEATURES?.storyStoreV7) { - provider.channel.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex()); - await api.fetchIndex(); - } + provider.channel.on(STORY_INDEX_INVALIDATED, () => api.fetchIndex()); + await api.fetchIndex(); }, }; }; diff --git a/code/lib/manager-api/src/tests/stories.test.ts b/code/lib/manager-api/src/tests/stories.test.ts index 76213e10be25..36afdbd14a72 100644 --- a/code/lib/manager-api/src/tests/stories.test.ts +++ b/code/lib/manager-api/src/tests/stories.test.ts @@ -40,7 +40,7 @@ jest.mock('@storybook/global', () => ({ global: { ...globalThis, fetch: jest.fn(() => ({ json: () => ({ v: 4, entries: mockGetEntries() }) })), - FEATURES: { storyStoreV7: true }, + FEATURES: {}, CONFIG_TYPE: 'DEVELOPMENT', }, })); diff --git a/code/lib/preview-api/src/modules/client-api/ClientApi.ts b/code/lib/preview-api/src/modules/client-api/ClientApi.ts index f022ae4203b2..78c793923a56 100644 --- a/code/lib/preview-api/src/modules/client-api/ClientApi.ts +++ b/code/lib/preview-api/src/modules/client-api/ClientApi.ts @@ -1,6 +1,5 @@ /* eslint-disable no-underscore-dangle */ -import { dedent } from 'ts-dedent'; import { global } from '@storybook/global'; import type { Args, @@ -37,14 +36,6 @@ const warningAlternatives = { }; const checkMethod = (method: keyof typeof warningAlternatives) => { - if (global.FEATURES?.storyStoreV7) { - throw new Error( - dedent`You cannot use \`${method}\` with the new Story Store. - - ${warningAlternatives[method]}` - ); - } - if (!global.__STORYBOOK_CLIENT_API__) { throw new Error(`Singleton client API not yet initialized, cannot call \`${method}\`.`); } diff --git a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts index ccd95120b45c..72e33ff2e64a 100644 --- a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts +++ b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts @@ -142,14 +142,11 @@ export class StoryStoreFacade { if (fileName.match(/\.mdx$/) && !fileName.match(/\.stories\.mdx$/)) { if (global.FEATURES?.storyStoreV7MdxErrors !== false) { throw new Error(dedent` - Cannot index \`.mdx\` file (\`${fileName}\`) in \`storyStoreV7: false\` mode. + Cannot index \`.mdx\` file (\`${fileName}\`) in SB8. The legacy story store does not support new-style \`.mdx\` files. If the file above is not intended to be indexed (i.e. displayed as an entry in the sidebar), either - exclude it from your \`stories\` glob, or add to it. - - If you wanted to index the file, you'll need to name it \`stories.mdx\` and stick to the - legacy (6.x) MDX API, or use the new store.`); + exclude it from your \`stories\` glob, or add to it.`); } } diff --git a/code/lib/preview-api/src/modules/core-client/start.test.ts b/code/lib/preview-api/src/modules/core-client/start.test.ts index aa304d2ba883..670102982d18 100644 --- a/code/lib/preview-api/src/modules/core-client/start.test.ts +++ b/code/lib/preview-api/src/modules/core-client/start.test.ts @@ -568,14 +568,11 @@ describe('start', () => { await waitForEvents([CONFIG_ERROR]); expect(mockChannel.emit.mock.calls.find((call) => call[0] === CONFIG_ERROR)?.[1]) .toMatchInlineSnapshot(` - [Error: Cannot index \`.mdx\` file (\`./Introduction.mdx\`) in \`storyStoreV7: false\` mode. + [Error: Cannot index \`.mdx\` file (\`./Introduction.mdx\`) in SB8. The legacy story store does not support new-style \`.mdx\` files. If the file above is not intended to be indexed (i.e. displayed as an entry in the sidebar), either - exclude it from your \`stories\` glob, or add to it. - - If you wanted to index the file, you'll need to name it \`stories.mdx\` and stick to the - legacy (6.x) MDX API, or use the new store.] + exclude it from your \`stories\` glob, or add to it.] `); }); }); diff --git a/code/lib/preview-api/src/modules/core-client/start.ts b/code/lib/preview-api/src/modules/core-client/start.ts index 3b527da4cd1a..a66c63a48bca 100644 --- a/code/lib/preview-api/src/modules/core-client/start.ts +++ b/code/lib/preview-api/src/modules/core-client/start.ts @@ -1,19 +1,10 @@ -/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */ +/* eslint-disable @typescript-eslint/naming-convention */ import { global } from '@storybook/global'; -import type { Renderer, ArgsStoryFn, Path, ProjectAnnotations } from '@storybook/types'; -import { createBrowserChannel } from '@storybook/channels'; -import { FORCE_RE_RENDER } from '@storybook/core-events'; -import { addons } from '../../addons'; -import { PreviewWeb } from '../../preview-web'; -import { ClientApi } from '../../client-api'; - -import { executeLoadableForChanges } from './executeLoadable'; -import type { Loadable } from './executeLoadable'; - -const { FEATURES } = global; +import type { Renderer, ArgsStoryFn, ProjectAnnotations } from '@storybook/types'; +import type { ClientApi } from '../../client-api'; const removedApi = (name: string) => () => { - throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`); + throw new Error(`@storybook/client-api:${name} was removed in SB8.`); }; interface CoreClient_RendererImplementation { @@ -78,93 +69,11 @@ export function start( global.IS_STORYBOOK = true; } - if (FEATURES?.storyStoreV7) { - return { - forceReRender: removedApi('forceReRender'), - configure: removedApi('configure'), - clientApi: { - raw: removedApi('raw'), - }, - }; - } - - const channel = createBrowserChannel({ page: 'preview' }); - addons.setChannel(channel); - - const clientApi = global?.__STORYBOOK_CLIENT_API__ || new ClientApi(); - const preview = global?.__STORYBOOK_PREVIEW__ || new PreviewWeb(); - let initialized = false; - - const importFn = (path: Path) => clientApi.importFn(path); - function onStoriesChanged() { - const storyIndex = clientApi.getStoryIndex(); - preview.onStoriesChanged({ storyIndex, importFn }); - } - - // These two bits are a bit ugly, but due to dependencies, `ClientApi` cannot have - // direct reference to `PreviewWeb`, so we need to patch in bits - clientApi.onImportFnChanged = onStoriesChanged; - clientApi.storyStore = preview.storyStore; - - if (global) { - global.__STORYBOOK_CLIENT_API__ = clientApi; - global.__STORYBOOK_ADDONS_CHANNEL__ = channel; - global.__STORYBOOK_PREVIEW__ = preview; - global.__STORYBOOK_STORY_STORE__ = preview.storyStore; - } - return { - forceReRender: () => channel.emit(FORCE_RE_RENDER), - - clientApi, - // This gets called each time the user calls configure (i.e. once per HMR) - // The first time, it constructs the preview, subsequently it updates it - configure( - renderer: string, - loadable: Loadable, - m?: NodeModule, - disableBackwardCompatibility = true - ) { - if (disableBackwardCompatibility) { - throw new Error('unexpected configure() call'); - } - - clientApi.addParameters({ renderer }); - - // We need to run the `executeLoadableForChanges` function *inside* the `getProjectAnnotations - // function in case it throws. So we also need to process its output there also - const getProjectAnnotations = () => { - const { added, removed } = executeLoadableForChanges(loadable, m); - clientApi._loadAddedExports(); - - Array.from(added.entries()).forEach(([fileName, fileExports]) => - clientApi.facade.addStoriesFromExports(fileName, fileExports) - ); - - Array.from(removed.entries()).forEach(([fileName]) => - clientApi.facade.clearFilenameExports(fileName) - ); - - return { - render, - ...clientApi.facade.projectAnnotations, - renderToCanvas, - applyDecorators: decorateStory, - }; - }; - - if (!initialized) { - preview.initialize({ - getStoryIndex: () => clientApi.getStoryIndex(), - importFn, - getProjectAnnotations, - }); - initialized = true; - } else { - // TODO -- why don't we care about the new annotations? - getProjectAnnotations(); - onStoriesChanged(); - } + forceReRender: removedApi('forceReRender'), + configure: removedApi('configure'), + clientApi: { + raw: removedApi('raw'), }, }; } diff --git a/code/lib/preview-api/src/modules/preview-web/Preview.tsx b/code/lib/preview-api/src/modules/preview-web/Preview.tsx index 638cf8126b61..bd5a92e41a2d 100644 --- a/code/lib/preview-api/src/modules/preview-web/Preview.tsx +++ b/code/lib/preview-api/src/modules/preview-web/Preview.tsx @@ -61,7 +61,7 @@ export class Preview { previewEntryError?: Error; constructor(protected channel: Channel = addons.getChannel()) { - if (global.FEATURES?.storyStoreV7 && addons.hasServerChannel()) { + if (addons.hasServerChannel()) { this.serverChannel = addons.getServerChannel(); } this.storyStore = new StoryStore(); @@ -142,15 +142,7 @@ export class Preview { this.setInitialGlobals(); - let storyIndexPromise: Promise; - if (global.FEATURES?.storyStoreV7) { - storyIndexPromise = this.getStoryIndexFromServer(); - } else { - if (!this.getStoryIndex) { - throw new Error('No `getStoryIndex` passed defined in v6 mode'); - } - storyIndexPromise = SynchronousPromise.resolve().then(this.getStoryIndex); - } + const storyIndexPromise: Promise = this.getStoryIndexFromServer(); return storyIndexPromise .then((storyIndex: StoryIndex) => this.initializeWithStoryIndex(storyIndex)) @@ -192,7 +184,7 @@ export class Preview { return this.storyStore.initialize({ storyIndex, importFn: this.importFn, - cache: !global.FEATURES?.storyStoreV7, + cache: false, }); } @@ -368,9 +360,7 @@ export class Preview { Do you have an error in your \`preview.js\`? Check your Storybook's browser console for errors.`); } - if (global.FEATURES?.storyStoreV7) { - await this.storyStore.cacheAllCSFFiles(); - } + await this.storyStore.cacheAllCSFFiles(); return this.storyStore.extract(options); } diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts index 91d2cd35ae3e..038635366a31 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts @@ -44,9 +44,7 @@ jest.mock('@storybook/global', () => ({ search: '?id=*', }, }, - FEATURES: { - storyStoreV7: true, - }, + FEATURES: {}, fetch: async () => ({ status: 200, json: async () => mockStoryIndex }), }, })); diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts index 8123020b86bb..5caf2055bde0 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts @@ -69,10 +69,7 @@ jest.mock('@storybook/global', () => ({ search: '?id=*', }, }, - FEATURES: { - storyStoreV7: true, - // xxx - }, + FEATURES: {}, fetch: async () => mockFetchResult, }, })); diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx b/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx index 73b58cc70ead..f6c4d2e63dd7 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx @@ -117,9 +117,7 @@ export class PreviewWithSelection extends Preview { return super.initializeWithStoryIndex(storyIndex).then(() => { - if (!global.FEATURES?.storyStoreV7) { - this.channel.emit(SET_INDEX, this.storyStore.getSetIndexPayload()); - } + this.channel.emit(SET_INDEX, this.storyStore.getSetIndexPayload()); return this.selectSpecifiedStory(); }); @@ -204,9 +202,7 @@ export class PreviewWithSelection extends Preview extends Preview extends Preview extends Preview { }); test('should return user specified features', async () => { - const features = { - storyStoreV7: true, - }; + const features = {}; const result = await computeStorybookMetadata({ packageJson: packageJsonMock, diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 0f2a9f54c271..6308d6b02f22 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -279,11 +279,6 @@ export interface StorybookConfig { */ buildStoriesJson?: boolean; - /** - * Activate on demand story store - */ - storyStoreV7?: boolean; - /** * Do not throw errors if using `.mdx` files in SSv7 * (for internal use in sandboxes) diff --git a/code/ui/manager/src/components/preview/Preview.tsx b/code/ui/manager/src/components/preview/Preview.tsx index 7096c1d9bf47..6d9707e73a5f 100644 --- a/code/ui/manager/src/components/preview/Preview.tsx +++ b/code/ui/manager/src/components/preview/Preview.tsx @@ -160,7 +160,7 @@ const Canvas: FC<{ withLoader: boolean; baseUrl: string; children?: never }> = ( const [progress, setProgress] = useState(undefined); useEffect(() => { - if (FEATURES?.storyStoreV7 && global.CONFIG_TYPE === 'DEVELOPMENT') { + if (global.CONFIG_TYPE === 'DEVELOPMENT') { try { const channel = addons.getServerChannel(); diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts index 861fc3b88fcb..8c565be5b1c8 100644 --- a/code/ui/manager/src/runtime.ts +++ b/code/ui/manager/src/runtime.ts @@ -34,7 +34,7 @@ class ReactProvider extends Provider { this.channel = channel; global.__STORYBOOK_ADDONS_CHANNEL__ = channel; - if (FEATURES?.storyStoreV7 && CONFIG_TYPE === 'DEVELOPMENT') { + if (CONFIG_TYPE === 'DEVELOPMENT') { this.serverChannel = this.channel; addons.setServerChannel(this.serverChannel); } diff --git a/scripts/event-log-checker.ts b/scripts/event-log-checker.ts index e1f6d82bd533..72d3177dcd44 100644 --- a/scripts/event-log-checker.ts +++ b/scripts/event-log-checker.ts @@ -60,26 +60,6 @@ async function run() { assert.equal(bootEvent.payload?.eventType, eventType); }); - // Test only StoryStoreV7 projects, as ssv6 does not support the storyIndex - if (template.modifications?.mainConfig?.features?.storyStoreV7 !== false) { - const { exampleStoryCount, exampleDocsCount } = mainEvent.payload?.storyIndex || {}; - if (['build', 'dev'].includes(eventType)) { - test(`${eventType} event should contain 8 stories and 3 docs entries`, () => { - assert.equal( - exampleStoryCount, - 8, - `Expected 8 stories but received ${exampleStoryCount} instead.` - ); - const expectedDocsCount = template.modifications?.disableDocs ? 0 : 3; - assert.equal( - exampleDocsCount, - expectedDocsCount, - `Expected ${expectedDocsCount} docs entries but received ${exampleDocsCount} instead.` - ); - }); - } - } - test(`main event should be ${eventType} and contain correct id and session id`, () => { assert.equal(mainEvent.eventType, eventType); assert.notEqual(mainEvent.eventId, bootEvent.eventId); diff --git a/scripts/tasks/test-runner-build.ts b/scripts/tasks/test-runner-build.ts index b57d4c803233..b5d1a399f9b7 100644 --- a/scripts/tasks/test-runner-build.ts +++ b/scripts/tasks/test-runner-build.ts @@ -19,11 +19,6 @@ export const testRunnerBuild: Task & { port: number } = { '--failOnConsole', ]; - // index-json mode is only supported in ssv7 - if (template.modifications?.mainConfig?.features?.storyStoreV7 !== false) { - flags.push('--index-json'); - } - await exec( `yarn test-storybook ${flags.join(' ')}`, { diff --git a/test-storybooks/ember-cli/.storybook/main.js b/test-storybooks/ember-cli/.storybook/main.js index 1552c8dfd1f1..f8becd9be286 100644 --- a/test-storybooks/ember-cli/.storybook/main.js +++ b/test-storybooks/ember-cli/.storybook/main.js @@ -45,7 +45,6 @@ module.exports = { staticDirs: ['../ember-output'], features: { buildStoriesJson: false, - storyStoreV7: false, }, framework: { name: '@storybook/ember' }, }; diff --git a/test-storybooks/external-docs/.storybook/main.cjs b/test-storybooks/external-docs/.storybook/main.cjs index fbe15b8582ac..4aed5ba024ff 100644 --- a/test-storybooks/external-docs/.storybook/main.cjs +++ b/test-storybooks/external-docs/.storybook/main.cjs @@ -20,7 +20,6 @@ const config = { channelOptions: { allowFunction: false, maxDepth: 10 }, }, features: { - storyStoreV7: !global.navigator?.userAgent?.match?.('jsdom'), buildStoriesJson: true, warnOnLegacyHierarchySeparator: false, previewMdx2: true, diff --git a/test-storybooks/server-kitchen-sink/.storybook/main.ts b/test-storybooks/server-kitchen-sink/.storybook/main.ts index 7854dd0349f5..3334ddd63d08 100644 --- a/test-storybooks/server-kitchen-sink/.storybook/main.ts +++ b/test-storybooks/server-kitchen-sink/.storybook/main.ts @@ -15,9 +15,7 @@ const mainConfig: StorybookConfig = { core: { disableTelemetry: true, }, - features: { - storyStoreV7: false, - }, + features: {}, framework: '@storybook/server-webpack5', };