diff --git a/.github/actions/compute-native-cache-input-hash/action.yml b/.github/actions/compute-native-cache-input-hash/action.yml index a88dea1d00..f417d97bf9 100644 --- a/.github/actions/compute-native-cache-input-hash/action.yml +++ b/.github/actions/compute-native-cache-input-hash/action.yml @@ -42,8 +42,10 @@ runs: 'packages/cli/build.ts', 'packages/cli/tsdown.config.ts', '.github/actions/build-upstream/action.yml', + '.github/actions/clone/action.yml', '.github/actions/build-windows-cli/action.yml', '.github/actions/compute-native-cache-input-hash/action.yml', + '.github/actions/download-rolldown-binaries/action.yml', '.github/actions/setup-xwin/action.yml' ) }} diff --git a/.github/workflows/vp-binary-size.yml b/.github/workflows/vp-binary-size.yml new file mode 100644 index 0000000000..58e1c06188 --- /dev/null +++ b/.github/workflows/vp-binary-size.yml @@ -0,0 +1,363 @@ +name: Native Binary Size + +permissions: {} + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: native-binary-size-${{ github.event.pull_request.number }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + inputs: + name: Detect native input changes + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + changed: ${{ steps.compare.outputs.changed }} + steps: + - name: Check out base + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + ref: ${{ github.event.pull_request.base.sha }} + fetch-depth: 0 + persist-credentials: false + + - name: Compute base native input hash + id: base + uses: ./.github/actions/compute-native-cache-input-hash + + - name: Check out PR + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + persist-credentials: false + + - name: Compute PR native input hash + id: head + uses: ./.github/actions/compute-native-cache-input-hash + + - name: Compare native inputs + id: compare + env: + BASE_HASH: ${{ steps.base.outputs.hash }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_HASH: ${{ steps.head.outputs.hash }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + if [[ "$BASE_HASH" != "$HEAD_HASH" ]] || + ! git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- .github/workflows/vp-binary-size.yml; then + echo "changed=true" >> "$GITHUB_OUTPUT" + else + echo "changed=false" >> "$GITHUB_OUTPUT" + fi + + build: + name: Build ${{ matrix.source }} ${{ matrix.settings.label }} + needs: inputs + if: needs.inputs.outputs.changed == 'true' + strategy: + fail-fast: false + matrix: + source: [base, head] + settings: + - label: Linux x64 + builder: upstream + os: namespace-profile-linux-x64-default + platform: linux + target: x86_64-unknown-linux-gnu + - label: macOS ARM64 + builder: upstream + os: namespace-profile-mac-default + platform: macos + target: aarch64-apple-darwin + - label: Windows x64 + builder: windows-cross + os: namespace-profile-linux-x64-default + platform: windows + target: x86_64-pc-windows-msvc + runs-on: ${{ matrix.settings.os }} + permissions: + contents: read + env: + DEBUG: 'napi:*' + RELEASE_BUILD: 'true' + VERSION: '0.0.0-native-size' + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + ref: ${{ matrix.source == 'base' && github.event.pull_request.base.sha || github.event.pull_request.head.sha }} + persist-credentials: false + + - uses: ./.github/actions/clone + + - uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 - Swatinem/rust-cache v2.9.1 for node24) + if: matrix.settings.builder == 'upstream' + with: + save-cache: false + cache-key: native-binary-size-${{ matrix.source }}-${{ matrix.settings.target }} + + - name: Add Rust target + if: matrix.settings.builder == 'upstream' + run: rustup target add ${{ matrix.settings.target }} + + - uses: oxc-project/setup-node@4c588e9266bd930b6ddc34307df0659ed511d187 # v1.3.1 + if: matrix.settings.builder == 'upstream' + + - name: Build final artifacts + if: matrix.settings.builder == 'upstream' + uses: ./.github/actions/build-upstream + with: + target: ${{ matrix.settings.target }} + + - name: Cross-compile final Windows artifacts + if: matrix.settings.builder == 'windows-cross' + uses: ./.github/actions/build-windows-cli + with: + artifact-name: windows-cli-binaries-size-${{ matrix.source }} + save-cache: false + + - name: Measure final artifacts + env: + PLATFORM: ${{ matrix.settings.platform }} + SIZE_FILE: ${{ runner.temp }}/native-size-${{ matrix.source }}-${{ matrix.settings.platform }}.json + SOURCE: ${{ matrix.source }} + TARGET: ${{ matrix.settings.target }} + run: | + node <<'NODE' + const { existsSync, readFileSync, writeFileSync } = require('node:fs'); + const { gzipSync } = require('node:zlib'); + + const target = process.env.TARGET; + const paths = + process.env.PLATFORM === 'linux' + ? { + vp: `target/${target}/release/vp`, + napi: 'packages/cli/binding/vite-plus.linux-x64-gnu.node', + } + : process.env.PLATFORM === 'macos' + ? { + vp: `target/${target}/release/vp`, + napi: 'packages/cli/binding/vite-plus.darwin-arm64.node', + } + : { + vp: `target/${target}/release/vp.exe`, + napi: 'packages/cli/binding/vite-plus.win32-x64-msvc.node', + trampoline: `target/${target}/release/vp-shim.exe`, + }; + + const artifacts = {}; + for (const [name, file] of Object.entries(paths)) { + if (!existsSync(file)) { + throw new Error(`Expected final ${name} artifact at ${file}`); + } + const contents = readFileSync(file); + artifacts[name] = { + path: file, + raw: contents.length, + gzip: gzipSync(contents, { level: 9 }).length, + }; + } + + const result = { + source: process.env.SOURCE, + target, + artifacts, + }; + writeFileSync(process.env.SIZE_FILE, `${JSON.stringify(result, null, 2)}\n`); + console.log(JSON.stringify(result, null, 2)); + NODE + + - name: Upload size measurements + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: native-size-${{ matrix.source }}-${{ matrix.settings.platform }} + path: ${{ runner.temp }}/native-size-${{ matrix.source }}-${{ matrix.settings.platform }}.json + if-no-files-found: error + retention-days: 1 + + cleanup: + name: Clear stale binary size report + needs: inputs + if: needs.inputs.outputs.changed != 'true' && github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Delete stale size comment + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 + with: + script: | + const marker = ''; + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const existing = comments.find((comment) => comment.body?.includes(marker)); + if (existing) { + await github.rest.issues.deleteComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + }); + } + + comment: + name: Report binary size + needs: build + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + pull-requests: write + steps: + - name: Download size measurements + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + pattern: native-size-* + path: ${{ runner.temp }}/native-size + merge-multiple: true + + - name: Comment size comparison + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 + env: + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + SIZE_DIR: ${{ runner.temp }}/native-size + with: + script: | + const fs = require('node:fs'); + const path = require('node:path'); + + const marker = ''; + const load = (source, platform) => + JSON.parse( + fs.readFileSync(path.join(process.env.SIZE_DIR, `native-size-${source}-${platform}.json`)), + ); + const baseLinux = load('base', 'linux'); + const headLinux = load('head', 'linux'); + const baseMacos = load('base', 'macos'); + const headMacos = load('head', 'macos'); + const baseWindows = load('base', 'windows'); + const headWindows = load('head', 'windows'); + const artifacts = [ + { + name: '`vp` (Linux x64)', + baseRaw: baseLinux.artifacts.vp.raw, + baseGzip: baseLinux.artifacts.vp.gzip, + headRaw: headLinux.artifacts.vp.raw, + headGzip: headLinux.artifacts.vp.gzip, + }, + { + name: 'NAPI (Linux x64)', + baseRaw: baseLinux.artifacts.napi.raw, + baseGzip: baseLinux.artifacts.napi.gzip, + headRaw: headLinux.artifacts.napi.raw, + headGzip: headLinux.artifacts.napi.gzip, + }, + { + name: '`vp` (macOS ARM64)', + baseRaw: baseMacos.artifacts.vp.raw, + baseGzip: baseMacos.artifacts.vp.gzip, + headRaw: headMacos.artifacts.vp.raw, + headGzip: headMacos.artifacts.vp.gzip, + }, + { + name: 'NAPI (macOS ARM64)', + baseRaw: baseMacos.artifacts.napi.raw, + baseGzip: baseMacos.artifacts.napi.gzip, + headRaw: headMacos.artifacts.napi.raw, + headGzip: headMacos.artifacts.napi.gzip, + }, + { + name: '`vp` (Windows x64)', + baseRaw: baseWindows.artifacts.vp.raw, + baseGzip: baseWindows.artifacts.vp.gzip, + headRaw: headWindows.artifacts.vp.raw, + headGzip: headWindows.artifacts.vp.gzip, + }, + { + name: 'NAPI (Windows x64)', + baseRaw: baseWindows.artifacts.napi.raw, + baseGzip: baseWindows.artifacts.napi.gzip, + headRaw: headWindows.artifacts.napi.raw, + headGzip: headWindows.artifacts.napi.gzip, + }, + { + name: 'Trampoline (Windows x64)', + baseRaw: baseWindows.artifacts.trampoline.raw, + baseGzip: baseWindows.artifacts.trampoline.gzip, + headRaw: headWindows.artifacts.trampoline.raw, + headGzip: headWindows.artifacts.trampoline.gzip, + }, + ]; + + const formatSize = (bytes, includePlus = false) => { + const absolute = Math.abs(bytes); + const sign = bytes < 0 ? '-' : includePlus && bytes > 0 ? '+' : ''; + if (absolute >= 1024 ** 2) { + return `${sign}${(absolute / 1024 ** 2).toFixed(2)} MiB`; + } + if (absolute >= 1024) { + return `${sign}${(absolute / 1024).toFixed(2)} KiB`; + } + return `${sign}${absolute.toLocaleString('en-US')} B`; + }; + const formatDelta = (base, head) => { + const delta = head - base; + const percent = base === 0 ? 0 : (delta / base) * 100; + const sign = delta > 0 ? '+' : ''; + return `${formatSize(delta, true)} (${sign}${percent.toFixed(2)}%)`; + }; + + const shortSha = process.env.HEAD_SHA.slice(0, 7); + const rows = artifacts.flatMap((artifact) => [ + `| ${artifact.name} | Binary | ${formatSize(artifact.baseRaw)} | ${formatSize(artifact.headRaw)} | ${formatDelta(artifact.baseRaw, artifact.headRaw)} |`, + `| ${artifact.name} | gzip -9 | ${formatSize(artifact.baseGzip)} | ${formatSize(artifact.headGzip)} | ${formatDelta(artifact.baseGzip, artifact.headGzip)} |`, + ]); + const body = [ + marker, + '', + `### Native binary sizes (\`${shortSha}\`)`, + '', + 'Final release artifacts built by the canonical `build-upstream` and `build-windows-cli` actions.', + '', + '| Artifact | Format | Base | PR | Change |', + '| --- | --- | ---: | ---: | ---: |', + ...rows, + ].join('\n'); + + await core.summary.addRaw(body.replace(marker, '')).write(); + + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + const existing = comments.find((comment) => comment.body?.includes(marker)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } diff --git a/Cargo.lock b/Cargo.lock index 0400cff860..1e65b50fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -529,26 +529,6 @@ dependencies = [ "regex", ] -[[package]] -name = "bincode" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" -dependencies = [ - "bincode_derive", - "serde", - "unty", -] - -[[package]] -name = "bincode_derive" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" -dependencies = [ - "virtue", -] - [[package]] name = "bit-set" version = "0.5.3" @@ -646,7 +626,7 @@ dependencies = [ "arrayvec", "cc", "cfg-if", - "constant_time_eq 0.4.2", + "constant_time_eq", "cpufeatures 0.2.17", ] @@ -842,15 +822,6 @@ version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" -[[package]] -name = "bzip2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" -dependencies = [ - "libbz2-rs-sys", -] - [[package]] name = "cached" version = "0.56.0" @@ -1227,12 +1198,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "constant_time_eq" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" - [[package]] name = "constant_time_eq" version = "0.4.2" @@ -1322,21 +1287,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - [[package]] name = "crc24" version = "0.1.6" @@ -1700,12 +1650,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "deflate64" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2" - [[package]] name = "der" version = "0.7.10" @@ -1717,15 +1661,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "deranged" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -dependencies = [ - "powerfmt", -] - [[package]] name = "derive_builder" version = "0.20.2" @@ -3473,12 +3408,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" -[[package]] -name = "libbz2-rs-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4a545a15244c7d945065b5d392b2d2d7f21526fba56ce51467b06ed445e8f7" - [[package]] name = "libc" version = "0.2.186" @@ -3589,16 +3518,6 @@ dependencies = [ "value-bag", ] -[[package]] -name = "lzma-rust2" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1670343e58806300d87950e3401e820b519b9384281bbabfb15e3636689ffd69" -dependencies = [ - "crc", - "sha2 0.10.9", -] - [[package]] name = "matchers" version = "0.2.0" @@ -4049,12 +3968,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" - [[package]] name = "num-integer" version = "0.1.46" @@ -5021,16 +4934,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" -[[package]] -name = "pbkdf2" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" -dependencies = [ - "digest 0.10.7", - "hmac", -] - [[package]] name = "peg" version = "0.8.5" @@ -5506,18 +5409,6 @@ dependencies = [ "serde", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - -[[package]] -name = "ppmd-rust" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efca4c95a19a79d1c98f791f10aebd5c1363b473244630bb7dbde1dc98455a24" - [[package]] name = "ppv-lite86" version = "0.2.21" @@ -7877,26 +7768,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "time" -version = "0.3.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" -dependencies = [ - "deranged", - "js-sys", - "num-conv", - "powerfmt", - "serde_core", - "time-core", -] - -[[package]] -name = "time-core" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" - [[package]] name = "tiny-keccak" version = "2.0.2" @@ -8350,12 +8221,6 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" -[[package]] -name = "unty" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" - [[package]] name = "url" version = "2.5.8" @@ -8465,12 +8330,6 @@ dependencies = [ "filetime", ] -[[package]] -name = "virtue" -version = "0.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" - [[package]] name = "vite-plus-benches" version = "0.1.0" @@ -8564,12 +8423,10 @@ version = "0.0.0" dependencies = [ "anyhow", "ast-grep-config", - "bincode", "bstr", "ignore", "nix 0.30.1", "reqwest", - "rusqlite", "semver 1.0.27", "serde_json", "thiserror 2.0.18", @@ -8578,7 +8435,6 @@ dependencies = [ "vite_shared", "vite_str", "vite_workspace", - "wax 0.6.0", ] [[package]] @@ -8588,7 +8444,7 @@ source = "git+https://github.com/voidzero-dev/vite-task.git?rev=417b6aae5fca92b1 dependencies = [ "globset", "thiserror 2.0.18", - "wax 0.7.0", + "wax", ] [[package]] @@ -8904,7 +8760,7 @@ dependencies = [ "vite_task_plan", "vite_task_server", "vite_workspace", - "wax 0.7.0", + "wax", "winapi", "wincode", "zstd", @@ -8953,7 +8809,7 @@ dependencies = [ "vite_path", "vite_str", "vite_workspace", - "wax 0.7.0", + "wax", "wincode", ] @@ -9036,7 +8892,7 @@ dependencies = [ "vite_glob", "vite_path", "vite_str", - "wax 0.7.0", + "wax", ] [[package]] @@ -9215,21 +9071,6 @@ dependencies = [ "semver 1.0.27", ] -[[package]] -name = "wax" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d12a78aa0bab22d2f26ed1a96df7ab58e8a93506a3e20adb47c51a93b4e1357" -dependencies = [ - "const_format", - "itertools 0.11.0", - "nom 7.1.3", - "pori", - "regex", - "thiserror 1.0.69", - "walkdir", -] - [[package]] name = "wax" version = "0.7.0" @@ -9952,26 +9793,11 @@ version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c42e33efc22a0650c311c2ef19115ce232583abbe80850bc8b66509ebef02de0" dependencies = [ - "aes", - "bzip2", - "constant_time_eq 0.3.1", "crc32fast", - "deflate64", "flate2", - "generic-array", - "getrandom 0.3.4", - "hmac", "indexmap", - "lzma-rust2", "memchr", - "pbkdf2", - "ppmd-rust", - "sha1", - "time", "typed-path", - "zeroize", - "zopfli", - "zstd", ] [[package]] @@ -9986,18 +9812,6 @@ version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" -[[package]] -name = "zopfli" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" -dependencies = [ - "bumpalo", - "crc32fast", - "log", - "simd-adler32", -] - [[package]] name = "zstd" version = "0.13.3" diff --git a/Cargo.toml b/Cargo.toml index 75cde36aa6..90ab1461e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,7 +171,6 @@ async-trait = "0.1.89" backon = "1.3.0" base-encode = "0.3.1" base64-simd = "0.8.0" -bincode = "2.0.1" bstr = { version = "1.12.0", default-features = false, features = ["alloc", "std"] } bitflags = "2.9.1" brush-parser = "0.3.0" @@ -260,7 +259,6 @@ regress = "0.11.0" reqwest = { version = "0.13", default-features = false } rolldown-notify = "10.2.0" rolldown-notify-debouncer-full = "0.7.5" -rusqlite = { version = "0.39.0", features = ["bundled"] } rustc-hash = "2.1.1" rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] } schemars = "1.0.0" @@ -292,13 +290,7 @@ tokio-util = "0.7" toml = "1.0.0" tracing = "0.1.41" tracing-chrome = "0.7.2" -tracing-subscriber = { version = "0.3.19", default-features = false, features = [ - "env-filter", - "fmt", - "json", - "serde", - "std", -] } +tracing-subscriber = { version = "0.3.19", default-features = false, features = ["fmt", "std"] } ts-rs = "12.0" typedmap = "0.6.0" url = "2.5.4" @@ -319,11 +311,10 @@ vite_str = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6 vite_task = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" } vite_workspace = { git = "https://github.com/voidzero-dev/vite-task.git", rev = "417b6aae5fca92b128c586c8ff3421e43911b553" } walkdir = "2.5.0" -wax = "0.6.0" which = "8.0.0" winreg = "0.56.0" xxhash-rust = "0.8.15" -zip = "7.2" +zip = { version = "7.2", default-features = false, features = ["deflate-flate2-zlib-rs"] } # oxc crates with the same version oxc = { version = "0.138.0", features = [ diff --git a/crates/vite_error/Cargo.toml b/crates/vite_error/Cargo.toml index d5a37307b8..9fb52370c7 100644 --- a/crates/vite_error/Cargo.toml +++ b/crates/vite_error/Cargo.toml @@ -7,14 +7,15 @@ license.workspace = true publish = false rust-version.workspace = true +[features] +migration = ["dep:ast-grep-config", "dep:ignore"] + [dependencies] anyhow = { workspace = true } -ast-grep-config = { workspace = true } -bincode = { workspace = true } +ast-grep-config = { workspace = true, optional = true } bstr = { workspace = true } -ignore = { workspace = true } +ignore = { workspace = true, optional = true } nix = { workspace = true } -rusqlite = { workspace = true } semver = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } @@ -23,7 +24,6 @@ vite_path = { workspace = true } vite_shared = { workspace = true } vite_str = { workspace = true } vite_workspace = { workspace = true } -wax = { workspace = true } [target.'cfg(target_os = "windows")'.dependencies] reqwest = { workspace = true, features = ["stream", "native-tls-vendored", "json"] } diff --git a/crates/vite_error/src/lib.rs b/crates/vite_error/src/lib.rs index 30fd98751a..09f23ed57e 100644 --- a/crates/vite_error/src/lib.rs +++ b/crates/vite_error/src/lib.rs @@ -8,18 +8,6 @@ use vite_str::Str; #[derive(Error, Debug)] pub enum Error { - #[error(transparent)] - Sqlite(#[from] rusqlite::Error), - - #[error(transparent)] - BincodeEncode(#[from] bincode::error::EncodeError), - - #[error(transparent)] - BincodeDecode(#[from] bincode::error::DecodeError), - - #[error("Unrecognized db version: {0}")] - UnrecognizedDbVersion(u32), - #[error(transparent)] Io(#[from] std::io::Error), @@ -50,12 +38,7 @@ pub enum Error { #[error(transparent)] Utf8Error(#[from] bstr::Utf8Error), - #[error(transparent)] - WaxBuild(#[from] wax::BuildError), - - #[error(transparent)] - WaxWalk(#[from] wax::WalkError), - + #[cfg(feature = "migration")] #[error(transparent)] IgnoreError(#[from] ignore::Error), @@ -135,6 +118,7 @@ pub enum Error { #[error("Invalid argument: {0}")] InvalidArgument(Str), + #[cfg(feature = "migration")] #[error(transparent)] AstGrepConfigError(#[from] ast_grep_config::RuleConfigError), diff --git a/crates/vite_migration/Cargo.toml b/crates/vite_migration/Cargo.toml index 9df1df084d..436a5c3e89 100644 --- a/crates/vite_migration/Cargo.toml +++ b/crates/vite_migration/Cargo.toml @@ -16,7 +16,7 @@ ignore = { workspace = true } rayon = { workspace = true } regex = { workspace = true } serde_json = { workspace = true, features = ["preserve_order"] } -vite_error = { workspace = true } +vite_error = { workspace = true, features = ["migration"] } [dev-dependencies] tempfile = { workspace = true }