Centralize externs_list BUILD.gn declarations
The externs_list is used by the Closure compiler, to type check imported terms like 'chrome.fileManagerPrivate.foo', and to ensure that when minimizing JS code from 'foo.bar.baz()' to 'a.b.c()', well known names like 'chrome' aren't minimized. However, the files_manager app does not ship Closure-compiled code in production. It ships uncompiled code - the .js files as written by the programmer. Instead, the externs_list is used indirectly by the js_type_check("closure_compile") rules as a lint-style check. Prior to this CL, maintaining the externs_list was therefore ad hoc and indirect. For example, the hand-written and hand-maintained BUILD.gn files would contain rules like: js_library("foo") { deps = [ "../../common/js:elephant", "../../common/js:giraffe", ] externs_list = [ "../../../externs/apple.js", "../../../externs/banana.js", ] } where foo.js might not refer to externs/apple.js any longer, and it might actually depend on externs/pear.js that is only coincidentally satisfied because common/js/giraffe.js happens to list externs/pear.js on its externs_list. This might be true at any particular point in time, but as new code is added, and as existing code is refactored, the externs_list entries become stale. After this CL, each js_type_check("closure_compile") target has an associated js_library("closure_compile_externs") BUILD.gn target. This gives exactly one place to list all the external dependencies of every Closure compilation target. Future commits may re-organize the very fine grained (only 1 .js file per js_library BUILD.gn target) js_library targets into larger units, and in doing so, push duplicated externs_list entries from the leaves of the BUILD.gn dependency tree towards the root. This could arguably help us move towards shipping Closure compiled JS instead of hand-written JS. But the first step is to get a handle on the dependencies (i.e. externs_list entries) in the first place. Test: "ninja ui/file_manager:closure_compile" runs without error Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation Change-Id: I1a3b029b5223db12abd38077d56914ad9d28a396 Reviewed-on: https://chromium-review.googlesource.com/1092399Reviewed-by:calamity <calamity@chromium.org> Reviewed-by:
Sasha Morrissey <sashab@chromium.org> Commit-Queue: Nigel Tao <nigeltao@chromium.org> Cr-Commit-Position: refs/heads/master@{#567072}
Showing
Please register or sign in to comment