Skip to content

Commit 9b850e0

Browse files
committed
test: add bundles size check
1 parent e45ae8d commit 9b850e0

File tree

4 files changed

+205
-8
lines changed

4 files changed

+205
-8
lines changed

.size-limit.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
"name": "zx/core",
4+
"path": ["build/core.cjs", "build/util.cjs", "build/vendor-core.cjs"],
5+
"limit": "70 kB",
6+
"brotli": false,
7+
"gzip": false
8+
},
9+
{
10+
"name": "zx/index",
11+
"path": "build/*.{js,cjs}",
12+
"limit": "842 kB",
13+
"brotli": false,
14+
"gzip": false
15+
},
16+
{
17+
"name": "dts libdefs",
18+
"path": "build/*.d.ts",
19+
"limit": "31 kB",
20+
"brotli": false,
21+
"gzip": false
22+
},
23+
{
24+
"name": "all",
25+
"path": "build/*",
26+
"limit": "875 kB",
27+
"brotli": false,
28+
"gzip": false
29+
}
30+
]

package-lock.json

+170-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@
6868
"build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all",
6969
"build:dts": "tsc --project tsconfig.prod.json && node scripts/build-dts.mjs",
7070
"pretest": "npm run build",
71-
"test": "npm run test:unit && npm run test:types && npm run test:license",
71+
"test": "npm run test:size && npm run test:unit && npm run test:types && npm run test:license",
7272
"test:unit": "node ./test/all.test.js",
7373
"test:circular": "madge --circular src/*",
7474
"test:types": "tsd",
7575
"test:license": "node ./test/extra.test.js",
76+
"test:size": "size-limit",
7677
"test:smoke:tsx": "tsx test/smoke/ts.test.ts",
7778
"test:smoke:tsc": "cd test/smoke && mkdir -p node_modules && ln -s ../../../ ./node_modules/zx; tsc --esModuleInterop --module node16 --rootDir . --outdir ./temp ts.test.ts && node ./temp/ts.test.js",
7879
"test:smoke:ts-node": "node --loader ts-node/esm test/smoke/ts.test.ts",
@@ -89,6 +90,7 @@
8990
"@types/node": ">=20"
9091
},
9192
"devDependencies": {
93+
"@size-limit/file": "^11.1.4",
9294
"@types/fs-extra": "^11.0.4",
9395
"@types/minimist": "^1.2.5",
9496
"@types/node": ">=20.11.30",
@@ -114,6 +116,7 @@
114116
"minimist": "^1.2.8",
115117
"node-fetch-native": "^1.6.4",
116118
"prettier": "^3.3.2",
119+
"size-limit": "^11.1.4",
117120
"ts-node": "^10.9.2",
118121
"tsd": "^0.31.1",
119122
"tsx": "^4.15.6",

scripts/build-dts.mjs

+1-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ for (const i in results) {
9999
}
100100

101101
// Replaces redundant triple-slash directives
102-
for (const dts of await glob([
103-
'build/**/*.d.ts',
104-
'!build/vendor.d.ts',
105-
'!build/core-vendor.d.ts',
106-
])) {
102+
for (const dts of await glob(['build/**/*.d.ts', '!build/vendor-*.d.ts'])) {
107103
const contents = (await fs.readFile(dts, 'utf8'))
108104
.split('\n')
109105
.filter((line) => !line.startsWith('/// <reference types'))

0 commit comments

Comments
 (0)