From a466a601e49b76845ea5b9e9cc0bce4de4c63216 Mon Sep 17 00:00:00 2001 From: Toma <847775+redfish4ktc@users.noreply.github.com> Date: Sun, 4 Oct 2026 07:07:18 +0200 Subject: [PATCH 1/2] feat: add a bundle size summary to the build all examples script The sizes are reported in PR descriptions, in the maxGraph release notes and in a follow-up spreadsheet to track how the size of an app changes between maxGraph versions. Collecting them from the per-file listing was manual, so the script now ends with a Markdown table and a CSV line, in the same format as the build script of the maxGraph repository. Unlike the maxGraph script, which keeps only the largest JS file, all JS files of an example are summed: Farm puts part of the maxGraph code in its small file. The app code is counted too, which is fine since it barely changes and only the variations matter. The rsbuild index file is excluded as it only holds the HTML generation and the app initialization. SvelteKit is left out, as its server and client files cannot be told apart reliably for now. --- build-all-examples.bash | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/build-all-examples.bash b/build-all-examples.bash index 762a3f8..61b10ea 100755 --- a/build-all-examples.bash +++ b/build-all-examples.bash @@ -98,6 +98,49 @@ for dir in "${EXAMPLE_DIRS[@]}"; do fi done +# Sizes are tracked to compare maxGraph versions, so the app code included in the bundles is not a concern as it +# barely changes. All JS files are summed, as some bundlers (Farm) split the maxGraph code across several files. +# Print the size in kB of the JS files to keep for an example. +compute_example_size() { + local example_dir="$1" + local find_exclusions=() + case "$(basename "$example_dir")" in + # The index file only contains the HTML generation and the app initialization. + rsbuild-ts) find_exclusions=(-not -name "index.*.js") ;; + esac + find "$example_dir/dist" -name "*.js" -type f "${find_exclusions[@]}" -printf '%s\n' | LC_NUMERIC=C awk ' + { total += $1 } + END { if (NR > 0) printf "%.2f", total / 1000 } + ' +} + +# Server and client files of SvelteKit cannot be told apart reliably for now. +SIZE_UNTRACKED_EXAMPLE="sveltekit-ts" +SIZE_EXAMPLE_NAMES=() +SIZE_VALUES=() +for dir in "${EXAMPLE_DIRS[@]}"; do + example_name="$(basename "$dir")" + [[ "$example_name" = "$SIZE_UNTRACKED_EXAMPLE" ]] && continue + example_size="" + [[ -d "$dir/dist" ]] && example_size=$(compute_example_size "$dir") + SIZE_EXAMPLE_NAMES+=("$example_name") + SIZE_VALUES+=("${example_size:-N/A}") +done + +print_section_title "Markdown table of bundle sizes" +echo +echo "| Example | before | now |" +echo "| --- | --- | --- |" +for ((i = 0; i < ${#SIZE_EXAMPLE_NAMES[@]}; i++)); do + size="${SIZE_VALUES[$i]}" + [[ "$size" != "N/A" ]] && size="$size kB" + echo "| ${SIZE_EXAMPLE_NAMES[$i]} | kB | $size |" +done + +print_section_title "CSV of bundle sizes (kB)" +echo +(IFS=,; echo "${SIZE_EXAMPLE_NAMES[*]}"; echo "${SIZE_VALUES[*]}") + if [[ ${#FAILED_EXAMPLES[@]} -gt 0 ]]; then print_section_title "Failed builds" echo From b7e39ffeca1d085bc16c3899ac0cc0c92272c3f4 Mon Sep 17 00:00:00 2001 From: Toma <847775+redfish4ktc@users.noreply.github.com> Date: Sun, 4 Oct 2026 07:52:11 +0200 Subject: [PATCH 2/2] style: add a default case to the size computation of the build script SonarCloud flags a case statement without a default branch. All examples other than rsbuild keep every JS file, so the default branch is intentionally empty. --- build-all-examples.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/build-all-examples.bash b/build-all-examples.bash index 61b10ea..04f301e 100755 --- a/build-all-examples.bash +++ b/build-all-examples.bash @@ -107,6 +107,7 @@ compute_example_size() { case "$(basename "$example_dir")" in # The index file only contains the HTML generation and the app initialization. rsbuild-ts) find_exclusions=(-not -name "index.*.js") ;; + *) ;; esac find "$example_dir/dist" -name "*.js" -type f "${find_exclusions[@]}" -printf '%s\n' | LC_NUMERIC=C awk ' { total += $1 }