From 580fcf769a52037d76178d55dd180f012f71fbe1 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 19 Jun 2023 19:32:09 +0800 Subject: [PATCH] fix(storybook): fix typescript v5 capability issue (#4002) --- .changeset/purple-dogs-know.md | 8 +++++++ packages/cli/plugin-storybook/package.json | 5 +++-- .../cli/plugin-storybook/template/main.tmpl | 6 +++++ pnpm-lock.yaml | 22 +++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .changeset/purple-dogs-know.md diff --git a/.changeset/purple-dogs-know.md b/.changeset/purple-dogs-know.md new file mode 100644 index 000000000000..2eafaf366344 --- /dev/null +++ b/.changeset/purple-dogs-know.md @@ -0,0 +1,8 @@ +--- +'@modern-js/plugin-storybook': patch +--- + +fix(storybook): fix typescript v5 capability issue + +fix(storybook): 修复与 typescript v5 的兼容问题 + diff --git a/packages/cli/plugin-storybook/package.json b/packages/cli/plugin-storybook/package.json index e32a01743e53..1d7d2f992886 100644 --- a/packages/cli/plugin-storybook/package.json +++ b/packages/cli/plugin-storybook/package.json @@ -60,12 +60,13 @@ "@storybook/core": "6.5.12", "@storybook/manager-webpack5": "6.5.12", "@storybook/react": "6.5.12", + "@swc/helpers": "0.5.1", "esbuild": "0.15.7", "findup-sync": "^4.0.0", "fs-extra": "^10.0.0", "process.argv": "^0.6.0", - "tsconfig-paths-webpack-plugin": "4.0.0", - "@swc/helpers": "0.5.1" + "react-docgen-typescript-plugin": "1.0.5", + "tsconfig-paths-webpack-plugin": "4.0.0" }, "devDependencies": { "@babel/core": "^7.21.8", diff --git a/packages/cli/plugin-storybook/template/main.tmpl b/packages/cli/plugin-storybook/template/main.tmpl index 0e1a291863d8..b1726106ed53 100644 --- a/packages/cli/plugin-storybook/template/main.tmpl +++ b/packages/cli/plugin-storybook/template/main.tmpl @@ -43,6 +43,12 @@ module.exports = { }, ...(userMainConfig.addons || []), ], + // Fix typescript v5 capability issue + // https://github.com/hipstersmoothie/react-docgen-typescript-plugin/issues/78 + // https://github.com/storybookjs/storybook/issues/21642 + typescript: { + reactDocgen: 'react-docgen-typescript-plugin' + }, webpackFinal: async (config, options) => { // change webpack config const { customFinalWebpack = () => config } = options; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe3aec80d4f0..2ff255c47852 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1618,6 +1618,9 @@ importers: process.argv: specifier: ^0.6.0 version: 0.6.0 + react-docgen-typescript-plugin: + specifier: 1.0.5 + version: 1.0.5(typescript@5.0.4)(webpack@5.82.1) tsconfig-paths-webpack-plugin: specifier: 4.0.0 version: 4.0.0 @@ -29172,6 +29175,25 @@ packages: '@babel/runtime': 7.21.5 react: 18.2.0 + /react-docgen-typescript-plugin@1.0.5(typescript@5.0.4)(webpack@5.82.1): + resolution: {integrity: sha512-Ds6s2ioyIlH45XSfEVMNwRcDkzuff3xQCPxDFOzTc8GEshy+hksas8RYlmV4JEQREI+OGEGybhMCJk3vFbQZNQ==} + peerDependencies: + typescript: '>= 4.x' + webpack: '>= 4' + dependencies: + debug: 4.3.4(supports-color@8.1.1) + endent: 2.1.0 + find-cache-dir: 3.3.2 + flat-cache: 3.0.4 + micromatch: 4.0.5 + react-docgen-typescript: 2.2.2(typescript@5.0.4) + tslib: 2.4.0 + typescript: 5.0.4 + webpack: 5.82.1(esbuild@0.15.7) + transitivePeerDependencies: + - supports-color + dev: false + /react-docgen-typescript@2.2.2(typescript@5.0.4): resolution: {integrity: sha512-tvg2ZtOpOi6QDwsb3GZhOjDkkX0h8Z2gipvTg6OVMUyoYoURhEiRNePT8NZItTVCDh39JJHnLdfCOkzoLbFnTg==} peerDependencies: