From ac88bd0fa8164d43be3e1d8319c1738219ece83a Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Mon, 1 May 2017 23:42:15 +0200 Subject: [PATCH] PolyGerrit: Make ES6 to ES5 transpilation actually work Bump rules_closure version to this commit[1], that allows us to pass --force_inject_library=es6_runtime to closure compiler, that fixes missing injection of ES6 dependency with optimization level whitespace. One side effect of this change: because of the recently made change in rules_closure rules of how the external dependencies are consumed, we cannot reuse some common dependencies that were already fetched during gerrit build and must re-fetch them again, most notably: * asm * gson * guava * guice * soy The bad news here is, that re-fetching takes place with rules_closure's java_import_external rule, that is not using our own download_file.py utility and thus the artifacts are not cached in ~/.gerritcodereview directory, so that when the build is repeated on the same machine but on different clone of gerrit repository all rules_closure dependencies are going to be re-fetched again. Another complication of re-fetching is that the different versions of the artifacts are now fetched: e.g. Gerrit is using guava 21, and closure rule is using guava 20. The reason why we don't have the collision here is because gerrit mounts this dependency under @guava directory, whereas rules_closure is using canonical artifact name, so that we get: * external/com_google_guava/guava-20.0.jar # fetched by rules_closure * external/guava/jar/guava-21.0.jar # fetched by gerrit Test Plan: 1. conduct ES6 modification, e.g. apply this CL: [2] 2. run bazel build gerrit 3. verify that transpiled code actually work [1] https://github.com/bazelbuild/rules_closure/commit/f68d4b5a55c04ee50a3196590dce1ca8e7dbf438 [2] https://gerrit-review.googlesource.com/105104 Bug: Issue 6110 Change-Id: I3f3adf8ce5e613d45d1d0684b823e48e68a14080 --- WORKSPACE | 21 ++++++--------------- polygerrit-ui/app/BUILD | 8 ++++---- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 0787e1040c..f63b8b3f49 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -6,9 +6,9 @@ load("//plugins:external_plugin_deps.bzl", "external_plugin_deps") http_archive( name = "io_bazel_rules_closure", - strip_prefix = "rules_closure-0.4.1", - sha256 = "ba5e2e10cdc4027702f96e9bdc536c6595decafa94847d08ae28c6cb48225124", - url = "http://bazel-mirror.storage.googleapis.com/github.com/bazelbuild/rules_closure/archive/0.4.1.tar.gz", + sha256 = "af1f5a31b8306faed9d09a38c8e2c1d6afc4c4a2dada3b5de11cceae8c7f4596", + strip_prefix = "rules_closure-f68d4b5a55c04ee50a3196590dce1ca8e7dbf438", + url = "https://bazel-mirror.storage.googleapis.com/github.com/bazelbuild/rules_closure/archive/f68d4b5a55c04ee50a3196590dce1ca8e7dbf438.tar.gz", # 2017-05-05 ) # File is specific to Polymer and copied from the Closure Github -- should be @@ -24,18 +24,9 @@ load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") # Prevent redundant loading of dependencies. closure_repositories( - omit_aopalliance=True, - omit_args4j=True, - omit_jsr305=True, - omit_gson=True, - omit_guava=True, - omit_guice=True, - omit_soy=True, - omit_icu4j=True, - omit_asm=True, - omit_asm_analysis=True, - omit_asm_commons=True, - omit_asm_util=True, + omit_aopalliance = True, + omit_args4j = True, + omit_javax_inject = True, ) ANTLR_VERS = "3.5.2" diff --git a/polygerrit-ui/app/BUILD b/polygerrit-ui/app/BUILD index 7c12fa27a2..abfb8f85e5 100644 --- a/polygerrit-ui/app/BUILD +++ b/polygerrit-ui/app/BUILD @@ -34,10 +34,9 @@ closure_js_library( name = "closure_lib", srcs = ["gr-app.js"], convention = "GOOGLE", - language = "ECMASCRIPT6", - suppress = [ - "JSC_BAD_JSDOC_ANNOTATION", - ], + # TODO(davido): Clean up these issues: http://paste.openstack.org/show/608548 + # and remove this supression + suppress = ["JSC_UNUSED_LOCAL_ASSIGNMENT"], deps = [ "//lib/polymer_externs:polymer_closure", "@io_bazel_rules_closure//closure/library", @@ -52,6 +51,7 @@ closure_js_binary( defs = [ "--polymer_pass", "--jscomp_off=duplicate", + "--force_inject_library=es6_runtime", ], language = "ECMASCRIPT5", deps = [":closure_lib"],