From 70311ea842e9107e8aa6471f488f7d2beea51830 Mon Sep 17 00:00:00 2001 From: TechQuery Date: Tue, 30 Jan 2024 08:24:12 +0800 Subject: [PATCH] [fix] Storybook bundling bug with Babel/TypeScript --- .npmignore | 2 +- package.json | 4 ++-- pnpm-lock.yaml | 21 ++++++++++----------- vite.config.ts | 12 +++++++++++- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.npmignore b/.npmignore index 78e000e..ff8e87c 100644 --- a/.npmignore +++ b/.npmignore @@ -7,6 +7,6 @@ api-extractor.json stories/ .storybook/ storybook-static/ -.vscode/settings.json +.vscode/ .husky/ .github/ \ No newline at end of file diff --git a/package.json b/package.json index 675b04e..cd5ad65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "idea-react", - "version": "2.0.0-rc.0", + "version": "2.0.0-rc.1", "license": "LGPL-3.0-or-later", "author": "shiy2008@gmail.com", "description": "A React advanced components library based on TypeScript & Bootstrap, built by idea2app remote developers team.", @@ -45,7 +45,7 @@ }, "devDependencies": { "@babel/plugin-proposal-decorators": "^7.23.9", - "@babel/preset-env": "^7.23.9", + "@babel/preset-typescript": "^7.23.3", "@microsoft/api-extractor": "^7.39.4", "@parcel/config-default": "~2.11.0", "@parcel/packager-ts": "~2.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c7603c..c4840e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -58,9 +58,9 @@ devDependencies: '@babel/plugin-proposal-decorators': specifier: ^7.23.9 version: 7.23.9 - '@babel/preset-env': - specifier: ^7.23.9 - version: 7.23.9(@babel/core@7.23.9) + '@babel/preset-typescript': + specifier: ^7.23.3 + version: 7.23.3(@babel/core@7.23.9) '@microsoft/api-extractor': specifier: ^7.39.4 version: 7.39.4(@types/node@18.19.10) @@ -144,7 +144,7 @@ devDependencies: version: 9.0.7 koapache: specifier: ^2.2.2 - version: 2.2.2(@babel/preset-env@7.23.9)(@types/node@18.19.10) + version: 2.2.2(@types/node@18.19.10) less: specifier: ^4.2.0 version: 4.2.0 @@ -5254,7 +5254,7 @@ packages: resolution: {integrity: sha512-myfUej5naTBWnqOCc/MdVOLVjXUXtIA+NpDrDBKJtLLg2shUjBu3cZmB/85RyitKc55+lUUyl7oRfLOvkr2hsw==} dev: true - /@tech_query/node-toolkit@1.2.1(@babel/preset-env@7.23.9)(@types/node@18.19.10): + /@tech_query/node-toolkit@1.2.1(@types/node@18.19.10): resolution: {integrity: sha512-XFw0EVc8LCcC+CNo+lCxi+5iiPzQyubz41rP4iNuMueN+kjn/KMliaHKLZ5kAnCi+HxmuJPmzrSi6vZtuP07Hg==} peerDependencies: '@babel/plugin-transform-modules-commonjs': ^7.0.0 @@ -5262,7 +5262,6 @@ packages: '@types/node': '>=18' dependencies: '@babel/core': 7.23.9 - '@babel/preset-env': 7.23.9(@babel/core@7.23.9) '@types/node': 18.19.10 cross-spawn: 7.0.3 file-type: 16.5.4 @@ -6535,10 +6534,10 @@ packages: delayed-stream: 1.0.0 dev: true - /commander-jsx@0.6.9(@babel/preset-env@7.23.9)(@types/node@18.19.10): + /commander-jsx@0.6.9(@types/node@18.19.10): resolution: {integrity: sha512-E/wSYQhT7kgqd98WW8sdRiM+3i+J9Z30NOBTCdfD88p2k/po4+JEzikqOECKA1OouTqnAuIgdg5aKGbjq5B0jg==} dependencies: - '@tech_query/node-toolkit': 1.2.1(@babel/preset-env@7.23.9)(@types/node@18.19.10) + '@tech_query/node-toolkit': 1.2.1(@types/node@18.19.10) tslib: 2.6.2 transitivePeerDependencies: - '@babel/plugin-transform-modules-commonjs' @@ -8971,14 +8970,14 @@ packages: - supports-color dev: true - /koapache@2.2.2(@babel/preset-env@7.23.9)(@types/node@18.19.10): + /koapache@2.2.2(@types/node@18.19.10): resolution: {integrity: sha512-JJaXaR1h1SieXw06bAxdRkxqmY1pJ2BzlIA673lwBBgKbc1kPd3byxUvy69eONhJ9lcHrR6K6rTOWticAv0oKA==} engines: {node: '>=14'} hasBin: true dependencies: '@koa/cors': 4.0.0 - '@tech_query/node-toolkit': 1.2.1(@babel/preset-env@7.23.9)(@types/node@18.19.10) - commander-jsx: 0.6.9(@babel/preset-env@7.23.9)(@types/node@18.19.10) + '@tech_query/node-toolkit': 1.2.1(@types/node@18.19.10) + commander-jsx: 0.6.9(@types/node@18.19.10) form-data: 4.0.0 internal-ip: 6.2.0 koa: 2.15.0 diff --git a/vite.config.ts b/vite.config.ts index 7c499ae..f92736a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -25,7 +25,17 @@ export default defineConfig(({ mode }) => { plugins: [ react({ babel: { - presets: [['@babel/preset-env']], + presets: [ + [ + '@babel/preset-typescript', + { + allowDeclareFields: true, + allowNamespaces: true, + allExtensions: true, + isTSX: true + } + ] + ], plugins: [ [ '@babel/plugin-proposal-decorators',