Commit 8d2021d8 authored by Tim van der Lippe's avatar Tim van der Lippe Committed by Commit Bot

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: default avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702500}
parent 92e2c7b9
...@@ -1487,7 +1487,7 @@ action("generate_devtools_grd") { ...@@ -1487,7 +1487,7 @@ action("generate_devtools_grd") {
] ]
grd_files = grd_files =
all_devtools_modules + generated_applications + copied_devtools_modules + generated_applications +
generated_non_autostart_non_remote_modules + devtools_embedder_scripts + generated_non_autostart_non_remote_modules + devtools_embedder_scripts +
[ "$resources_out_dir/devtools_extension_api.js" ] [ "$resources_out_dir/devtools_extension_api.js" ]
......
...@@ -12,6 +12,10 @@ from os.path import join, relpath ...@@ -12,6 +12,10 @@ from os.path import join, relpath
import shutil import shutil
import sys import sys
import rjsmin
from modular_build import read_file, write_file
def main(argv): def main(argv):
try: try:
...@@ -21,11 +25,13 @@ def main(argv): ...@@ -21,11 +25,13 @@ def main(argv):
output_path = argv[output_path_flag_index + 1] output_path = argv[output_path_flag_index + 1]
devtools_modules = argv[1:input_path_flag_index] devtools_modules = argv[1:input_path_flag_index]
except: 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 raise
for file_name in devtools_modules: 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__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment