Skip to content

Commit ed22d9c

Browse files
committed
chore: wip
1 parent 41b4a40 commit ed22d9c

File tree

7 files changed

+375
-15
lines changed

7 files changed

+375
-15
lines changed

.github/workflows/export-size.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
node-version: ${{ matrix.node-version }}
2828
cache: pnpm
2929

30-
- uses: antfu/export-size-action@v1
31-
with:
32-
github_token: ${{ secrets.GITHUB_TOKEN }}
33-
paths: .stacks/core/actions,.stacks/core/ai,.stacks/core/alias,.stacks/core/analytics,.stacks/core/arrays,.stacks/core/auth,.stacks/core/buddy,.stacks/core/build,.stacks/core/cache,.stacks/core/cli,.stacks/core/cloud,.stacks/core/collections,.stacks/core/config,.stacks/core/database,.stacks/core/development,.stacks/core/dns,.stacks/core/docs,.stacks/core/email,.stacks/core/error-handling,.stacks/core/events,.stacks/core/git,.stacks/core/health,.stacks/core/logging,.stacks/core/lint,.stacks/core/modules,.stacks/core/notifications,.stacks/core/objects,.stacks/core/orm,.stacks/core/pages,.stacks/core/path,.stacks/core/query-builder,.stacks/core/payments,.stacks/core/push,.stacks/core/realtime,.stacks/core/repl,.stacks/core/router,.stacks/core/scheduler,.stacks/core/search-engine,.stacks/core/security,.stacks/core/server,.stacks/core/signals,.stacks/core/slug,.stacks/core/sms,.stacks/core/storage,.stacks/core/strings,.stacks/core/testing,.stacks/core/tinker,.stacks/core/types,.stacks/core/ui,.stacks/core/utils,.stacks/core/validation,.stacks/core/vite-plugin
34-
build_script: pnpm --filter=./.stacks build
30+
# - uses: antfu/export-size-action@v1
31+
# with:
32+
# github_token: ${{ secrets.GITHUB_TOKEN }}
33+
# paths: .stacks/core/actions,.stacks/core/ai,.stacks/core/alias,.stacks/core/analytics,.stacks/core/arrays,.stacks/core/auth,.stacks/core/buddy,.stacks/core/build,.stacks/core/cache,.stacks/core/cli,.stacks/core/cloud,.stacks/core/collections,.stacks/core/config,.stacks/core/database,.stacks/core/development,.stacks/core/dns,.stacks/core/docs,.stacks/core/email,.stacks/core/error-handling,.stacks/core/events,.stacks/core/git,.stacks/core/health,.stacks/core/logging,.stacks/core/lint,.stacks/core/modules,.stacks/core/notifications,.stacks/core/objects,.stacks/core/orm,.stacks/core/pages,.stacks/core/path,.stacks/core/query-builder,.stacks/core/payments,.stacks/core/push,.stacks/core/realtime,.stacks/core/repl,.stacks/core/router,.stacks/core/scheduler,.stacks/core/search-engine,.stacks/core/security,.stacks/core/server,.stacks/core/signals,.stacks/core/slug,.stacks/core/sms,.stacks/core/storage,.stacks/core/strings,.stacks/core/testing,.stacks/core/tinker,.stacks/core/types,.stacks/core/ui,.stacks/core/utils,.stacks/core/validation,.stacks/core/vite-plugin
34+
# build_script: pnpm --filter=./.stacks build

.stacks/core/utils/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"scripts": {
4747
"build": "unbuild",
4848
"dev": "unbuild --stub",
49-
"typecheck": "tsc --noEmit"
49+
"typecheck": "tsc --noEmit",
50+
"size": "tsx scripts/export-size.ts"
5051
},
5152
"peerDependencies": {
5253
"@dinero.js/currencies": "2.0.0-alpha.14",
@@ -65,6 +66,7 @@
6566
"@vueuse/shared": "^10.2.1",
6667
"defu": "^6.1.2",
6768
"dinero.js": "2.0.0-alpha.14",
69+
"export-size": "^0.5.2",
6870
"fast-glob": "^3.3.0",
6971
"js-yaml": "^4.1.0",
7072
"kolorist": "1.8.0",
@@ -90,6 +92,7 @@
9092
"detect-indent": "^7.0.1",
9193
"detect-newline": "^4.0.0",
9294
"dinero.js": "2.0.0-alpha.14",
95+
"export-size": "^0.5.2",
9396
"fast-glob": "^3.3.0",
9497
"js-yaml": "^4.1.0",
9598
"kolorist": "1.8.0",
@@ -100,6 +103,7 @@
100103
"yaml": "^2.3.1"
101104
},
102105
"devDependencies": {
103-
"@stacksjs/development": "workspace:*"
106+
"@stacksjs/development": "workspace:*",
107+
"markdown-table": "^3.0.3"
104108
}
105109
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// inspired by vue-use
2+
import { markdownTable } from 'markdown-table'
3+
import filesize from 'filesize'
4+
import { fs } from '@stacksjs/storage'
5+
import type { PackageManifest } from '@vueuse/metadata'
6+
import { getExportsSize } from '../src/export-size'
7+
import { version } from '../package.json'
8+
9+
export const packages: PackageManifest[] = [
10+
{
11+
name: 'metadata',
12+
display: 'Metadata for VueUse functions',
13+
manualImport: true,
14+
iife: false,
15+
utils: true,
16+
target: 'node14',
17+
},
18+
{
19+
name: 'shared',
20+
display: 'Shared utilities',
21+
},
22+
{
23+
name: 'core',
24+
display: 'VueUse',
25+
description: 'Collection of essential Vue Composition Utilities',
26+
},
27+
{
28+
name: 'components',
29+
display: 'Components',
30+
description: 'Renderless components for VueUse',
31+
author: 'Jacob Clevenger<https://github.com/wheatjs>',
32+
external: [
33+
'@vueuse/core',
34+
'@vueuse/shared',
35+
],
36+
},
37+
{
38+
name: 'math',
39+
display: 'Math',
40+
description: 'Math functions for VueUse',
41+
external: [
42+
'@vueuse/shared',
43+
],
44+
},
45+
]
46+
47+
async function run() {
48+
// made shared library imported can resolve correctly
49+
// const packagesRoot = resolve(__dirname, '../../..', 'core')
50+
// await fs.writeFile(join(packagesRoot, 'shared/index.mjs'), 'export * from "./dist/index.mjs"', 'utf-8')
51+
// await fs.writeFile(join(packagesRoot, 'core/index.mjs'), 'export * from "./dist/index.mjs"', 'utf-8')
52+
// await fs.copy(join(packagesRoot, 'shared/dist'), join(packagesRoot, 'core/dist/node_modules/@vueuse/shared'), { overwrite: true })
53+
54+
let md = '# Export size\n\n'
55+
const mdJSON = {} as { [name: string]: string }
56+
md += 'generated by [export-size](https://github.com/antfu/export-size)<br>\n'
57+
md += `version: ${version}<br>\n`
58+
md += `date: ${new Date().toISOString()}\n\n`
59+
60+
md += '> Please note this is bundle size for each individual APIs (excluding Vue). '
61+
md += 'Since we have a lot shared utilities underneath each function, importing two '
62+
md += 'different functions does NOT necessarily mean the bundle size will be the sum of them (usually smaller). '
63+
md += 'Depends on the bundler and minifier you use, the final result might vary, this list is for reference only.'
64+
md += '\n\n'
65+
66+
for (const pkg of [...packages.slice(2), packages[1]]) {
67+
const { exports, packageJSON } = await getExportsSize({
68+
pkg: `./packages/${pkg.name}/dist`,
69+
output: false,
70+
bundler: 'rollup',
71+
external: ['vue-demi', ...(pkg.external || [])],
72+
includes: ['@vueuse/shared'],
73+
})
74+
75+
md += `<kbd>${packageJSON.name}</kbd>\n\n`
76+
77+
md += markdownTable([
78+
['Function', 'min+gzipped'],
79+
// eslint-disable-next-line ow3/no-cjs-exports
80+
...exports.map((i) => {
81+
mdJSON[i.name] = filesize(i.minzipped)
82+
return [`\`${i.name}\``, filesize(i.minzipped)]
83+
}),
84+
])
85+
86+
md += '\n\n'
87+
}
88+
// await fs.remove(join(packagesRoot, 'shared/index.mjs'))
89+
// await fs.remove(join(packagesRoot, 'core/index.mjs'))
90+
await fs.writeFile('../../export-size.md', md, 'utf-8')
91+
await fs.writeJSON('packages/export-size.json', mdJSON, { spaces: 2 })
92+
}
93+
94+
run()

.stacks/core/utils/src/export-size.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { getExportsSize } from 'export-size'

.stacks/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export * from '@stacksjs/sms'
9797
export * as sms from '@stacksjs/sms'
9898
export * from '@stacksjs/storage'
9999
export * as storage from '@stacksjs/storage'
100-
export * from '@stacksjs/strings'
100+
// export * from '@stacksjs/strings'
101101
export * as strings from '@stacksjs/strings'
102102
export * from '@stacksjs/testing'
103103
export * as testing from '@stacksjs/testing'

.stacks/vcs/github/workflows/export-size.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
node-version: ${{ matrix.node-version }}
2727
cache: pnpm
2828

29-
- uses: antfu/export-size-action@v1
30-
with:
31-
github_token: ${{ secrets.GITHUB_TOKEN }}
32-
paths: .stacks/core/actions,.stacks/core/arrays,.stacks/core/auth,.stacks/core/build,.stacks/core/cache,.stacks/core/cli,.stacks/core/cloud,.stacks/core/config,.stacks/core/collections,.stacks/core/database,.stacks/core/datetime,.stacks/core/docs,.stacks/core/error-handling,.stacks/core/git,.stacks/core/lint,.stacks/core/modules,.stacks/core/notifications,.stacks/core/objects,.stacks/core/path,.stacks/core/realtime,.stacks/core/router,.stacks/core/security,.stacks/core/server,.stacks/core/storage,.stacks/core/strings,.stacks/core/testing,.stacks/core/types,.stacks/core/ui,.stacks/core/utils,.stacks/core/x-ray
29+
# - uses: antfu/export-size-action@v1
30+
# with:
31+
# github_token: ${{ secrets.GITHUB_TOKEN }}
32+
# paths: .stacks/core/actions,.stacks/core/arrays,.stacks/core/auth,.stacks/core/build,.stacks/core/cache,.stacks/core/cli,.stacks/core/cloud,.stacks/core/config,.stacks/core/collections,.stacks/core/database,.stacks/core/datetime,.stacks/core/docs,.stacks/core/error-handling,.stacks/core/git,.stacks/core/lint,.stacks/core/modules,.stacks/core/notifications,.stacks/core/objects,.stacks/core/path,.stacks/core/realtime,.stacks/core/router,.stacks/core/security,.stacks/core/server,.stacks/core/storage,.stacks/core/strings,.stacks/core/testing,.stacks/core/types,.stacks/core/ui,.stacks/core/utils,.stacks/core/x-ray

0 commit comments

Comments
 (0)