From 37701a88c0a092d3d12e0125320122eaebf55e74 Mon Sep 17 00:00:00 2001 From: JayFate <48240828+JayFate@users.noreply.github.com> Date: Mon, 10 Apr 2023 14:06:28 +0800 Subject: [PATCH] chore: replace brotli with node:zlib (#8045) Signed-off-by: JayFate <48240828+JayFate@users.noreply.github.com> --- package.json | 1 - packages/size-check/brotli.js | 4 ++-- pnpm-lock.yaml | 8 -------- scripts/build.js | 5 ++--- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 4f565fdb2..35d89e177 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "@typescript-eslint/parser": "^5.56.0", "@vitest/coverage-istanbul": "^0.29.7", "@vue/consolidate": "0.17.3", - "brotli": "^1.3.2", "chalk": "^4.1.0", "conventional-changelog-cli": "^2.0.31", "enquirer": "^2.3.2", diff --git a/packages/size-check/brotli.js b/packages/size-check/brotli.js index 1e7ea0c77..f9dedac0b 100644 --- a/packages/size-check/brotli.js +++ b/packages/size-check/brotli.js @@ -1,6 +1,6 @@ -const { compress } = require('brotli') +const { brotliCompressSync } = require('zlib') const file = require('fs').readFileSync('dist/index.js') -const compressed = compress(file) +const compressed = brotliCompressSync(file) const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb' console.log(`brotli: ${compressedSize}`) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 633220967..73e9b2c6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,7 +18,6 @@ importers: '@typescript-eslint/parser': ^5.56.0 '@vitest/coverage-istanbul': ^0.29.7 '@vue/consolidate': 0.17.3 - brotli: ^1.3.2 chalk: ^4.1.0 conventional-changelog-cli: ^2.0.31 enquirer: ^2.3.2 @@ -65,7 +64,6 @@ importers: '@typescript-eslint/parser': 5.56.0_qesohl5arz7pvqyycxtsqomlr4 '@vitest/coverage-istanbul': 0.29.7_vitest@0.29.7 '@vue/consolidate': 0.17.3 - brotli: 1.3.3 chalk: 4.1.2 conventional-changelog-cli: 2.2.2 enquirer: 2.3.6 @@ -1467,12 +1465,6 @@ packages: fill-range: 7.0.1 dev: true - /brotli/1.3.3: - resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==} - dependencies: - base64-js: 1.5.1 - dev: true - /browserslist/4.21.5: resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} diff --git a/scripts/build.js b/scripts/build.js index 5272c49c3..05ed32ebc 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -20,8 +20,7 @@ import fs from 'node:fs/promises' import { existsSync, readFileSync, rmSync } from 'node:fs' import path from 'node:path' import minimist from 'minimist' -import { gzipSync } from 'node:zlib' -import { compress } from 'brotli' +import { gzipSync, brotliCompressSync } from 'node:zlib' import chalk from 'chalk' import execa from 'execa' import { cpus } from 'node:os' @@ -143,7 +142,7 @@ function checkFileSize(filePath) { const minSize = (file.length / 1024).toFixed(2) + 'kb' const gzipped = gzipSync(file) const gzippedSize = (gzipped.length / 1024).toFixed(2) + 'kb' - const compressed = compress(file) + const compressed = brotliCompressSync(file) // @ts-ignore const compressedSize = (compressed.length / 1024).toFixed(2) + 'kb' console.log(