Skip to content

Commit

Permalink
ci: improve size script
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 23, 2021
1 parent c1cf26d commit f27a98b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: size
files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/size-check.global.prod.js
files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/index.js
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
"scripts": {
"dev": "node scripts/dev.js",
"build": "node scripts/build.js",
"size": "node scripts/build.js vue runtime-dom size-check -p -f global",
"size": "run-s size-global size-baseline",
"size-global": "node scripts/build.js vue runtime-dom -f global -p",
"size-baseline": "node scripts/build.js vue runtime-dom runtime-core reactivity shared -f esm-bundler && cd packages/size-check && vite build",
"lint": "eslint --ext .ts packages/*/src/**.ts",
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
"test": "node scripts/build.js vue -f global -d && jest --runInBand",
"test-dts": "node scripts/build.js shared reactivity runtime-core runtime-dom -dt -f esm-bundler && yarn test-dts-only",
"test-dts-only": "tsc -p ./test-dts/tsconfig.json && tsc -p ./test-dts/tsconfig.build.json",
"release": "node scripts/release.js",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"dev-compiler": "npm-run-all --parallel \"dev template-explorer\" serve",
"dev-sfc": "npm-run-all --parallel \"dev compiler-sfc -f esm-browser\" \"dev runtime-core -f esm-bundler\" \"dev runtime-dom -f esm-bundler\" serve-sfc-playground",
"dev-compiler": "run-p \"dev template-explorer\" serve",
"dev-sfc": "run-p \"dev compiler-sfc -f esm-browser\" \"dev runtime-core -f esm-bundler\" \"dev runtime-dom -f esm-bundler\" serve-sfc-playground",
"serve-sfc-playground": "vite packages/sfc-playground --host",
"serve": "serve",
"open": "open http://localhost:5000/packages/template-explorer/local.html",
Expand Down
10 changes: 5 additions & 5 deletions packages/size-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@vue/size-check",
"version": "3.2.16",
"private": true,
"buildOptions": {
"name": "Vue",
"formats": [
"global"
]
"scripts": {
"build": "vite build"
},
"devDependencies": {
"vite": "^2.5.10"
}
}
2 changes: 1 addition & 1 deletion packages/size-check/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, createApp } from '@vue/runtime-dom'
import { h, createApp } from 'vue'

// The bare minimum code required for rendering something to the screen
createApp({
Expand Down
10 changes: 10 additions & 0 deletions packages/size-check/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
build: {
rollupOptions: {
input: ['src/index.ts'],
output: {
entryFileNames: `[name].js`
}
}
}
}
6 changes: 4 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async function build(target) {
}

function checkAllSizes(targets) {
if (devOnly) {
if (devOnly || (formats && !formats.includes('global'))) {
return
}
console.log()
Expand All @@ -168,7 +168,9 @@ function checkAllSizes(targets) {
function checkSize(target) {
const pkgDir = path.resolve(`packages/${target}`)
checkFileSize(`${pkgDir}/dist/${target}.global.prod.js`)
checkFileSize(`${pkgDir}/dist/${target}.runtime.global.prod.js`)
if (!formats || formats.includes('global-runtime')) {
checkFileSize(`${pkgDir}/dist/${target}.runtime.global.prod.js`)
}
}

function checkFileSize(filePath) {
Expand Down

0 comments on commit f27a98b

Please sign in to comment.