From 89ed2e37b95a8e29327a8b41a306f5abc14d49eb Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Thu, 1 Feb 2024 03:24:36 +0000 Subject: [PATCH 1/9] Update ./docs/versions/next.json for v8.0.0-alpha.17 --- docs/versions/next.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versions/next.json b/docs/versions/next.json index 5cafa5e5cdea..05542e26f3d1 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.0.0-alpha.16","info":{"plain":"- CLI: Fix `upgrade` detecting the wrong version of existing Storybooks - [#25752](https://github.com/storybookjs/storybook/pull/25752), thanks [@JReinhold](https://github.com/JReinhold)!\n- CLI: Update init for react native v7 - [#25780](https://github.com/storybookjs/storybook/pull/25780), thanks [@dannyhw](https://github.com/dannyhw)!\n- UI: Improve how the addon panel work on mobile - [#25787](https://github.com/storybookjs/storybook/pull/25787), thanks [@cdedreuille](https://github.com/cdedreuille)!"}} +{"version":"8.0.0-alpha.17","info":{"plain":"- CLI: Fix add command for non monorepo deps - [#25791](https://github.com/storybookjs/storybook/pull/25791), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n- Core: Fix `--test` must be passed for `build.test` values to be set. - [#25828](https://github.com/storybookjs/storybook/pull/25828), thanks [@ndelangen](https://github.com/ndelangen)!\n- Test: Fix vitest patch to work with portable stories and upgrade testing-library/jest-dom - [#25840](https://github.com/storybookjs/storybook/pull/25840), thanks [@kasperpeulen](https://github.com/kasperpeulen)!\n- UI: Fix sidebar top and bottom addons not showing - [#25825](https://github.com/storybookjs/storybook/pull/25825), thanks [@ndelangen](https://github.com/ndelangen)!\n- Webpack: Update StorybookConfig import in core-webpack types.ts - [#25740](https://github.com/storybookjs/storybook/pull/25740), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!"}} From 617e48f86372ec037c18b790f56e3607da8fba54 Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:38:50 +0000 Subject: [PATCH 2/9] Update ./docs/versions/next.json for v8.0.0-beta.0 --- docs/versions/next.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versions/next.json b/docs/versions/next.json index 05542e26f3d1..f183795f3f3e 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.0.0-alpha.17","info":{"plain":"- CLI: Fix add command for non monorepo deps - [#25791](https://github.com/storybookjs/storybook/pull/25791), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n- Core: Fix `--test` must be passed for `build.test` values to be set. - [#25828](https://github.com/storybookjs/storybook/pull/25828), thanks [@ndelangen](https://github.com/ndelangen)!\n- Test: Fix vitest patch to work with portable stories and upgrade testing-library/jest-dom - [#25840](https://github.com/storybookjs/storybook/pull/25840), thanks [@kasperpeulen](https://github.com/kasperpeulen)!\n- UI: Fix sidebar top and bottom addons not showing - [#25825](https://github.com/storybookjs/storybook/pull/25825), thanks [@ndelangen](https://github.com/ndelangen)!\n- Webpack: Update StorybookConfig import in core-webpack types.ts - [#25740](https://github.com/storybookjs/storybook/pull/25740), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!"}} +{"version":"8.0.0-beta.0","info":{"plain":"- CLI: Add Visual Tests addon to `init` - [#25850](https://github.com/storybookjs/storybook/pull/25850), thanks [@shilman](https://github.com/shilman)!\n- CLI: Upgrade boxen library - [#25713](https://github.com/storybookjs/storybook/pull/25713), thanks [@yannbf](https://github.com/yannbf)!\n- UI: Fix custom tabs not showing in the manager - [#25792](https://github.com/storybookjs/storybook/pull/25792), thanks [@ndelangen](https://github.com/ndelangen)!"}} From 2a6a501da55544d916626b72eb9d4c8bd24983fc Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Sat, 3 Feb 2024 20:49:55 +0000 Subject: [PATCH 3/9] fix: errors on react native when running compose story --- code/lib/preview-api/src/modules/preview-web/UrlStore.ts | 2 +- code/lib/preview-api/src/modules/preview-web/WebView.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts index 16d66ba7f6b6..f69e6b520f96 100644 --- a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts +++ b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts @@ -65,7 +65,7 @@ const getFirstString = (v: ValueOf): string | void => { }; export const getSelectionSpecifierFromPath: () => SelectionSpecifier | null = () => { - const query = qs.parse(document.location.search, { ignoreQueryPrefix: true }); + const query = qs.parse(document?.location?.search, { ignoreQueryPrefix: true }); const args = typeof query.args === 'string' ? parseArgsParam(query.args) : undefined; const globals = typeof query.globals === 'string' ? parseArgsParam(query.globals) : undefined; diff --git a/code/lib/preview-api/src/modules/preview-web/WebView.ts b/code/lib/preview-api/src/modules/preview-web/WebView.ts index 6f02568934c3..eefa4f007856 100644 --- a/code/lib/preview-api/src/modules/preview-web/WebView.ts +++ b/code/lib/preview-api/src/modules/preview-web/WebView.ts @@ -47,7 +47,7 @@ export class WebView implements View { constructor() { // Special code for testing situations // eslint-disable-next-line @typescript-eslint/naming-convention - const { __SPECIAL_TEST_PARAMETER__ } = qs.parse(document.location.search, { + const { __SPECIAL_TEST_PARAMETER__ } = qs.parse(document?.location?.search, { ignoreQueryPrefix: true, }); switch (__SPECIAL_TEST_PARAMETER__) { From 4606346401edbe24c22211dfc0d09fd90b3b9c06 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Sun, 4 Feb 2024 07:53:59 +0800 Subject: [PATCH 4/9] Merge pull request #25895 from storybookjs/dannyhw/adjust-rn-init (cherry picked from commit 39cc4da9dfbc3d9bc2ec70a564c2977ade7908fb) --- code/lib/cli/src/generators/REACT_NATIVE/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/code/lib/cli/src/generators/REACT_NATIVE/index.ts b/code/lib/cli/src/generators/REACT_NATIVE/index.ts index c2d18fb84d82..80230cdc690b 100644 --- a/code/lib/cli/src/generators/REACT_NATIVE/index.ts +++ b/code/lib/cli/src/generators/REACT_NATIVE/index.ts @@ -47,7 +47,6 @@ const generator = async ( packageManager.addScripts({ 'storybook-generate': 'sb-rn-get-stories', - 'storybook-watch': 'sb-rn-watcher', }); const storybookConfigFolder = '.storybook'; From 71ed2166017286dd955ce64fc79d4ef7b18e1f43 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 5 Feb 2024 14:56:55 +0100 Subject: [PATCH 5/9] Merge pull request #25908 from storybookjs/dannyhw/fix-rn-init-existing-package React Native: Fix init fails when package is already installed (cherry picked from commit 985505a1b2263f535e9402b8d8fa190a1f4b3fec) --- code/lib/cli/src/generators/REACT_NATIVE/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/lib/cli/src/generators/REACT_NATIVE/index.ts b/code/lib/cli/src/generators/REACT_NATIVE/index.ts index 80230cdc690b..bb245cd1839b 100644 --- a/code/lib/cli/src/generators/REACT_NATIVE/index.ts +++ b/code/lib/cli/src/generators/REACT_NATIVE/index.ts @@ -14,12 +14,15 @@ const generator = async ( const reactVersion = packageJson.dependencies.react; - const packagesToResolve = [ - // addon-ondevice-controls peer deps + const controlsPeerDependencies = [ 'react-native-safe-area-context', '@react-native-async-storage/async-storage', '@react-native-community/datetimepicker', '@react-native-community/slider', + ].filter((dep) => !packageJson.dependencies[dep] && !packageJson.devDependencies[dep]); + + const packagesToResolve = [ + ...controlsPeerDependencies, '@storybook/addon-ondevice-controls', '@storybook/addon-ondevice-actions', '@storybook/react-native', From 2f353e5248456f561cd09a7855295137e0910128 Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:24:29 +0000 Subject: [PATCH 6/9] Write changelog for 7.6.13 [skip ci] --- CHANGELOG.md | 7 +++++++ code/package.json | 3 ++- docs/versions/latest.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1a25029e92c..918bef245067 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 7.6.13 + +- Next.js: Fix frameworkOptions resolution - [#25907](https://github.com/storybookjs/storybook/pull/25907), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)! +- React Native: Fix init fails when package is already installed - [#25908](https://github.com/storybookjs/storybook/pull/25908), thanks [@dannyhw](https://github.com/dannyhw)! +- React Native: Remove watcher from init - [#25895](https://github.com/storybookjs/storybook/pull/25895), thanks [@dannyhw](https://github.com/dannyhw)! +- Webpack: Update StorybookConfig import in core-webpack types.ts - [#25740](https://github.com/storybookjs/storybook/pull/25740), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)! + ## 7.6.12 - CLI: Fix `upgrade` detecting the wrong version of existing Storybooks - [#25752](https://github.com/storybookjs/storybook/pull/25752), thanks [@JReinhold](https://github.com/JReinhold)! diff --git a/code/package.json b/code/package.json index 98ae6df4db46..ee6bf8363bdd 100644 --- a/code/package.json +++ b/code/package.json @@ -329,5 +329,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "7.6.13" } diff --git a/docs/versions/latest.json b/docs/versions/latest.json index 1f2574bd8083..454fbba1c4c0 100644 --- a/docs/versions/latest.json +++ b/docs/versions/latest.json @@ -1 +1 @@ -{"version":"7.6.12","info":{"plain":"- CLI: Fix `upgrade` detecting the wrong version of existing Storybooks - [#25752](https://github.com/storybookjs/storybook/pull/25752), thanks [@JReinhold](https://github.com/JReinhold)!"}} +{"version":"7.6.13","info":{"plain":"- Next.js: Fix frameworkOptions resolution - [#25907](https://github.com/storybookjs/storybook/pull/25907), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!\n- React Native: Fix init fails when package is already installed - [#25908](https://github.com/storybookjs/storybook/pull/25908), thanks [@dannyhw](https://github.com/dannyhw)!\n- React Native: Remove watcher from init - [#25895](https://github.com/storybookjs/storybook/pull/25895), thanks [@dannyhw](https://github.com/dannyhw)!\n- Webpack: Update StorybookConfig import in core-webpack types.ts - [#25740](https://github.com/storybookjs/storybook/pull/25740), thanks [@valentinpalkovic](https://github.com/valentinpalkovic)!"}} From a63a4f4674cd97f5d6076cb96d09a365984f2642 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 6 Feb 2024 21:46:52 +0800 Subject: [PATCH 7/9] Merge pull request #25740 from storybookjs/valentin/fix-storybook-config-typing-for-webpack-projects Webpack: Update StorybookConfig import in core-webpack types.ts (cherry picked from commit a91240a3ba7cd784f5fbdea6152c3cf70381e78d) --- code/builders/builder-webpack5/src/types.ts | 5 ++- code/frameworks/angular/src/preset.ts | 6 +-- code/frameworks/ember/src/preset.ts | 35 ++++++++++++++- code/frameworks/html-vite/src/preset.ts | 3 +- code/frameworks/nextjs/src/preset.ts | 35 +-------------- code/frameworks/preact-vite/src/preset.ts | 2 +- code/frameworks/react-vite/src/preset.ts | 2 +- code/frameworks/react-webpack5/src/preset.ts | 44 +++---------------- code/frameworks/svelte-vite/src/preset.ts | 2 +- code/frameworks/vue3-webpack5/src/preset.ts | 5 +-- .../web-components-vite/src/preset.ts | 3 +- 11 files changed, 53 insertions(+), 89 deletions(-) diff --git a/code/builders/builder-webpack5/src/types.ts b/code/builders/builder-webpack5/src/types.ts index 93b2c3ad9caf..69ef6edf66bb 100644 --- a/code/builders/builder-webpack5/src/types.ts +++ b/code/builders/builder-webpack5/src/types.ts @@ -3,11 +3,12 @@ import type { Options, BuilderResult as BuilderResultBase, StorybookConfig, + TypescriptOptions as WebpackTypescriptOptions, } from '@storybook/core-webpack'; import type ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; -type TypeScriptOptionsBase = Required['typescript']; +type TypeScriptOptionsBase = Partial; /** * Options for TypeScript usage within Storybook. @@ -19,7 +20,7 @@ export interface TypescriptOptions extends TypeScriptOptionsBase { checkOptions?: ConstructorParameters[0]; } -export interface StorybookConfigWebpack extends Pick { +export interface StorybookConfigWebpack extends Omit { /** * Modify or return a custom Webpack config after the Storybook's default configuration * has run (mostly used by addons). diff --git a/code/frameworks/angular/src/preset.ts b/code/frameworks/angular/src/preset.ts index f093cb6cc8b8..9bf25db2a767 100644 --- a/code/frameworks/angular/src/preset.ts +++ b/code/frameworks/angular/src/preset.ts @@ -25,8 +25,8 @@ export const previewAnnotations: StorybookConfig['previewAnnotations'] = ( return annotations; }; -export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { - const framework = await options.presets.apply('framework'); +export const core: PresetProperty<'core'> = async (config, options) => { + const framework = await options.presets.apply('framework'); return { ...config, @@ -37,7 +37,7 @@ export const core: PresetProperty<'core', StorybookConfig> = async (config, opti }; }; -export const typescript: PresetProperty<'typescript', StorybookConfig> = async (config) => { +export const typescript: PresetProperty<'typescript'> = async (config) => { return { ...config, skipBabel: true, diff --git a/code/frameworks/ember/src/preset.ts b/code/frameworks/ember/src/preset.ts index 6524132780e5..f94f0caea350 100644 --- a/code/frameworks/ember/src/preset.ts +++ b/code/frameworks/ember/src/preset.ts @@ -10,8 +10,39 @@ export const addons: PresetProperty<'addons', StorybookConfig> = [ require.resolve('./server/framework-preset-ember-docs'), ]; -export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { - const framework = await options.presets.apply('framework'); +export const webpackFinal: StorybookConfig['webpackFinal'] = async (baseConfig, options) => { + const { virtualModules } = await getVirtualModules(options); + + const babelOptions = await options.presets.apply('babel', {}, options); + const typescriptOptions = await options.presets.apply('typescript', {}, options); + + return { + ...baseConfig, + module: { + ...baseConfig.module, + rules: [ + ...(baseConfig.module?.rules ?? []), + { + test: typescriptOptions.skipCompiler ? /\.((c|m)?jsx?)$/ : /\.((c|m)?(j|t)sx?)$/, + use: [ + { + loader: require.resolve('babel-loader'), + options: { + cacheDirectory: resolvePathInStorybookCache('babel'), + ...babelOptions, + }, + }, + ], + include: [getProjectRoot()], + exclude: [/node_modules/, ...Object.keys(virtualModules)], + }, + ], + }, + }; +}; + +export const core: PresetProperty<'core'> = async (config, options) => { + const framework = await options.presets.apply('framework'); return { ...config, diff --git a/code/frameworks/html-vite/src/preset.ts b/code/frameworks/html-vite/src/preset.ts index 4ae871b6e589..965ba77956a0 100644 --- a/code/frameworks/html-vite/src/preset.ts +++ b/code/frameworks/html-vite/src/preset.ts @@ -1,12 +1,11 @@ import type { PresetProperty } from '@storybook/types'; import { dirname, join } from 'path'; -import type { StorybookConfig } from './types'; function getAbsolutePath(value: I): I { return dirname(require.resolve(join(value, 'package.json'))) as any; } -export const core: PresetProperty<'core', StorybookConfig> = { +export const core: PresetProperty<'core'> = { builder: getAbsolutePath('@storybook/builder-vite'), renderer: getAbsolutePath('@storybook/html'), }; diff --git a/code/frameworks/nextjs/src/preset.ts b/code/frameworks/nextjs/src/preset.ts index e4fdd7936fb9..17172c10ff55 100644 --- a/code/frameworks/nextjs/src/preset.ts +++ b/code/frameworks/nextjs/src/preset.ts @@ -23,38 +23,8 @@ export const addons: PresetProperty<'addons', StorybookConfig> = [ dirname(require.resolve(join('@storybook/preset-react-webpack', 'package.json'))), ]; -const defaultFrameworkOptions: FrameworkOptions = {}; - -export const frameworkOptions = async ( - _: never, - options: Options -): Promise => { - const config = await options.presets.apply('framework'); - - if (typeof config === 'string') { - return { - name: config, - options: defaultFrameworkOptions, - }; - } - if (typeof config === 'undefined') { - return { - name: require.resolve('@storybook/nextjs') as '@storybook/nextjs', - options: defaultFrameworkOptions, - }; - } - - return { - name: config.name, - options: { - ...defaultFrameworkOptions, - ...config.options, - }, - }; -}; - -export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { - const framework = await options.presets.apply('framework'); +export const core: PresetProperty<'core'> = async (config, options) => { + const framework = await options.presets.apply('framework'); return { ...config, @@ -134,7 +104,6 @@ export const babel = async (baseConfig: TransformOptions): Promise { - // eslint-disable-next-line @typescript-eslint/no-shadow const frameworkOptions = await options.presets.apply<{ options: FrameworkOptions }>( 'frameworkOptions' ); diff --git a/code/frameworks/preact-vite/src/preset.ts b/code/frameworks/preact-vite/src/preset.ts index 2d4e18d77e90..188ffcde2f5d 100644 --- a/code/frameworks/preact-vite/src/preset.ts +++ b/code/frameworks/preact-vite/src/preset.ts @@ -7,7 +7,7 @@ import type { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -export const core: PresetProperty<'core', StorybookConfig> = { +export const core: PresetProperty<'core'> = { builder: getAbsolutePath('@storybook/builder-vite'), renderer: getAbsolutePath('@storybook/preact'), }; diff --git a/code/frameworks/react-vite/src/preset.ts b/code/frameworks/react-vite/src/preset.ts index 207f60988ebc..1d8584db4548 100644 --- a/code/frameworks/react-vite/src/preset.ts +++ b/code/frameworks/react-vite/src/preset.ts @@ -7,7 +7,7 @@ import type { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -export const core: PresetProperty<'core', StorybookConfig> = { +export const core: PresetProperty<'core'> = { builder: getAbsolutePath('@storybook/builder-vite'), renderer: getAbsolutePath('@storybook/react'), }; diff --git a/code/frameworks/react-webpack5/src/preset.ts b/code/frameworks/react-webpack5/src/preset.ts index 873d214c597c..d28fe9f6cf20 100644 --- a/code/frameworks/react-webpack5/src/preset.ts +++ b/code/frameworks/react-webpack5/src/preset.ts @@ -1,8 +1,6 @@ -/* eslint-disable no-param-reassign */ - import { dirname, join } from 'path'; -import type { PresetProperty, Options } from '@storybook/types'; -import type { FrameworkOptions, StorybookConfig } from './types'; +import type { PresetProperty } from '@storybook/types'; +import type { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; @@ -11,40 +9,8 @@ export const addons: PresetProperty<'addons', StorybookConfig> = [ getAbsolutePath('@storybook/preset-react-webpack'), ]; -const defaultFrameworkOptions: FrameworkOptions = { - legacyRootApi: true, -}; - -export const frameworkOptions = async ( - _: never, - options: Options -): Promise => { - const config = await options.presets.apply('framework'); - - if (typeof config === 'string') { - return { - name: config, - options: defaultFrameworkOptions, - }; - } - if (typeof config === 'undefined') { - return { - name: getAbsolutePath('@storybook/react-webpack5'), - options: defaultFrameworkOptions, - }; - } - - return { - name: config.name, - options: { - ...defaultFrameworkOptions, - ...config.options, - }, - }; -}; - -export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { - const framework = await options.presets.apply('framework'); +export const core: PresetProperty<'core'> = async (config, options) => { + const framework = await options.presets.apply('framework'); return { ...config, @@ -57,8 +23,10 @@ export const core: PresetProperty<'core', StorybookConfig> = async (config, opti }; export const webpack: StorybookConfig['webpack'] = async (config) => { + // eslint-disable-next-line no-param-reassign config.resolve = config.resolve || {}; + // eslint-disable-next-line no-param-reassign config.resolve.alias = { ...config.resolve?.alias, '@storybook/react': getAbsolutePath('@storybook/react'), diff --git a/code/frameworks/svelte-vite/src/preset.ts b/code/frameworks/svelte-vite/src/preset.ts index 220812cf7c5a..de3b5f2383e2 100644 --- a/code/frameworks/svelte-vite/src/preset.ts +++ b/code/frameworks/svelte-vite/src/preset.ts @@ -8,7 +8,7 @@ import { svelteDocgen } from './plugins/svelte-docgen'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -export const core: PresetProperty<'core', StorybookConfig> = { +export const core: PresetProperty<'core'> = { builder: getAbsolutePath('@storybook/builder-vite'), renderer: getAbsolutePath('@storybook/svelte'), }; diff --git a/code/frameworks/vue3-webpack5/src/preset.ts b/code/frameworks/vue3-webpack5/src/preset.ts index 1714cc16075e..5e58a1ece98c 100644 --- a/code/frameworks/vue3-webpack5/src/preset.ts +++ b/code/frameworks/vue3-webpack5/src/preset.ts @@ -1,13 +1,10 @@ import { dirname, join } from 'path'; import type { PresetProperty } from '@storybook/types'; -import type { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -export const addons: PresetProperty<'addons', StorybookConfig> = [ - getAbsolutePath('@storybook/preset-vue3-webpack'), -]; +export const addons: PresetProperty<'addons'> = [getAbsolutePath('@storybook/preset-vue3-webpack')]; export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { const framework = await options.presets.apply('framework'); diff --git a/code/frameworks/web-components-vite/src/preset.ts b/code/frameworks/web-components-vite/src/preset.ts index a3bb7c4d66a2..2edf8f450c75 100644 --- a/code/frameworks/web-components-vite/src/preset.ts +++ b/code/frameworks/web-components-vite/src/preset.ts @@ -1,11 +1,10 @@ import type { PresetProperty } from '@storybook/types'; import { dirname, join } from 'path'; -import type { StorybookConfig } from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -export const core: PresetProperty<'core', StorybookConfig> = { +export const core: PresetProperty<'core'> = { builder: getAbsolutePath('@storybook/builder-vite'), renderer: getAbsolutePath('@storybook/web-components'), }; From 1801d3da86a25f5526f1eb0d5e151f48bd2d2899 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Mon, 5 Feb 2024 12:59:31 +0100 Subject: [PATCH 8/9] Merge pull request #25907 from storybookjs/valentin/fix-framework-options-resolution-nextjs Next.js: Fix frameworkOptions resolution (cherry picked from commit dda22268517d1c4aba870bd55b557616a8b87463) --- code/frameworks/nextjs/src/preset.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/frameworks/nextjs/src/preset.ts b/code/frameworks/nextjs/src/preset.ts index 17172c10ff55..e974503ae0d9 100644 --- a/code/frameworks/nextjs/src/preset.ts +++ b/code/frameworks/nextjs/src/preset.ts @@ -104,10 +104,7 @@ export const babel = async (baseConfig: TransformOptions): Promise { - const frameworkOptions = await options.presets.apply<{ options: FrameworkOptions }>( - 'frameworkOptions' - ); - const { options: { nextConfigPath, builder } = {} } = frameworkOptions; + const { nextConfigPath } = await options.presets.apply('frameworkOptions'); const nextConfig = await configureConfig({ baseConfig, nextConfigPath, From fdd7a22a5c37fa58052803243ba39a417d97a449 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 6 Feb 2024 23:29:51 +0800 Subject: [PATCH 9/9] Fix TS errors --- code/frameworks/ember/src/preset.ts | 2 ++ code/frameworks/nextjs/src/preset.ts | 7 +++++-- code/frameworks/vue3-webpack5/src/preset.ts | 6 +++--- code/lib/types/src/modules/core-common.ts | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/code/frameworks/ember/src/preset.ts b/code/frameworks/ember/src/preset.ts index f94f0caea350..747cf0cecfae 100644 --- a/code/frameworks/ember/src/preset.ts +++ b/code/frameworks/ember/src/preset.ts @@ -1,4 +1,6 @@ import { dirname, join } from 'path'; +import { getVirtualModules } from '@storybook/builder-webpack5'; +import { getProjectRoot, resolvePathInStorybookCache } from '@storybook/core-common'; import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; diff --git a/code/frameworks/nextjs/src/preset.ts b/code/frameworks/nextjs/src/preset.ts index e974503ae0d9..1d6df2b1567c 100644 --- a/code/frameworks/nextjs/src/preset.ts +++ b/code/frameworks/nextjs/src/preset.ts @@ -1,6 +1,6 @@ // https://storybook.js.org/docs/react/addons/writing-presets import { dirname, join } from 'path'; -import type { Options, PresetProperty } from '@storybook/types'; +import type { PresetProperty } from '@storybook/types'; import type { ConfigItem, PluginItem, TransformOptions } from '@babel/core'; import { loadPartialConfig } from '@babel/core'; import { getProjectRoot } from '@storybook/core-common'; @@ -104,7 +104,10 @@ export const babel = async (baseConfig: TransformOptions): Promise { - const { nextConfigPath } = await options.presets.apply('frameworkOptions'); + const { builder, nextConfigPath } = await options.presets.apply( + 'frameworkOptions' + ); + const nextConfig = await configureConfig({ baseConfig, nextConfigPath, diff --git a/code/frameworks/vue3-webpack5/src/preset.ts b/code/frameworks/vue3-webpack5/src/preset.ts index 5e58a1ece98c..3cbc05b096e7 100644 --- a/code/frameworks/vue3-webpack5/src/preset.ts +++ b/code/frameworks/vue3-webpack5/src/preset.ts @@ -6,8 +6,8 @@ const getAbsolutePath = (input: I): I => export const addons: PresetProperty<'addons'> = [getAbsolutePath('@storybook/preset-vue3-webpack')]; -export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { - const framework = await options.presets.apply('framework'); +export const core: PresetProperty<'core'> = async (config, options) => { + const framework = await options.presets.apply('framework'); return { ...config, @@ -19,7 +19,7 @@ export const core: PresetProperty<'core', StorybookConfig> = async (config, opti }; }; -export const typescript: PresetProperty<'typescript', StorybookConfig> = async (config) => ({ +export const typescript: PresetProperty<'typescript'> = async (config) => ({ ...config, skipBabel: true, skipCompiler: true, diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 2f7077fc5d88..b11f673d0156 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -67,9 +67,9 @@ interface DirectoryMapping { export interface Presets { apply( extension: 'typescript', - config: TypescriptOptions, + config: Partial, args?: Options - ): Promise; + ): Promise>; apply(extension: 'framework', config?: {}, args?: any): Promise; apply(extension: 'babel', config?: {}, args?: any): Promise; apply(extension: 'swc', config?: {}, args?: any): Promise;