Skip to content

Commit

Permalink
chore: refactor size check
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Apr 3, 2023
1 parent b64751f commit 1a3a28f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"scripts": {
"release": "node scripts/release.mjs",
"size": "pnpm run -r size",
"size": "node scripts/check-size.mjs",
"build": "pnpm run -r build",
"build:dts": "pnpm run -r build:dts",
"docs:api": "pnpm run --filter ./packages/docs -r docs:api",
Expand Down
34 changes: 19 additions & 15 deletions scripts/check-size.js → scripts/check-size.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const fs = require('fs').promises
const path = require('path')
const chalk = require('chalk')
const { gzipSync } = require('zlib')
const { compress } = require('brotli')
import fs from 'node:fs/promises'
import path from 'node:path'
import chalk from 'chalk'
import { gzipSync } from 'zlib'
import { compress } from 'brotli'

const __dirname = path.dirname(new URL(import.meta.url).pathname)

async function checkFileSize(filePath) {
const stat = await fs.stat(filePath).catch(() => null)
Expand All @@ -27,14 +29,16 @@ async function checkFileSize(filePath) {
}

;(async () => {
const files = [
path.resolve(__dirname, '../packages/router/size-checks/dist/webRouter.js'),
path.resolve(
__dirname,
'../packages/router/dist/vue-router.global.prod.js'
),
]
for (const file of files) {
await checkFileSize(file)
}
await Promise.all(
[
path.resolve(
__dirname,
'../packages/router/size-checks/dist/webRouter.js'
),
path.resolve(
__dirname,
'../packages/router/dist/vue-router.global.prod.js'
),
].map(checkFileSize)
)
})()

0 comments on commit 1a3a28f

Please sign in to comment.