From 8d0429d574f9fb8e5eb097ba825d2b451ed5fe9f Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Thu, 19 Dec 2024 11:18:07 +0800 Subject: [PATCH] feat: use catalog to globally upgrade vite and vitest (#2680) --- internals/cli/package.json | 2 +- .../unplugin-virtual-template/tsup.config.ts | 2 +- package.json | 3 +-- packages/mobile/package.json | 13 ++++++--- packages/mobile/tsconfig.json | 25 +++++++++++++++++ packages/mobile/tsconfig.node.json | 10 +++++++ packages/mobile/vite.config.ts | 27 +++++++++++++++++++ packages/utils/package.json | 4 +-- packages/utils/src/crypt/sha256.ts | 2 +- pnpm-workspace.yaml | 4 +-- 10 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 packages/mobile/tsconfig.json create mode 100644 packages/mobile/tsconfig.node.json create mode 100644 packages/mobile/vite.config.ts diff --git a/internals/cli/package.json b/internals/cli/package.json index b878fdca0e..06ae60ff31 100644 --- a/internals/cli/package.json +++ b/internals/cli/package.json @@ -23,7 +23,7 @@ "rollup": "^3.7.3", "semver": "^7.3.8", "tsup": "7.2.0", - "vite": "catalog:", + "vite": "^4.3.8", "typescript": "catalog:", "tailwindcss": "^3.2.4" }, diff --git a/internals/unplugin-virtual-template/tsup.config.ts b/internals/unplugin-virtual-template/tsup.config.ts index 5f5f855c1c..6f487b0831 100644 --- a/internals/unplugin-virtual-template/tsup.config.ts +++ b/internals/unplugin-virtual-template/tsup.config.ts @@ -4,6 +4,6 @@ export default { entryPoints: ['src/*.ts'], clean: true, format: ['cjs', 'esm'], - dts: true, + dts: false, onSuccess: 'esno scripts/postbuild.ts' } diff --git a/package.json b/package.json index 49ee32ed9f..ad3eaa0959 100644 --- a/package.json +++ b/package.json @@ -229,8 +229,7 @@ "vue@3": "3.4.38", "vue2": "npm:vue@2.6.14", "vue2.7": "npm:vue@2.7.10", - "vue3": "npm:vue@3.4.38", - "vite": "catalog:" + "vue3": "npm:vue@3.4.38" }, "packageExtensions": { "vue-template-compiler@2.6.14": { diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 10bca45275..d150810786 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -25,8 +25,7 @@ "sideEffects": false, "main": "index.ts", "scripts": { - "build": "pnpm -w build:ui", - "postversion": "pnpm build" + "build": "vite build" }, "dependencies": { "@better-scroll/core": "^2.5.0", @@ -36,6 +35,12 @@ "@opentiny/vue-locale": "workspace:~" }, "devDependencies": { - "vue": "^3.5.0" + "vue": "^3.5.0", + "typescript": "catalog:", + "vite": "catalog:", + "@vitejs/plugin-vue": "^5.2.1", + "@vitejs/plugin-vue-jsx": "^4.1.1", + "vite-plugin-dts": "^4.3.0", + "vite-svg-loader": "^5.1.0" } -} \ No newline at end of file +} diff --git a/packages/mobile/tsconfig.json b/packages/mobile/tsconfig.json new file mode 100644 index 0000000000..56c154f085 --- /dev/null +++ b/packages/mobile/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["components/**/*.ts", "components/**/*.tsx", "components/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/packages/mobile/tsconfig.node.json b/packages/mobile/tsconfig.node.json new file mode 100644 index 0000000000..42872c59f5 --- /dev/null +++ b/packages/mobile/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/mobile/vite.config.ts b/packages/mobile/vite.config.ts new file mode 100644 index 0000000000..22680e7c52 --- /dev/null +++ b/packages/mobile/vite.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' +import dts from 'vite-plugin-dts' +import svgLoader from 'vite-svg-loader' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx(), dts(), svgLoader()], + build: { + lib: { + entry: './index.ts' + }, + minify: true, + rollupOptions: { + external: [/@better-scroll/, /@opentiny/], + input: ['index.ts'], + output: [ + { + format: 'es', + entryFileNames: '[name].js', + preserveModules: true + } + ] + } + } +}) diff --git a/packages/utils/package.json b/packages/utils/package.json index 5afaeaf9e3..14e9ffb924 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -21,8 +21,8 @@ "xss": "1.0.14" }, "devDependencies": { - "typescript": "^5.2.2", + "typescript": "catalog:", "vite-plugin-dts": "~4.3.0", - "vite": "^6.0.0" + "vite": "catalog:" } } diff --git a/packages/utils/src/crypt/sha256.ts b/packages/utils/src/crypt/sha256.ts index 42dd825e1d..0645ed1cd9 100644 --- a/packages/utils/src/crypt/sha256.ts +++ b/packages/utils/src/crypt/sha256.ts @@ -36,7 +36,7 @@ while (mPrime < 64) { export class SHA256Algo extends Hasher { _hash: any - _data: any + declare _data: any _doReset() { this._hash = new WordArray(H.slice(0)) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index bfd27e3322..ab608b729a 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -6,6 +6,6 @@ packages: # 统一版本,方便维护 catalog: - 'vitest': '^0.31.0' - 'vite': '^4.3.8' + 'vitest': '^2.1.8' + 'vite': '^6.0.0' 'typescript': '~5.3.3'