Skip to content

Commit c77c8e3

Browse files
committed
chore: release version 1.2.4 with optimized DevTools extension assets
- Reduced the size of published DevTools extension assets from ~43 MB to ~5.5 MB on disk and ~1 MB compressed by tree-shaking Material icons and omitting local CanvasKit. - Updated README and hit_devtools_extension README to reflect changes in the build process and asset management. - Enhanced build script to ensure efficient asset handling and pruning of unused files.
1 parent 5f887f1 commit c77c8e3

4 files changed

Lines changed: 51 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## 1.2.4
22

3+
- Shrink the published DevTools extension assets (~43 MB → ~5.5 MB on disk,
4+
~1 MB compressed archive): tree-shake Material icons and omit local
5+
CanvasKit (loaded from the Flutter CDN at runtime). See `tool/build_devtools.sh`.
36
- Add **Probe** mode to the hit DevTools extension: tap the connected app to
47
list every hit area under that point (`Hit.probed`) with diagnostic notes
58
for misses. Mutually exclusive with Select; reuses cancelled pointer

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,15 @@ HitLayer(
347347
```
348348

349349
Rebuild the embedded web assets after changing the
350-
extension UI:
350+
extension UI (run before `pub publish`):
351351

352352
```bash
353353
./tool/build_devtools.sh
354354
```
355355

356+
That script tree-shakes icons and drops unused local CanvasKit so the
357+
published archive stays small (~1 MB compressed).
358+
356359
See [DevTools extensions](https://docs.flutter.dev/tools/devtools/extensions)
357360
and [`devtools_extensions`](https://pub.dev/packages/devtools_extensions).
358361

‎hit_devtools_extension/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Source lives here so it does not inflate `package:hit` for app users. Built
66
assets are copied into `../extension/devtools/build` and shipped with the
77
published package.
88

9+
`../tool/build_devtools.sh` builds with icon tree-shaking and strips the local
10+
`canvaskit/` directory (CanvasKit is loaded from the Flutter CDN via
11+
`engineRevision` in `flutter_bootstrap.js`). Prefer that script over
12+
`dart run devtools_extensions build_and_copy`, which ships ~40 MB of unused
13+
engine binaries (see [flutter/devtools#9897](https://github.com/flutter/devtools/issues/9897)).
14+
915
## Develop
1016

1117
```bash

‎tool/build_devtools.sh‎

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
11
#!/usr/bin/env bash
2+
# Build the hit DevTools extension web app into extension/devtools/build.
3+
#
4+
# Size notes (see flutter/devtools#9897):
5+
# - `devtools_extensions build_and_copy` hardcodes --no-tree-shake-icons and
6+
# ships the full local canvaskit/ tree even though flutter_bootstrap.js loads
7+
# CanvasKit from the gstatic CDN via engineRevision. We build ourselves with
8+
# icon tree-shaking and prune canvaskit/ after copy.
29
set -euo pipefail
310

411
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
512
EXT="$ROOT/hit_devtools_extension"
613
DEST="$ROOT/extension/devtools"
14+
SRC_BUILD="$EXT/build/web"
15+
DEST_BUILD="$DEST/build"
716

817
cd "$EXT"
918
flutter pub get
10-
dart run devtools_extensions build_and_copy --source=. --dest="$DEST"
19+
20+
echo "Building extension (release, tree-shake-icons)..."
21+
flutter build web \
22+
--pwa-strategy=offline-first \
23+
--release \
24+
--tree-shake-icons
25+
26+
echo "Copying build → $DEST_BUILD"
27+
rm -rf "$DEST_BUILD"
28+
mkdir -p "$DEST_BUILD"
29+
cp -R "$SRC_BUILD"/. "$DEST_BUILD"/
30+
31+
# Drop local CanvasKit when the bootstrap is CDN-configured (default).
32+
# Local files are never fetched at runtime in that case.
33+
if [[ -f "$DEST_BUILD/flutter_bootstrap.js" ]] &&
34+
grep -q 'engineRevision' "$DEST_BUILD/flutter_bootstrap.js" &&
35+
! grep -q 'useLocalCanvasKit":true\|"useLocalCanvasKit": true' "$DEST_BUILD/flutter_bootstrap.js"; then
36+
if [[ -d "$DEST_BUILD/canvaskit" ]]; then
37+
echo "Pruning unused local canvaskit/ (CDN via engineRevision)..."
38+
rm -rf "$DEST_BUILD/canvaskit"
39+
fi
40+
fi
41+
42+
# Debug symbol maps are not needed at runtime.
43+
find "$DEST_BUILD" -type f \( -name '*.js.symbols' -o -name '*.map' \) -delete
44+
45+
cd "$EXT"
1146
dart run devtools_extensions validate --package="$ROOT"
12-
echo "Built DevTools extension → $DEST/build"
47+
48+
echo "Built DevTools extension → $DEST_BUILD ($(du -sh "$DEST_BUILD" | cut -f1))"

0 commit comments

Comments
 (0)