From 924d095f07255e56a6f32a1bc70eb89658076e51 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 28 Nov 2024 14:58:04 +0100 Subject: [PATCH 1/4] Portable stories: Support multiple annotation notations from preview file --- .../store/csf/portable-stories.test.ts | 19 +++++++++++++++++++ .../modules/store/csf/portable-stories.ts | 7 ++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts index 6c85760cbd4e..24e286b3b909 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.test.ts @@ -77,6 +77,25 @@ describe('composeStory', () => { expect(composedStory.parameters.fromAnnotations.asDefaultImport).toEqual(true); }); + it('should compose project annotations when used in named and default exports from the same module', () => { + setProjectAnnotations([ + { + initialGlobals: { namedExportAnnotation: true }, + default: { + parameters: { defaultExportAnnotation: true }, + }, + }, + ]); + + const Story: Story = { + render: () => {}, + }; + + const composedStory = composeStory(Story, meta); + expect(composedStory.parameters.defaultExportAnnotation).toEqual(true); + expect(composedStory.globals.namedExportAnnotation).toEqual(true); + }); + it('should return story with composed annotations from story, meta and project', () => { const decoratorFromProjectAnnotations = vi.fn((StoryFn) => StoryFn()); const decoratorFromStoryAnnotations = vi.fn((StoryFn) => StoryFn()); diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.ts index b9efd7da9792..22b449bd98f0 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.ts @@ -61,11 +61,8 @@ function extractAnnotation( // import * as annotations from '.storybook/preview' // import annotations from '.storybook/preview' // in both cases: 1 - the file has a default export; 2 - named exports only - // support imports such as - // import * as annotations from '.storybook/preview' - // import annotations from '.storybook/preview' - // in both cases: 1 - the file has a default export; 2 - named exports only - return 'default' in annotation ? annotation.default : annotation; + // also support when the file has both annotations coming from default and named exports + return composeConfigs([annotation]); } export function setProjectAnnotations( From 9a3b90eab368606b8eb5a9a0fb8e7ef295a51993 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Wed, 27 Nov 2024 18:11:29 +0100 Subject: [PATCH 2/4] Build: Attempt to fix Vite 6 sandboxes --- scripts/tasks/sandbox-parts.ts | 3 +-- scripts/utils/yarn.ts | 12 ------------ 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/scripts/tasks/sandbox-parts.ts b/scripts/tasks/sandbox-parts.ts index 5f4991644cdf..27b73c36de4e 100644 --- a/scripts/tasks/sandbox-parts.ts +++ b/scripts/tasks/sandbox-parts.ts @@ -109,10 +109,9 @@ export const install: Task['run'] = async ({ sandboxDir, key }, { link, dryRun, 'svelte-vite/default-ts', 'vue3-vite/default-js', 'vue3-vite/default-ts', - 'svelte-kit/skeleton-ts', ]; if (sandboxesNeedingWorkarounds.includes(key) || key.includes('vite')) { - await addWorkaroundResolutions({ cwd, dryRun, debug, key }); + await addWorkaroundResolutions({ cwd, dryRun, debug }); } await exec( diff --git a/scripts/utils/yarn.ts b/scripts/utils/yarn.ts index 142432fa6354..8013083bc2a6 100644 --- a/scripts/utils/yarn.ts +++ b/scripts/utils/yarn.ts @@ -70,7 +70,6 @@ export const installYarn2 = async ({ cwd, dryRun, debug }: YarnOptions) => { export const addWorkaroundResolutions = async ({ cwd, dryRun, - key, }: YarnOptions & { key?: TemplateKey }) => { logger.info(`🔢 Adding resolutions for workarounds`); @@ -82,22 +81,11 @@ export const addWorkaroundResolutions = async ({ const packageJson = await readJSON(packageJsonPath); packageJson.resolutions = { ...packageJson.resolutions, - // Due to our support of older vite versions - '@vitejs/plugin-react': '4.2.0', - '@vitejs/plugin-vue': '4.5.0', - // TODO: Remove this once we figure out how to properly test Vite 4, 5 and 6 in our sandboxes - vite: '^5.0.0', - // We need to downgrade the plugin so that it works with Vite 5 projects - '@sveltejs/vite-plugin-svelte': '4.0.2', '@testing-library/dom': '^9.3.4', '@testing-library/jest-dom': '^6.5.0', '@testing-library/user-event': '^14.5.2', }; - if (key?.includes('svelte-kit')) { - packageJson.resolutions['@sveltejs/vite-plugin-svelte'] = '^3.0.0'; - } - await writeJSON(packageJsonPath, packageJson, { spaces: 2 }); }; From 78bdb527b17e56f608459d7ddebc3ff296f239fa Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Wed, 27 Nov 2024 18:33:34 +0100 Subject: [PATCH 3/4] React: Bump docgen version --- .../react-native-web-vite/package.json | 2 +- code/frameworks/react-vite/package.json | 2 +- code/yarn.lock | 31 ++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/code/frameworks/react-native-web-vite/package.json b/code/frameworks/react-native-web-vite/package.json index 924bc6ad9449..6932dfb0df0f 100644 --- a/code/frameworks/react-native-web-vite/package.json +++ b/code/frameworks/react-native-web-vite/package.json @@ -53,7 +53,7 @@ "prep": "jiti ../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@joshwooding/vite-plugin-react-docgen-typescript": "0.3.0", + "@joshwooding/vite-plugin-react-docgen-typescript": "0.4.2", "@storybook/builder-vite": "workspace:*", "@storybook/react": "workspace:*", "@storybook/react-vite": "workspace:*", diff --git a/code/frameworks/react-vite/package.json b/code/frameworks/react-vite/package.json index 9d8bee1852bf..7886b6dd8c30 100644 --- a/code/frameworks/react-vite/package.json +++ b/code/frameworks/react-vite/package.json @@ -47,7 +47,7 @@ "prep": "jiti ../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@joshwooding/vite-plugin-react-docgen-typescript": "0.3.0", + "@joshwooding/vite-plugin-react-docgen-typescript": "0.4.2", "@rollup/pluginutils": "^5.0.2", "@storybook/builder-vite": "workspace:*", "@storybook/react": "workspace:*", diff --git a/code/yarn.lock b/code/yarn.lock index ac6a40441400..6623d2309c32 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -4041,21 +4041,19 @@ __metadata: languageName: node linkType: hard -"@joshwooding/vite-plugin-react-docgen-typescript@npm:0.3.0": - version: 0.3.0 - resolution: "@joshwooding/vite-plugin-react-docgen-typescript@npm:0.3.0" +"@joshwooding/vite-plugin-react-docgen-typescript@npm:0.4.2": + version: 0.4.2 + resolution: "@joshwooding/vite-plugin-react-docgen-typescript@npm:0.4.2" dependencies: - glob: "npm:^7.2.0" - glob-promise: "npm:^4.2.0" magic-string: "npm:^0.27.0" react-docgen-typescript: "npm:^2.2.2" peerDependencies: typescript: ">= 4.3.x" - vite: ^3.0.0 || ^4.0.0 || ^5.0.0 + vite: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 10c0/31098ad8fcc2440437534599c111d9f2951dd74821e8ba46c521b969bae4c918d830b7bb0484efbad29a51711bb62d3bc623d5a1ed5b1695b5b5594ea9dd4ca0 + checksum: 10c0/355d13ad92a9da786b561a25250e6c94a8e51d235ced345e54ebfe709abc45ab60c2a8d06599df6ec0441fba01720f189883429943cb62dff9a4c31b59f0939c languageName: node linkType: hard @@ -7099,7 +7097,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/react-native-web-vite@workspace:frameworks/react-native-web-vite" dependencies: - "@joshwooding/vite-plugin-react-docgen-typescript": "npm:0.3.0" + "@joshwooding/vite-plugin-react-docgen-typescript": "npm:0.4.2" "@storybook/builder-vite": "workspace:*" "@storybook/react": "workspace:*" "@storybook/react-vite": "workspace:*" @@ -7120,7 +7118,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/react-vite@workspace:frameworks/react-vite" dependencies: - "@joshwooding/vite-plugin-react-docgen-typescript": "npm:0.3.0" + "@joshwooding/vite-plugin-react-docgen-typescript": "npm:0.4.2" "@rollup/pluginutils": "npm:^5.0.2" "@storybook/builder-vite": "workspace:*" "@storybook/react": "workspace:*" @@ -8292,7 +8290,7 @@ __metadata: languageName: node linkType: hard -"@types/glob@npm:^7.1.1, @types/glob@npm:^7.1.3": +"@types/glob@npm:^7.1.1": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" dependencies: @@ -16676,17 +16674,6 @@ __metadata: languageName: node linkType: hard -"glob-promise@npm:^4.2.0": - version: 4.2.2 - resolution: "glob-promise@npm:4.2.2" - dependencies: - "@types/glob": "npm:^7.1.3" - peerDependencies: - glob: ^7.1.6 - checksum: 10c0/3eb01bed2901539365df6a4d27800afb8788840647d01f9bf3500b3de756597f2ff4b8c823971ace34db228c83159beca459dc42a70968d4e9c8200ed2cc96bd - languageName: node - linkType: hard - "glob-to-regexp@npm:^0.4.1": version: 0.4.1 resolution: "glob-to-regexp@npm:0.4.1" @@ -16723,7 +16710,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0": +"glob@npm:^7.1.2, glob@npm:^7.1.3, glob@npm:^7.1.4": version: 7.2.3 resolution: "glob@npm:7.2.3" dependencies: From 1d899a363a2361a669d4f2ba36c5e5d2559215af Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Fri, 29 Nov 2024 01:28:54 +0000 Subject: [PATCH 4/4] Write changelog for 8.5.0-alpha.12 [skip ci] --- CHANGELOG.prerelease.md | 9 +++++++++ code/package.json | 3 ++- docs/versions/next.json | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.prerelease.md b/CHANGELOG.prerelease.md index 9e4b54c8bd39..cc5650e7cd88 100644 --- a/CHANGELOG.prerelease.md +++ b/CHANGELOG.prerelease.md @@ -1,3 +1,12 @@ +## 8.5.0-alpha.12 + +- Core / Addon Test: Add config UI to Testing Module - [#29708](https://github.com/storybookjs/storybook/pull/29708), thanks @ghengeveld! +- Manager: Add tags property to GroupEntry objects - [#29672](https://github.com/storybookjs/storybook/pull/29672), thanks @Sidnioulz! +- Portable stories: Support multiple annotation notations from preview - [#29733](https://github.com/storybookjs/storybook/pull/29733), thanks @yannbf! +- React: Upgrade react-docgen-typescript to support Vite 6 - [#29724](https://github.com/storybookjs/storybook/pull/29724), thanks @yannbf! +- Svelte: Support `@sveltejs/vite-plugin-svelte` v5 - [#29731](https://github.com/storybookjs/storybook/pull/29731), thanks @JReinhold! +- Toolbars: Suppress deprecation warning when using dynamic icons - [#29545](https://github.com/storybookjs/storybook/pull/29545), thanks @ValeraS! + ## 8.5.0-alpha.11 - Core + Addon Test: Refactor test API and fix total test count - [#29656](https://github.com/storybookjs/storybook/pull/29656), thanks @ghengeveld! diff --git a/code/package.json b/code/package.json index d51950ae932c..3c7041bf1339 100644 --- a/code/package.json +++ b/code/package.json @@ -293,5 +293,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "8.5.0-alpha.12" } diff --git a/docs/versions/next.json b/docs/versions/next.json index 5d1664859ce0..93e33c6aed45 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.5.0-alpha.11","info":{"plain":"- Core + Addon Test: Refactor test API and fix total test count - [#29656](https://github.com/storybookjs/storybook/pull/29656), thanks @ghengeveld!\n- Core: Emit deprecated `TESTING_MODULE_RUN_ALL_REQUEST` for backward compatibility - [#29711](https://github.com/storybookjs/storybook/pull/29711), thanks @ghengeveld!\n- Frameworks: Add Vite 6 support - [#29710](https://github.com/storybookjs/storybook/pull/29710), thanks @yannbf!\n- TestAddon: Refactor UI & add config options - [#29662](https://github.com/storybookjs/storybook/pull/29662), thanks @ndelangen!\n- Vue: Fix `vue-component-meta` docgen HMR not working - [#29518](https://github.com/storybookjs/storybook/pull/29518), thanks @IonianPlayboy!"}} +{"version":"8.5.0-alpha.12","info":{"plain":"- Core / Addon Test: Add config UI to Testing Module - [#29708](https://github.com/storybookjs/storybook/pull/29708), thanks @ghengeveld!\n- Manager: Add tags property to GroupEntry objects - [#29672](https://github.com/storybookjs/storybook/pull/29672), thanks @Sidnioulz!\n- Portable stories: Support multiple annotation notations from preview - [#29733](https://github.com/storybookjs/storybook/pull/29733), thanks @yannbf!\n- React: Upgrade react-docgen-typescript to support Vite 6 - [#29724](https://github.com/storybookjs/storybook/pull/29724), thanks @yannbf!\n- Svelte: Support `@sveltejs/vite-plugin-svelte` v5 - [#29731](https://github.com/storybookjs/storybook/pull/29731), thanks @JReinhold!\n- Toolbars: Suppress deprecation warning when using dynamic icons - [#29545](https://github.com/storybookjs/storybook/pull/29545), thanks @ValeraS!"}}