From 3a16e56fa412a35ce76923a809519acc41dcab81 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 19 Apr 2021 21:42:59 -0400 Subject: [PATCH] Reduce pyodide.asm.js by factor of 2 with sed (#1500) --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 9f815be98..4d3435314 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,14 @@ build/pyodide.asm.js: \ --exclude-file "*__pycache__*" \ --exclude-file "*/test/*" \ --exclude-file "*/tests/*" + # Strip out C++ symbols which all start __Z. + # There are 4821 of these and they have VERY VERY long names. + # Reduces size of pyodide.asm.js by a factor of 2. + # I messed around with striping more and could remove another 400kb or so + # but the regexes I got were generated. + # To show some stats on the symbols you can use the following: + # cat build/pyodide.asm.js | grep -ohE 'var _{0,5}.' | sort | uniq -c | sort -nr | head -n 20 + sed -i -E 's/var __Z[^;]*;//g' build/pyodide.asm.js date +"[%F %T] done building pyodide.asm.js."