Minify ES Modules files

After converting the `ui/` folder to ESM, there was a significant performance
regression in terms of file size of the `resources.pak`. It turns out that we
were not minifying ESM files, but we did do that before with Closure.

Update the `copy_devtools_modules` to also invoke rjsmin to minify the
JavaScript source code.

Before:
$ du -h -B K out/Default/resources.pak
12096K	out/Default/resources.pak

After:
$ du -h -B K out/Default/resources.pak
11752K	out/Default/resources.pak

Before the original CL transforming `ui/` landed:
$ du -h -B K out/Default/resources.pak
11860K	out/Default/resources.pak

This means that after converting `ui/` to ESM, we saved 90KB. We suspect
this is because we are no longer transpiling to ES5, but instead serve
source ES6.

Bug: 1010910
Change-Id: I7dd07ff788d014e9f9a8e25e168c58c010cd00af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837814
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#702500}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8d2021d8394b9a248436fb6976070629cdffd961
This commit is contained in:
Tim van der Lippe
2019-10-03 18:36:31 +00:00
committed by Commit Bot
parent 3de2f69991
commit bc38bd6964
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -1487,7 +1487,7 @@ action("generate_devtools_grd") {
]
grd_files =
all_devtools_modules + generated_applications +
copied_devtools_modules + generated_applications +
generated_non_autostart_non_remote_modules + devtools_embedder_scripts +
[ "$resources_out_dir/devtools_extension_api.js" ]
+8 -2
View File
@@ -12,6 +12,10 @@ from os.path import join, relpath
import shutil
import sys
import rjsmin
from modular_build import read_file, write_file
def main(argv):
try:
@@ -21,11 +25,13 @@ def main(argv):
output_path = argv[output_path_flag_index + 1]
devtools_modules = argv[1:input_path_flag_index]
except:
print 'Usage: %s module_1 module_2 ... module_N --input_path <input_path> --output_path <output_path>' % argv[0]
print('Usage: %s module_1 module_2 ... module_N --input_path <input_path> --output_path <output_path>' % argv[0])
raise
for file_name in devtools_modules:
shutil.copy(join(input_path, file_name), join(output_path, relpath(file_name, 'front_end')))
file_content = read_file(join(input_path, file_name))
minified = rjsmin.jsmin(file_content)
write_file(join(output_path, relpath(file_name, 'front_end')), minified)
if __name__ == '__main__':