Skip to content

Commit

Permalink
Report actual vendors bundle limit
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechszocs committed Sep 9, 2020
1 parent 2fa813f commit 890e014
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ fi
MAX_BYTES=2726298 # ~2.6 MiB
VENDORS_MAIN_BYTES=$(jq -r '.assets[] | select(.name | match("^vendors~main-chunk.*js$")) | .size' public/dist/stats.json)
DISPLAY_VALUE=$(awk "BEGIN {printf \"%.2f\n\", $VENDORS_MAIN_BYTES/1024/1024}")
MAX_DISPLAY_VALUE=$(awk "BEGIN {printf \"%.2f\n\", $MAX_BYTES/1024/1024}")

echo "Main vendor bundle size: $DISPLAY_VALUE MiB"
if (( VENDORS_MAIN_BYTES > MAX_BYTES )); then
echo "FAILURE: Main vendor bundle is larger than the 2.5 MiB limit."
echo "FAILURE: Main vendor bundle is larger than the $MAX_DISPLAY_VALUE MiB limit."
echo "If you haven't added a new dependency, an import might have accidentally pulled an existing dependency into the main vendor bundle."
echo "If adding a large dependency, consider lazy loading the component with AsyncComponent."
exit 1
Expand Down

0 comments on commit 890e014

Please sign in to comment.