From b707dd264e18d0acd418d84de5a76fd3b71d1ea6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 13 Mar 2026 14:42:09 +0800 Subject: [PATCH] build(vite)!: migrate to Vite 8, switch to Oxc-based @vitejs/plugin-react, and clean up legacy compatibility config (#6492) * chore(deps): update npm dependencies to v8 * build(vite)!: migrate to Vite 8, switch to Oxc-based @vitejs/plugin-react, and clean up legacy compatibility config --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Slinetrac --- README.md | 2 +- package.json | 7 +- pnpm-lock.yaml | 548 ++++++++++++++++++--------- src-tauri/tauri.macos.conf.json | 2 +- src/components/proxy/proxy-chain.tsx | 68 ++-- vite.config.mts | 205 +--------- 6 files changed, 397 insertions(+), 435 deletions(-) diff --git a/README.md b/README.md index 67046228b..e2a6e8f96 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ A Clash Meta GUI based on Tauri Go to the [Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package
-Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple). +Supports Windows (x64/x86), Linux (x64/arm64) and macOS 11+ (intel/apple). #### 我应当怎样选择发行版 diff --git a/package.json b/package.json index 60f69a64f..0b0b43b72 100644 --- a/package.json +++ b/package.json @@ -91,8 +91,8 @@ "@types/react": "19.2.14", "@types/react-dom": "19.2.3", "@types/validator": "^13.15.10", - "@vitejs/plugin-legacy": "^7.2.1", - "@vitejs/plugin-react-swc": "^4.2.3", + "@vitejs/plugin-legacy": "^8.0.0", + "@vitejs/plugin-react": "^6.0.0", "adm-zip": "^0.5.16", "cli-color": "^2.0.4", "commander": "^14.0.3", @@ -119,7 +119,7 @@ "terser": "^5.46.0", "typescript": "^5.9.3", "typescript-eslint": "^8.56.1", - "vite": "^7.3.1", + "vite": "^8.0.0", "vite-plugin-svgr": "^4.5.0" }, "lint-staged": { @@ -136,7 +136,6 @@ "pnpm": { "onlyBuiltDependencies": [ "@parcel/watcher", - "@swc/core", "core-js", "es5-ext", "esbuild", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe6e15bec..afe1c9cd9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -175,11 +175,11 @@ importers: specifier: ^13.15.10 version: 13.15.10 '@vitejs/plugin-legacy': - specifier: ^7.2.1 - version: 7.2.1(terser@5.46.0)(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) - '@vitejs/plugin-react-swc': - specifier: ^4.2.3 - version: 4.2.3(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) + specifier: ^8.0.0 + version: 8.0.0(terser@5.46.0)(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) + '@vitejs/plugin-react': + specifier: ^6.0.0 + version: 6.0.0(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) adm-zip: specifier: ^0.5.16 version: 0.5.16 @@ -259,11 +259,11 @@ importers: specifier: ^8.56.1 version: 8.56.1(eslint@10.0.3(jiti@2.6.1))(typescript@5.9.3) vite: - specifier: ^7.3.1 - version: 7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) + specifier: ^8.0.0 + version: 8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) vite-plugin-svgr: specifier: ^4.5.0 - version: 4.5.0(rollup@4.59.0)(typescript@5.9.3)(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) + version: 4.5.0(rollup@4.59.0)(typescript@5.9.3)(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)) packages: @@ -1264,6 +1264,9 @@ packages: '@napi-rs/wasm-runtime@0.2.12': resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} + '@napi-rs/wasm-runtime@1.1.1': + resolution: {integrity: sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==} + '@octokit/auth-token@6.0.0': resolution: {integrity: sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==} engines: {node: '>= 20'} @@ -1306,6 +1309,13 @@ packages: '@octokit/types@16.0.0': resolution: {integrity: sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==} + '@oxc-project/runtime@0.115.0': + resolution: {integrity: sha512-Rg8Wlt5dCbXhQnsXPrkOjL1DTSvXLgb2R/KYfnf1/K+R0k6UMLEmbQXPM+kwrWqSmWA2t0B1EtHy2/3zikQpvQ==} + engines: {node: ^20.19.0 || >=22.12.0} + + '@oxc-project/types@0.115.0': + resolution: {integrity: sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw==} + '@parcel/watcher-android-arm64@2.5.6': resolution: {integrity: sha512-YQxSS34tPF/6ZG7r/Ih9xy+kP/WwediEUsqmtf0cuCV5TPPKw/PQHRhueUo6JdeFJaqV3pyjm0GdYjZotbRt/A==} engines: {node: '>= 10.0.0'} @@ -1401,8 +1411,106 @@ packages: '@popperjs/core@2.11.8': resolution: {integrity: sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==} - '@rolldown/pluginutils@1.0.0-rc.2': - resolution: {integrity: sha512-izyXV/v+cHiRfozX62W9htOAvwMo4/bXKDrQ+vom1L1qRuexPock/7VZDAhnpHCLNejd3NJ6hiab+tO0D44Rgw==} + '@rolldown/binding-android-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-lcJL0bN5hpgJfSIz/8PIf02irmyL43P+j1pTCfbD1DbLkmGRuFIA4DD3B3ZOvGqG0XiVvRznbKtN0COQVaKUTg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-J7Zk3kLYFsLtuH6U+F4pS2sYVzac0qkjcO5QxHS7OS7yZu2LRs+IXo+uvJ/mvpyUljDJ3LROZPoQfgBIpCMhdQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.9': + resolution: {integrity: sha512-iwtmmghy8nhfRGeNAIltcNXzD0QMNaaA5U/NyZc1Ia4bxrzFByNMDoppoC+hl7cDiUq5/1CnFthpT9n+UtfFyg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.0.0-rc.9': + resolution: {integrity: sha512-DLFYI78SCiZr5VvdEplsVC2Vx53lnA4/Ga5C65iyldMVaErr86aiqCoNBLl92PXPfDtUYjUh+xFFor40ueNs4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': + resolution: {integrity: sha512-CsjTmTwd0Hri6iTw/DRMK7kOZ7FwAkrO4h8YWKoX/kcj833e4coqo2wzIFywtch/8Eb5enQ/lwLM7w6JX1W5RQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-2x9O2JbSPxpxMDhP9Z74mahAStibTlrBMW0520+epJH5sac7/LwZW5Bmg/E6CXuEF53JJFW509uP+lSedaUNxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': + resolution: {integrity: sha512-JA1QRW31ogheAIRhIg9tjMfsYbglXXYGNPLdPEYrwFxdbkQCAzvpSCSHCDWNl4hTtrol8WeboCSEpjdZK8qrCg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-aOKU9dJheda8Kj8Y3w9gnt9QFOO+qKPAl8SWd7JPHP+Cu0EuDAE5wokQubLzIDQWg2myXq2XhTpOVS07qqvT+w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-OalO94fqj7IWRn3VdXWty75jC5dk4C197AWEuMhIpvVv2lw9fiPhud0+bW2ctCxb3YoBZor71QHbY+9/WToadA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': + resolution: {integrity: sha512-cVEl1vZtBsBZna3YMjGXNvnYYrOJ7RzuWvZU0ffvJUexWkukMaDuGhUXn0rjnV0ptzGVkvc+vW9Yqy6h8YX4pg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': + resolution: {integrity: sha512-UzYnKCIIc4heAKgI4PZ3dfBGUZefGCJ1TPDuLHoCzgrMYPb5Rv6TLFuYtyM4rWyHM7hymNdsg5ik2C+UD9VDbA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': + resolution: {integrity: sha512-+6zoiF+RRyf5cdlFQP7nm58mq7+/2PFaY2DNQeD4B87N36JzfF/l9mdBkkmTvSYcYPE8tMh/o3cRlsx1ldLfog==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': + resolution: {integrity: sha512-rgFN6sA/dyebil3YTlL2evvi/M+ivhfnyxec7AccTpRPccno/rPoNlqybEZQBkcbZu8Hy+eqNJCqfBR8P7Pg8g==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': + resolution: {integrity: sha512-lHVNUG/8nlF1IQk1C0Ci574qKYyty2goMiPlRqkC5R+3LkXDkL5Dhx8ytbxq35m+pkHVIvIxviD+TWLdfeuadA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': + resolution: {integrity: sha512-G0oA4+w1iY5AGi5HcDTxWsoxF509hrFIPB2rduV5aDqS9FtDg1CAfa7V34qImbjfhIcA8C+RekocJZA96EarwQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.0-rc.7': + resolution: {integrity: sha512-qujRfC8sFVInYSPPMLQByRh7zhwkGFS4+tyMQ83srV1qrxL4g8E2tyxVVyxd0+8QeBM1mIk9KbWxkegRr76XzA==} + + '@rolldown/pluginutils@1.0.0-rc.9': + resolution: {integrity: sha512-w6oiRWgEBl04QkFZgmW+jnU1EC9b57Oihi2ot3HNWIQRqgHp5PnYDia5iZ5FF7rpa4EQdiqMDXjlqKGXBhsoXw==} '@rollup/pluginutils@5.3.0': resolution: {integrity: sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==} @@ -1619,85 +1727,6 @@ packages: peerDependencies: '@svgr/core': '*' - '@swc/core-darwin-arm64@1.15.18': - resolution: {integrity: sha512-+mIv7uBuSaywN3C9LNuWaX1jJJ3SKfiJuE6Lr3bd+/1Iv8oMU7oLBjYMluX1UrEPzwN2qCdY6Io0yVicABoCwQ==} - engines: {node: '>=10'} - cpu: [arm64] - os: [darwin] - - '@swc/core-darwin-x64@1.15.18': - resolution: {integrity: sha512-wZle0eaQhnzxWX5V/2kEOI6Z9vl/lTFEC6V4EWcn+5pDjhemCpQv9e/TDJ0GIoiClX8EDWRvuZwh+Z3dhL1NAg==} - engines: {node: '>=10'} - cpu: [x64] - os: [darwin] - - '@swc/core-linux-arm-gnueabihf@1.15.18': - resolution: {integrity: sha512-ao61HGXVqrJFHAcPtF4/DegmwEkVCo4HApnotLU8ognfmU8x589z7+tcf3hU+qBiU1WOXV5fQX6W9Nzs6hjxDw==} - engines: {node: '>=10'} - cpu: [arm] - os: [linux] - - '@swc/core-linux-arm64-gnu@1.15.18': - resolution: {integrity: sha512-3xnctOBLIq3kj8PxOCgPrGjBLP/kNOddr6f5gukYt/1IZxsITQaU9TDyjeX6jG+FiCIHjCuWuffsyQDL5Ew1bg==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@swc/core-linux-arm64-musl@1.15.18': - resolution: {integrity: sha512-0a+Lix+FSSHBSBOA0XznCcHo5/1nA6oLLjcnocvzXeqtdjnPb+SvchItHI+lfeiuj1sClYPDvPMLSLyXFaiIKw==} - engines: {node: '>=10'} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@swc/core-linux-x64-gnu@1.15.18': - resolution: {integrity: sha512-wG9J8vReUlpaHz4KOD/5UE1AUgirimU4UFT9oZmupUDEofxJKYb1mTA/DrMj0s78bkBiNI+7Fo2EgPuvOJfuAA==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@swc/core-linux-x64-musl@1.15.18': - resolution: {integrity: sha512-4nwbVvCphKzicwNWRmvD5iBaZj8JYsRGa4xOxJmOyHlMDpsvvJ2OR2cODlvWyGFH6BYL1MfIAK3qph3hp0Az6g==} - engines: {node: '>=10'} - cpu: [x64] - os: [linux] - libc: [musl] - - '@swc/core-win32-arm64-msvc@1.15.18': - resolution: {integrity: sha512-zk0RYO+LjiBCat2RTMHzAWaMky0cra9loH4oRrLKLLNuL+jarxKLFDA8xTZWEkCPLjUTwlRN7d28eDLLMgtUcQ==} - engines: {node: '>=10'} - cpu: [arm64] - os: [win32] - - '@swc/core-win32-ia32-msvc@1.15.18': - resolution: {integrity: sha512-yVuTrZ0RccD5+PEkpcLOBAuPbYBXS6rslENvIXfvJGXSdX5QGi1ehC4BjAMl5FkKLiam4kJECUI0l7Hq7T1vwg==} - engines: {node: '>=10'} - cpu: [ia32] - os: [win32] - - '@swc/core-win32-x64-msvc@1.15.18': - resolution: {integrity: sha512-7NRmE4hmUQNCbYU3Hn9Tz57mK9Qq4c97ZS+YlamlK6qG9Fb5g/BB3gPDe0iLlJkns/sYv2VWSkm8c3NmbEGjbg==} - engines: {node: '>=10'} - cpu: [x64] - os: [win32] - - '@swc/core@1.15.18': - resolution: {integrity: sha512-z87aF9GphWp//fnkRsqvtY+inMVPgYW3zSlXH1kJFvRT5H/wiAn+G32qW5l3oEk63KSF1x3Ov0BfHCObAmT8RA==} - engines: {node: '>=10'} - peerDependencies: - '@swc/helpers': '>=0.5.17' - peerDependenciesMeta: - '@swc/helpers': - optional: true - - '@swc/counter@0.1.3': - resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} - - '@swc/types@0.1.25': - resolution: {integrity: sha512-iAoY/qRhNH8a/hBvm3zKj9qQ4oc2+3w1unPJa2XvTK3XjeLXtzcCingVPw/9e5mn1+0yPqxcBGp9Jf0pkfMb1g==} - '@tanstack/react-table@8.21.3': resolution: {integrity: sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==} engines: {node: '>=12'} @@ -2056,18 +2085,25 @@ packages: cpu: [x64] os: [win32] - '@vitejs/plugin-legacy@7.2.1': - resolution: {integrity: sha512-CaXb/y0mlfu7jQRELEJJc2/5w2bX2m1JraARgFnvSB2yfvnCNJVWWlqAo6WjnKoepOwKx8gs0ugJThPLKCOXIg==} + '@vitejs/plugin-legacy@8.0.0': + resolution: {integrity: sha512-o5BmEuu4N+woyv+yUsiDrMUfMntJ1kEJITUYLd2ELOAETObwkWNFn5GNIQLLGx8liaobIvoXeSRiM/aYVIaeTQ==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: terser: ^5.16.0 - vite: ^7.0.0 + vite: ^8.0.0 - '@vitejs/plugin-react-swc@4.2.3': - resolution: {integrity: sha512-QIluDil2prhY1gdA3GGwxZzTAmLdi8cQ2CcuMW4PB/Wu4e/1pzqrwhYWVd09LInCRlDUidQjd0B70QWbjWtLxA==} + '@vitejs/plugin-react@6.0.0': + resolution: {integrity: sha512-Bu5/eP6td3WI654+tRq+ryW1PbgA90y5pqMKpb3U7UpNk6VjI53P/ncPUd192U9dSrepLy7DHnq1XEMDz5H++w==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: - vite: ^4 || ^5 || ^6 || ^7 + '@rolldown/plugin-babel': ^0.1.7 + babel-plugin-react-compiler: ^1.0.0 + vite: ^8.0.0 + peerDependenciesMeta: + '@rolldown/plugin-babel': + optional: true + babel-plugin-react-compiler: + optional: true acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} @@ -2126,11 +2162,6 @@ packages: peerDependencies: '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 - babel-plugin-polyfill-corejs3@0.13.0: - resolution: {integrity: sha512-U+GNwMdSFgzVmfhNm8GJUX88AadB3uo9KpJqS3FaqNIPKgySuvMb+bHPsOmmuWyIcuqZj/pzt1RUIUZns4y2+A==} - peerDependencies: - '@babel/core': ^7.4.0 || ^8.0.0-0 <8.0.0 - babel-plugin-polyfill-corejs3@0.14.1: resolution: {integrity: sha512-ENp89vM9Pw4kv/koBb5N2f9bDZsR0hpf3BdPMOg/pkS3pwO4dzNnQZVXtBbeyAadgm865DmQG2jMMLqmZXvuCw==} peerDependencies: @@ -2938,6 +2969,80 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + lightningcss-android-arm64@1.32.0: + resolution: {integrity: sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.32.0: + resolution: {integrity: sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.32.0: + resolution: {integrity: sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.32.0: + resolution: {integrity: sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.32.0: + resolution: {integrity: sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.32.0: + resolution: {integrity: sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.32.0: + resolution: {integrity: sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.32.0: + resolution: {integrity: sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.32.0: + resolution: {integrity: sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.32.0: + resolution: {integrity: sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.32.0: + resolution: {integrity: sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.32.0: + resolution: {integrity: sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==} + engines: {node: '>= 12.0.0'} + lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -3412,6 +3517,11 @@ packages: rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} + rolldown@1.0.0-rc.9: + resolution: {integrity: sha512-9EbgWge7ZH+yqb4d2EnELAntgPTWbfL8ajiTW+SyhJEC4qhBbkCKbqFV4Ge4zmu5ziQuVbWxb/XwLZ+RIO7E8Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + rollup@4.59.0: resolution: {integrity: sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -3699,15 +3809,16 @@ packages: peerDependencies: vite: '>=2.6.0' - vite@7.3.1: - resolution: {integrity: sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==} + vite@8.0.0: + resolution: {integrity: sha512-fPGaRNj9Zytaf8LEiBhY7Z6ijnFKdzU/+mL8EFBaKr7Vw1/FWcTBAMW0wLPJAGMPX38ZPVCVgLceWiEqeoqL2Q==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.0.0-alpha.31 + esbuild: ^0.27.0 jiti: '>=1.21.0' less: ^4.0.0 - lightningcss: ^1.21.0 sass: ^1.70.0 sass-embedded: ^1.70.0 stylus: '>=0.54.8' @@ -3718,12 +3829,14 @@ packages: peerDependenciesMeta: '@types/node': optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true jiti: optional: true less: optional: true - lightningcss: - optional: true sass: optional: true sass-embedded: @@ -4973,6 +5086,13 @@ snapshots: '@tybys/wasm-util': 0.10.1 optional: true + '@napi-rs/wasm-runtime@1.1.1': + dependencies: + '@emnapi/core': 1.8.1 + '@emnapi/runtime': 1.8.1 + '@tybys/wasm-util': 0.10.1 + optional: true + '@octokit/auth-token@6.0.0': {} '@octokit/core@7.0.6': @@ -5025,6 +5145,10 @@ snapshots: dependencies: '@octokit/openapi-types': 27.0.0 + '@oxc-project/runtime@0.115.0': {} + + '@oxc-project/types@0.115.0': {} + '@parcel/watcher-android-arm64@2.5.6': optional: true @@ -5090,7 +5214,56 @@ snapshots: '@popperjs/core@2.11.8': {} - '@rolldown/pluginutils@1.0.0-rc.2': {} + '@rolldown/binding-android-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-darwin-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-darwin-x64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-freebsd-x64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.9': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.9': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.9': + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.9': + dependencies: + '@napi-rs/wasm-runtime': 1.1.1 + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.9': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.9': + optional: true + + '@rolldown/pluginutils@1.0.0-rc.7': {} + + '@rolldown/pluginutils@1.0.0-rc.9': {} '@rollup/pluginutils@5.3.0(rollup@4.59.0)': dependencies: @@ -5245,58 +5418,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@swc/core-darwin-arm64@1.15.18': - optional: true - - '@swc/core-darwin-x64@1.15.18': - optional: true - - '@swc/core-linux-arm-gnueabihf@1.15.18': - optional: true - - '@swc/core-linux-arm64-gnu@1.15.18': - optional: true - - '@swc/core-linux-arm64-musl@1.15.18': - optional: true - - '@swc/core-linux-x64-gnu@1.15.18': - optional: true - - '@swc/core-linux-x64-musl@1.15.18': - optional: true - - '@swc/core-win32-arm64-msvc@1.15.18': - optional: true - - '@swc/core-win32-ia32-msvc@1.15.18': - optional: true - - '@swc/core-win32-x64-msvc@1.15.18': - optional: true - - '@swc/core@1.15.18': - dependencies: - '@swc/counter': 0.1.3 - '@swc/types': 0.1.25 - optionalDependencies: - '@swc/core-darwin-arm64': 1.15.18 - '@swc/core-darwin-x64': 1.15.18 - '@swc/core-linux-arm-gnueabihf': 1.15.18 - '@swc/core-linux-arm64-gnu': 1.15.18 - '@swc/core-linux-arm64-musl': 1.15.18 - '@swc/core-linux-x64-gnu': 1.15.18 - '@swc/core-linux-x64-musl': 1.15.18 - '@swc/core-win32-arm64-msvc': 1.15.18 - '@swc/core-win32-ia32-msvc': 1.15.18 - '@swc/core-win32-x64-msvc': 1.15.18 - - '@swc/counter@0.1.3': {} - - '@swc/types@0.1.25': - dependencies: - '@swc/counter': 0.1.3 - '@tanstack/react-table@8.21.3(react-dom@19.2.4(react@19.2.4))(react@19.2.4)': dependencies: '@tanstack/table-core': 8.21.3 @@ -5610,13 +5731,13 @@ snapshots: '@unrs/resolver-binding-win32-x64-msvc@1.11.1': optional: true - '@vitejs/plugin-legacy@7.2.1(terser@5.46.0)(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))': + '@vitejs/plugin-legacy@8.0.0(terser@5.46.0)(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))': dependencies: '@babel/core': 7.29.0 '@babel/plugin-transform-dynamic-import': 7.27.1(@babel/core@7.29.0) '@babel/plugin-transform-modules-systemjs': 7.29.0(@babel/core@7.29.0) '@babel/preset-env': 7.29.0(@babel/core@7.29.0) - babel-plugin-polyfill-corejs3: 0.13.0(@babel/core@7.29.0) + babel-plugin-polyfill-corejs3: 0.14.1(@babel/core@7.29.0) babel-plugin-polyfill-regenerator: 0.6.7(@babel/core@7.29.0) browserslist: 4.28.1 browserslist-to-esbuild: 2.1.1(browserslist@4.28.1) @@ -5625,17 +5746,14 @@ snapshots: regenerator-runtime: 0.14.1 systemjs: 6.15.1 terser: 5.46.0 - vite: 7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) + vite: 8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-react-swc@4.2.3(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))': + '@vitejs/plugin-react@6.0.0(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2))': dependencies: - '@rolldown/pluginutils': 1.0.0-rc.2 - '@swc/core': 1.15.18 - vite: 7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) - transitivePeerDependencies: - - '@swc/helpers' + '@rolldown/pluginutils': 1.0.0-rc.7 + vite: 8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) acorn-jsx@5.3.2(acorn@8.16.0): dependencies: @@ -5704,14 +5822,6 @@ snapshots: transitivePeerDependencies: - supports-color - babel-plugin-polyfill-corejs3@0.13.0(@babel/core@7.29.0): - dependencies: - '@babel/core': 7.29.0 - '@babel/helper-define-polyfill-provider': 0.6.7(@babel/core@7.29.0) - core-js-compat: 3.48.0 - transitivePeerDependencies: - - supports-color - babel-plugin-polyfill-corejs3@0.14.1(@babel/core@7.29.0): dependencies: '@babel/core': 7.29.0 @@ -5891,8 +6001,7 @@ snapshots: dequal@2.0.3: {} - detect-libc@2.1.2: - optional: true + detect-libc@2.1.2: {} devlop@1.1.0: dependencies: @@ -6000,6 +6109,7 @@ snapshots: '@esbuild/win32-arm64': 0.27.3 '@esbuild/win32-ia32': 0.27.3 '@esbuild/win32-x64': 0.27.3 + optional: true escalade@3.2.0: {} @@ -6613,6 +6723,55 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + lightningcss-android-arm64@1.32.0: + optional: true + + lightningcss-darwin-arm64@1.32.0: + optional: true + + lightningcss-darwin-x64@1.32.0: + optional: true + + lightningcss-freebsd-x64@1.32.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.32.0: + optional: true + + lightningcss-linux-arm64-gnu@1.32.0: + optional: true + + lightningcss-linux-arm64-musl@1.32.0: + optional: true + + lightningcss-linux-x64-gnu@1.32.0: + optional: true + + lightningcss-linux-x64-musl@1.32.0: + optional: true + + lightningcss-win32-arm64-msvc@1.32.0: + optional: true + + lightningcss-win32-x64-msvc@1.32.0: + optional: true + + lightningcss@1.32.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.32.0 + lightningcss-darwin-arm64: 1.32.0 + lightningcss-darwin-x64: 1.32.0 + lightningcss-freebsd-x64: 1.32.0 + lightningcss-linux-arm-gnueabihf: 1.32.0 + lightningcss-linux-arm64-gnu: 1.32.0 + lightningcss-linux-arm64-musl: 1.32.0 + lightningcss-linux-x64-gnu: 1.32.0 + lightningcss-linux-x64-musl: 1.32.0 + lightningcss-win32-arm64-msvc: 1.32.0 + lightningcss-win32-x64-msvc: 1.32.0 + lines-and-columns@1.2.4: {} lint-staged@16.3.2: @@ -7237,6 +7396,27 @@ snapshots: rfdc@1.4.1: {} + rolldown@1.0.0-rc.9: + dependencies: + '@oxc-project/types': 0.115.0 + '@rolldown/pluginutils': 1.0.0-rc.9 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-rc.9 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.9 + '@rolldown/binding-darwin-x64': 1.0.0-rc.9 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.9 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.9 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.9 + '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.9 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.9 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.9 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.9 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.9 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.9 + rollup@4.59.0: dependencies: '@types/estree': 1.0.8 @@ -7267,6 +7447,7 @@ snapshots: '@rollup/rollup-win32-x64-gnu': 4.59.0 '@rollup/rollup-win32-x64-msvc': 4.59.0 fsevents: 2.3.3 + optional: true sass@1.97.3: dependencies: @@ -7558,27 +7739,28 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite-plugin-svgr@4.5.0(rollup@4.59.0)(typescript@5.9.3)(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)): + vite-plugin-svgr@4.5.0(rollup@4.59.0)(typescript@5.9.3)(vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2)): dependencies: '@rollup/pluginutils': 5.3.0(rollup@4.59.0) '@svgr/core': 8.1.0(typescript@5.9.3) '@svgr/plugin-jsx': 8.1.0(@svgr/core@8.1.0(typescript@5.9.3)) - vite: 7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) + vite: 8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2) transitivePeerDependencies: - rollup - supports-color - typescript - vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2): + vite@8.0.0(@types/node@24.12.0)(esbuild@0.27.3)(jiti@2.6.1)(sass@1.97.3)(terser@5.46.0)(yaml@2.8.2): dependencies: - esbuild: 0.27.3 - fdir: 6.5.0(picomatch@4.0.3) + '@oxc-project/runtime': 0.115.0 + lightningcss: 1.32.0 picomatch: 4.0.3 postcss: 8.5.8 - rollup: 4.59.0 + rolldown: 1.0.0-rc.9 tinyglobby: 0.2.15 optionalDependencies: '@types/node': 24.12.0 + esbuild: 0.27.3 fsevents: 2.3.3 jiti: 2.6.1 sass: 1.97.3 diff --git a/src-tauri/tauri.macos.conf.json b/src-tauri/tauri.macos.conf.json index 2aa49bbf1..452008172 100644 --- a/src-tauri/tauri.macos.conf.json +++ b/src-tauri/tauri.macos.conf.json @@ -6,7 +6,7 @@ "targets": ["app", "dmg"], "macOS": { "frameworks": [], - "minimumSystemVersion": "10.15", + "minimumSystemVersion": "11.0", "exceptionDomain": "", "signingIdentity": null, "entitlements": "packages/macos/entitlements.plist", diff --git a/src/components/proxy/proxy-chain.tsx b/src/components/proxy/proxy-chain.tsx index 8b1c5ade4..70a8e50b6 100644 --- a/src/components/proxy/proxy-chain.tsx +++ b/src/components/proxy/proxy-chain.tsx @@ -32,6 +32,7 @@ import { Typography, useTheme, } from "@mui/material"; +import yaml from "js-yaml"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { @@ -75,6 +76,21 @@ interface SortableItemProps { onRemove: (id: string) => void; } +const toChainItems = ( + parsedConfig: ParsedChainConfig | null | undefined, +): ProxyChainItem[] => { + const timestamp = Date.now(); + + return ( + parsedConfig?.proxies?.map((proxy, index) => ({ + id: `${proxy.name}_${timestamp}_${index}`, + name: proxy.name, + type: proxy.type, + delay: undefined, + })) || [] + ); +}; + const SortableItem = ({ proxy, index, @@ -410,51 +426,13 @@ export const ProxyChain = ({ useEffect(() => { if (chainConfigData) { try { - // Try to parse as YAML using dynamic import - import("js-yaml") - .then((yaml) => { - try { - const parsedConfig = yaml.load( - chainConfigData, - ) as ParsedChainConfig; - const chainItems = - parsedConfig?.proxies?.map((proxy, index: number) => ({ - id: `${proxy.name}_${Date.now()}_${index}`, - name: proxy.name, - type: proxy.type, - delay: undefined, - })) || []; - if (chainItems.length > 0) { - onUpdateChain(chainItems); - } - } catch (parseError) { - console.error("Failed to parse YAML:", parseError); - } - }) - .catch((importError) => { - // Fallback: try to parse as JSON if YAML is not available - console.warn( - "js-yaml not available, trying JSON parse:", - importError, - ); - try { - const parsedConfig = JSON.parse( - chainConfigData, - ) as ParsedChainConfig; - const chainItems = - parsedConfig?.proxies?.map((proxy, index: number) => ({ - id: `${proxy.name}_${Date.now()}_${index}`, - name: proxy.name, - type: proxy.type, - delay: undefined, - })) || []; - if (chainItems.length > 0) { - onUpdateChain(chainItems); - } - } catch (jsonError) { - console.error("Failed to parse as JSON either:", jsonError); - } - }); + // JSON is valid YAML, so one parser covers both persisted formats. + const parsedConfig = yaml.load(chainConfigData) as ParsedChainConfig; + const chainItems = toChainItems(parsedConfig); + + if (chainItems.length > 0) { + onUpdateChain(chainItems); + } } catch (error) { console.error("Failed to process chain config data:", error); } diff --git a/vite.config.mts b/vite.config.mts index a5ef33af2..dcd21a1bf 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,152 +1,10 @@ import path from "node:path"; -import { fileURLToPath } from "node:url"; import legacy from "@vitejs/plugin-legacy"; -import react from "@vitejs/plugin-react-swc"; +import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; import svgr from "vite-plugin-svgr"; -const CONFIG_DIR = path.dirname(fileURLToPath(import.meta.url)); -const SRC_ROOT = path.resolve(CONFIG_DIR, "src"); - -const getPackageName = (id: string) => { - // Walk through possible pnpm virtual paths and nested node_modules, return the last package segment. - const matches = [ - ...id.matchAll( - /node_modules\/(?:\.pnpm\/[^/]+\/)?(?:node_modules\/)?((?:@[^/]+\/)?[^/]+)/g, - ), - ]; - const last = matches.at(-1); - return last ? last[1] : null; -}; - -const getSemanticNameFromFacade = ( - facadeModuleId: string | null | undefined, -) => { - if (!facadeModuleId) return null; - - const cleanPath = facadeModuleId.split("?")[0]; - const relativePath = path.relative(SRC_ROOT, cleanPath); - if (relativePath.startsWith("..")) return null; - - const withoutExtension = relativePath.replace(/\.[^/.]+$/, ""); - const normalizedPath = withoutExtension.replace(/\\/g, "/"); - const withoutTrailingIndex = normalizedPath.endsWith("/index") - ? normalizedPath.slice(0, -"/index".length) - : normalizedPath; - - const semanticName = withoutTrailingIndex - .split("/") - .filter(Boolean) - .join("-") - .replace(/[^a-zA-Z0-9-]/g, "-") - .replace(/--+/g, "-") - .replace(/^-+|-+$/g, ""); - - return semanticName || "index"; -}; - -const normalizeEntryName = (name: string, isEntry?: boolean) => - isEntry && name === "index" ? "main" : name; - -const getSemanticNameFromChunk = (chunkInfo: { - facadeModuleId: string | null | undefined; - moduleIds?: string[]; - name: string; - isEntry?: boolean; -}) => { - const fromFacade = getSemanticNameFromFacade(chunkInfo.facadeModuleId); - if (fromFacade) return normalizeEntryName(fromFacade, chunkInfo.isEntry); - - if (Array.isArray(chunkInfo.moduleIds)) { - for (const moduleId of chunkInfo.moduleIds) { - const semantic = getSemanticNameFromFacade(moduleId); - if (semantic) return normalizeEntryName(semantic, chunkInfo.isEntry); - } - } - - return normalizeEntryName(chunkInfo.name, chunkInfo.isEntry); -}; - -const normalizePackageName = (pkg: string) => - pkg.replace(/^@/, "").replace(/[@/]/g, "-"); - -type ChunkMatchContext = { id: string; pkg: string | null }; -type ChunkRule = { - name: string | ((pkg: string) => string); - match: (ctx: ChunkMatchContext) => boolean; -}; - -const CHUNK_PACKAGE_SETS: Record> = { - "react-core": new Set([ - "react", - "react-dom", - "react-router", - "@remix-run/router", - "scheduler", - "loose-envify", - "object-assign", - "use-sync-external-store", - "use-sync-external-store/shim", - ]), - "react-ui": new Set([ - "react-transition-group", - "react-error-boundary", - "react-hook-form", - "react-markdown", - "react-virtuoso", - ]), - utils: new Set([ - "axios", - "lodash-es", - "dayjs", - "js-base64", - "js-yaml", - "cli-color", - "nanoid", - ]), -}; - -const NAMESPACE_CHUNK_PREFIXES: Array<{ name: string; prefixes: string[] }> = [ - { name: "mui", prefixes: ["@mui/"] }, - { name: "tauri-plugins", prefixes: ["@tauri-apps/"] }, -]; - -const LARGE_VENDOR_MATCHERS = [ - "@emotion/react", - "@emotion/styled", - "@emotion/cache", - "lodash", - "monaco", - "@dnd-kit", - "i18next", -]; - -const packageSetRules: ChunkRule[] = Object.entries(CHUNK_PACKAGE_SETS).map( - ([name, pkgSet]) => ({ - name, - match: ({ pkg }) => !!pkg && pkgSet.has(pkg), - }), -); - -const namespaceRules: ChunkRule[] = NAMESPACE_CHUNK_PREFIXES.map( - ({ name, prefixes }) => ({ - name, - match: ({ pkg }) => - !!pkg && prefixes.some((prefix) => pkg.startsWith(prefix)), - }), -); - -const chunkRules: ChunkRule[] = [ - { name: "monaco-editor", match: ({ id }) => id.includes("monaco-editor") }, - ...packageSetRules, - ...namespaceRules, - { - name: (pkg) => `vendor-${normalizePackageName(pkg ?? "vendor")}`, - match: ({ pkg }) => - !!pkg && LARGE_VENDOR_MATCHERS.some((keyword) => pkg.includes(keyword)), - }, -]; export default defineConfig({ root: "src", server: { port: 3000 }, @@ -154,12 +12,10 @@ export default defineConfig({ svgr(), react(), legacy({ - targets: ["edge>=109", "safari>=13"], + modernTargets: ["edge>=109", "safari>=14"], renderLegacyChunks: false, - modernPolyfills: true, + modernPolyfills: ["es.object.has-own", "web.structured-clone"], additionalModernPolyfills: [ - "core-js/modules/es.object.has-own.js", - "core-js/modules/web.structured-clone.js", path.resolve("./src/polyfills/matchMedia.js"), path.resolve("./src/polyfills/WeakRef.js"), path.resolve("./src/polyfills/RegExp.js"), @@ -169,60 +25,7 @@ export default defineConfig({ build: { outDir: "../dist", emptyOutDir: true, - minify: "terser", - chunkSizeWarningLimit: 4500, - reportCompressedSize: false, - sourcemap: false, - cssCodeSplit: true, - cssMinify: true, - terserOptions: { - compress: { - drop_console: false, - drop_debugger: true, - pure_funcs: ["console.debug", "console.trace"], - dead_code: true, - unused: true, - }, - mangle: { - safari10: true, - }, - }, - rollupOptions: { - treeshake: { - preset: "recommended", - moduleSideEffects: (id) => !id.endsWith(".css"), - tryCatchDeoptimization: false, - }, - output: { - compact: true, - dynamicImportInCjs: true, - entryFileNames: (chunkInfo) => { - const semanticName = getSemanticNameFromChunk(chunkInfo); - - return `assets/${semanticName}-[hash].js`; - }, - chunkFileNames: (chunkInfo) => { - const semanticName = getSemanticNameFromChunk(chunkInfo); - - return `assets/${semanticName}-[hash].js`; - }, - manualChunks(id) { - if (!id.includes("node_modules")) return; - - const pkg = getPackageName(id); - const ctx: ChunkMatchContext = { id, pkg }; - for (const rule of chunkRules) { - if (rule.match(ctx)) { - return typeof rule.name === "function" - ? rule.name(pkg ?? "vendor") - : rule.name; - } - } - - return "vendor"; - }, - }, - }, + chunkSizeWarningLimit: 4000, }, resolve: { alias: {