Skip to content

Commit f8e2404

Browse files
add size check
1 parent 510e755 commit f8e2404

File tree

3 files changed

+160
-8
lines changed

3 files changed

+160
-8
lines changed

.github/workflows/preview.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,35 @@ jobs:
4040
run: |
4141
npm pack
4242
43-
43+
- name: Check package size and create comment
44+
working-directory: ./typescript
45+
run: |
46+
# Run size-limit to get detailed size analysis
47+
SIZE_OUTPUT=$(npm run size 2>&1 || echo "Size check failed")
48+
49+
# Get package file info
50+
PACKAGE_FILE=$(ls *.tgz | head -1)
51+
PACKAGE_SIZE=$(stat -c%s "$PACKAGE_FILE" 2>/dev/null || stat -f%z "$PACKAGE_FILE")
52+
PACKAGE_SIZE_KB=$((PACKAGE_SIZE / 1024))
53+
54+
# Create comment body
55+
cat > /tmp/size_comment.md << EOF
56+
## 📦 Package Size Report
57+
58+
**Package:** \`$PACKAGE_FILE\` (${PACKAGE_SIZE_KB} KB compressed)
59+
60+
### Size Limit Analysis:
61+
\`\`\`
62+
$SIZE_OUTPUT
63+
\`\`\`
64+
65+
Preview package is ready for testing! 🚀
66+
EOF
67+
68+
# Post comment to PR
69+
gh pr comment --body-file /tmp/size_comment.md
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4472

4573
- name: List files in typescript dir
4674
working-directory: ./typescript

typescript/package-lock.json

Lines changed: 107 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/package.json

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"check": "tsc --noEmit",
2121
"lint": "eslint src --ext .ts,.tsx",
2222
"lint:fix": "eslint src --ext .ts,.tsx --fix",
23-
"prepare": "husky"
23+
"prepare": "husky",
24+
"size": "size-limit"
2425
},
2526
"keywords": [
2627
"json",
@@ -32,6 +33,7 @@
3233
"license": "MIT",
3334
"devDependencies": {
3435
"@eslint/js": "^9.28.0",
36+
"@size-limit/preset-small-lib": "^11.2.0",
3537
"@types/jest": "^29.5.14",
3638
"@types/node": "^22.15.27",
3739
"@types/react": "^19.1.5",
@@ -52,17 +54,19 @@
5254
"identity-obj-proxy": "^3.0.0",
5355
"jest": "^29.7.0",
5456
"json-schema-to-typescript": "^15.0.4",
57+
"json5": "^2.2.3",
5558
"lint-staged": "^15.5.2",
5659
"prettier": "3.5.3",
60+
"puppeteer": "^24.9.0",
61+
"size-limit": "^11.2.0",
62+
"strip-json-comments": "^5.0.2",
5763
"ts-jest": "^29.3.4",
5864
"ts-node": "^10.9.2",
5965
"tsup": "^8.5.0",
60-
"typescript": "^5.8.3",
61-
"puppeteer": "^24.9.0",
62-
"strip-json-comments": "^5.0.2",
63-
"json5": "^2.2.3"
66+
"typescript": "^5.8.3"
6467
},
6568
"dependencies": {
69+
"@types/katex": "^0.16.7",
6670
"ajv": "^8.17.1",
6771
"ajv-formats": "^3.0.1",
6872
"katex": "^0.16.22",
@@ -96,5 +100,19 @@
96100
"*.{ts,tsx}": [
97101
"eslint --fix"
98102
]
99-
}
103+
},
104+
"size-limit": [
105+
{
106+
"path": "dist/index.js",
107+
"limit": "20 KB"
108+
},
109+
{
110+
"path": "dist/index.mjs",
111+
"limit": "20 KB"
112+
},
113+
{
114+
"path": "dist/index.css",
115+
"limit": "20 KB"
116+
}
117+
]
100118
}

0 commit comments

Comments
 (0)