Skip to content

Commit 8ba2fe4

Browse files
committed
chore: upgrade vite to v6, typescript to v5
1 parent 04a1c58 commit 8ba2fe4

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,15 @@
9292
"@testing-library/react": "^12.1.4",
9393
"@testing-library/user-event": "^13.5.0",
9494
"@types/lodash-es": "^4.17.12",
95-
"@types/node": "^20.14.11",
95+
"@types/node": "^22.14.1",
9696
"@types/react": "^17.0.2",
9797
"@types/react-dom": "17.0.2",
9898
"@types/react-transition-group": "^4.4.4",
99+
"@types/rimraf": "^4.0.5",
99100
"@types/tinycolor2": "^1.4.6",
100101
"@typescript-eslint/eslint-plugin": "^5.6.0",
101102
"@typescript-eslint/parser": "^5.6.0",
102-
"@vitejs/plugin-react": "^1.1.1",
103+
"@vitejs/plugin-react": "^4.4.1",
103104
"@vitest/coverage-istanbul": "^2.0.3",
104105
"@vitest/coverage-v8": "^2.0.3",
105106
"@vitest/ui": "^2.0.3",
@@ -139,7 +140,7 @@
139140
"react": "^17.0.2",
140141
"react-dom": "^17.0.2",
141142
"react-router-dom": "^6.2.2",
142-
"rimraf": "^3.0.2",
143+
"rimraf": "^6.0.1",
143144
"rollup": "^2.55.0",
144145
"rollup-plugin-analyzer": "^4.0.0",
145146
"rollup-plugin-esbuild": "^4.5.0",
@@ -153,10 +154,10 @@
153154
"tdesign-icons-view": "^0.3.6",
154155
"tdesign-site-components": "^0.15.6",
155156
"tdesign-theme-generator": "^1.1.0",
156-
"typescript": "^4.5.3",
157-
"vite": "^2.7.0",
158-
"vite-plugin-pwa": "^0.11.11",
159-
"vite-plugin-tdoc": "^2.0.0",
157+
"typescript": "^5.8.3",
158+
"vite": "^6.2.3",
159+
"vite-plugin-pwa": "^1.0.0",
160+
"vite-plugin-tdoc": "^2.0.4",
160161
"vitest": "^2.0.3",
161162
"workbox-precaching": "^6.3.0"
162163
},

site/pwaConfig.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export default {
22
strategies: 'injectManifest',
3-
includeAssets: ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png'],
3+
includeAssets: ['favicon.svg', 'favicon.ico', 'apple-touch-icon.png'],
4+
injectManifest: {
5+
maximumFileSizeToCacheInBytes: 7000000,
6+
},
47
manifest: {
58
name: 'TDesign for Mobile React',
69
short_name: 'TDesign',
@@ -16,7 +19,7 @@ export default {
1619
src: 'pwa-512x512.png',
1720
sizes: '512x512',
1821
type: 'image/png',
19-
}
20-
]
21-
}
22+
},
23+
],
24+
},
2225
};

site/vite.config.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ const publicPathMap = {
1313
production: 'https://static.tdesign.tencent.com/mobile-react/',
1414
};
1515

16+
// Rollup 4+ 的 tree-shaking 策略调整, 这里是为了让样式在站点构建正常
17+
const disableTreeShakingPlugin = (paths) => ({
18+
name: 'disable-treeshake',
19+
transform(code, id) {
20+
for (const path of paths) {
21+
if (id.includes(path)) {
22+
return { code, map: null, moduleSideEffects: 'no-treeshake' };
23+
}
24+
}
25+
},
26+
});
27+
1628
export default ({ mode }) =>
1729
defineConfig({
1830
base: publicPathMap[mode],
@@ -48,5 +60,11 @@ export default ({ mode }) =>
4860
https: false,
4961
fs: { strict: false },
5062
},
51-
plugins: [react(), tdocPlugin(), VitePWA(pwaConfig), replace({ __DATE__: new Date().toISOString() })],
63+
plugins: [
64+
react(),
65+
tdocPlugin(),
66+
VitePWA(pwaConfig),
67+
disableTreeShakingPlugin(['style/']),
68+
replace({ __DATE__: new Date().toISOString() }),
69+
],
5270
});

site/web/Demo.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react';
22
import { Link, useLocation } from 'react-router-dom';
33
import Button from 'tdesign-mobile-react/button';
44

5-
export const jsxDemoFiles = import.meta.globEager('../../src/**/_example/*.jsx');
6-
export const tsxDemoFiles = import.meta.globEager('../../src/**/_example/*.tsx');
5+
export const jsxDemoFiles = import.meta.glob('../../src/**/_example/*.jsx', { eager: true });
6+
export const tsxDemoFiles = import.meta.glob('../../src/**/_example/*.tsx', { eager: true });
77

88
const demoObject = {};
99

0 commit comments

Comments
 (0)