Skip to content

ci: size report #8992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: baseline
  • Loading branch information
sxzz committed Aug 20, 2023
commit 789bd546651c5ad27b53d0005d3af89c51ca7d3d
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build-dts": "tsc -p tsconfig.build.json && rollup -c rollup.dts.config.js",
"size": "run-s size-global size-baseline",
"size-global": "node scripts/build.js vue runtime-dom -f global -p --size",
"size-baseline": "node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js runtime-dom runtime-core reactivity shared -f esm-bundler && tsx scripts/export-size.ts && cd packages/size-check && vite build",
"size-baseline": "node scripts/build.js vue -f esm-bundler-runtime && node scripts/build.js runtime-dom runtime-core reactivity shared -f esm-bundler && tsx scripts/export-size.ts && cd packages/size-check && pnpm build && pnpm size",
"check": "tsc --incremental --noEmit",
"lint": "eslint --cache --ext .ts packages/*/{src,__tests__}/**.ts",
"format": "prettier --write --cache \"**/*.[tj]s?(x)\"",
Expand Down
3 changes: 2 additions & 1 deletion packages/size-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "module",
"private": true,
"scripts": {
"build": "vite build"
"build": "vite build",
"size": "tsx ./size-report.ts"
},
"dependencies": {
"vue": "workspace:*"
Expand Down
12 changes: 8 additions & 4 deletions packages/size-check/size-report.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// @ts-check
import { brotliCompress, gzip } from 'node:zlib'
import { promisify } from 'node:util'
import { readFile, writeFile } from 'node:fs/promises'
import path from 'node:path'
import prettyBytes from 'pretty-bytes'
import { fileURLToPath } from 'node:url'

export async function sizeReport() {
const file = await readFile('dist/index.js')
const dirname = path.resolve(fileURLToPath(import.meta.url), '..')

run()

async function run() {
const file = await readFile(path.resolve(dirname, 'dist/index.js'))

const gzipped = await promisify(gzip)(file)
console.log(`gzip: ${prettyBytes(gzipped.length)}`)
Expand All @@ -15,7 +19,7 @@ export async function sizeReport() {
console.log(`brotli: ${prettyBytes(brotli.length)}`)

await writeFile(
path.resolve(__dirname, '../../temp/size/_baseline.json'),
path.resolve(dirname, '../../temp/size/_baseline.json'),
JSON.stringify({
size: file.length,
gzip: gzipped.length,
Expand Down
9 changes: 1 addition & 8 deletions packages/size-check/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineConfig } from 'vite'
import { sizeReport } from './size-report'

export default defineConfig({
define: {
Expand All @@ -14,11 +13,5 @@ export default defineConfig({
}
},
minify: 'terser'
},
plugins: [
{
name: 'size-report',
buildEnd: () => sizeReport()
}
]
}
})