Skip to content

Commit

Permalink
test: add bundles size check (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Jun 20, 2024
1 parent e45ae8d commit c1a160c
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 8 deletions.
37 changes: 37 additions & 0 deletions .size-limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"name": "zx/core",
"path": ["build/core.cjs", "build/util.cjs", "build/vendor-core.cjs"],
"limit": "70 kB",
"brotli": false,
"gzip": false
},
{
"name": "zx/index",
"path": "build/*.{js,cjs}",
"limit": "842 kB",
"brotli": false,
"gzip": false
},
{
"name": "dts libdefs",
"path": "build/*.d.ts",
"limit": "31 kB",
"brotli": false,
"gzip": false
},
{
"name": "vendor",
"path": "build/vendor-*",
"limit": "803 kB",
"brotli": false,
"gzip": false
},
{
"name": "all",
"path": "build/*",
"limit": "875 kB",
"brotli": false,
"gzip": false
}
]
172 changes: 170 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@
"build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all",
"build:dts": "tsc --project tsconfig.prod.json && node scripts/build-dts.mjs",
"pretest": "npm run build",
"test": "npm run test:unit && npm run test:types && npm run test:license",
"test": "npm run test:size && npm run test:unit && npm run test:types && npm run test:license",
"test:unit": "node ./test/all.test.js",
"test:circular": "madge --circular src/*",
"test:types": "tsd",
"test:license": "node ./test/extra.test.js",
"test:size": "size-limit",
"test:smoke:tsx": "tsx test/smoke/ts.test.ts",
"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",
"test:smoke:ts-node": "node --loader ts-node/esm test/smoke/ts.test.ts",
Expand All @@ -89,6 +90,7 @@
"@types/node": ">=20"
},
"devDependencies": {
"@size-limit/file": "^11.1.4",
"@types/fs-extra": "^11.0.4",
"@types/minimist": "^1.2.5",
"@types/node": ">=20.11.30",
Expand All @@ -114,6 +116,7 @@
"minimist": "^1.2.8",
"node-fetch-native": "^1.6.4",
"prettier": "^3.3.2",
"size-limit": "^11.1.4",
"ts-node": "^10.9.2",
"tsd": "^0.31.1",
"tsx": "^4.15.6",
Expand Down
6 changes: 1 addition & 5 deletions scripts/build-dts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ for (const i in results) {
}

// Replaces redundant triple-slash directives
for (const dts of await glob([
'build/**/*.d.ts',
'!build/vendor.d.ts',
'!build/core-vendor.d.ts',
])) {
for (const dts of await glob(['build/**/*.d.ts', '!build/vendor-*.d.ts'])) {
const contents = (await fs.readFile(dts, 'utf8'))
.split('\n')
.filter((line) => !line.startsWith('/// <reference types'))
Expand Down

0 comments on commit c1a160c

Please sign in to comment.