Add transpilation to PolyGerrit
Utilize the Closure compiler in Bazel to transpile. As part of this, a
rather large file of 'externs' must be added in order to call external
code. This file is specific to Polymer and copied from the Closure
Github, and should be synced any time there are major changes to
Polymer.
Test Plan:
- run `bazel build polygerrit` and verify that whitespaces are removed
from resulting gr-app.js file
- run `bazel build Documentation:licenses.txt` and verify that the new
dependency is listed in resulting
bazel-genfiles/Documentation/licenses.txt
TODO in later changes:
- Get closure optimizations working
- Explore sourcemaps possibilities
- Maybe use closure linting?
Change-Id: Ic358743dda7286fea3ac1e95a7991a92c96d6341
This commit is contained in:
@@ -3,6 +3,7 @@ package(
|
||||
)
|
||||
|
||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library", "closure_js_binary")
|
||||
load(
|
||||
"//tools/bzl:js.bzl",
|
||||
"bower_component_bundle",
|
||||
@@ -29,6 +30,31 @@ vulcanize(
|
||||
deps = ["//polygerrit-ui:polygerrit_components.bower_components"],
|
||||
)
|
||||
|
||||
closure_js_library(
|
||||
name = "closure_lib",
|
||||
srcs = ["gr-app.js"],
|
||||
language = "ECMASCRIPT6",
|
||||
suppress = [
|
||||
"JSC_BAD_JSDOC_ANNOTATION",
|
||||
"JSC_TYPE_PARSE_ERROR",
|
||||
"JSC_MISPLACED_MSG_ANNOTATION",
|
||||
],
|
||||
deps = [
|
||||
"//lib/polymer_externs:polymer_closure",
|
||||
"@io_bazel_rules_closure//closure/library",
|
||||
],
|
||||
)
|
||||
|
||||
closure_js_binary(
|
||||
name = "closure_bin",
|
||||
# Known issue: Closure compilation not compatible with Polymer behaviors.
|
||||
# See: https://github.com/google/closure-compiler/issues/2042
|
||||
compilation_level = "WHITESPACE_ONLY",
|
||||
defs = ["--polymer_pass"],
|
||||
language = "ECMASCRIPT3",
|
||||
deps = [":closure_lib"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "top_sources",
|
||||
srcs = [
|
||||
@@ -42,6 +68,14 @@ filegroup(
|
||||
srcs = glob(["styles/**/*.css"]),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "app_sources",
|
||||
srcs = [
|
||||
"closure_bin.js",
|
||||
"gr-app.html",
|
||||
],
|
||||
)
|
||||
|
||||
genrule2(
|
||||
name = "polygerrit_ui",
|
||||
srcs = [
|
||||
@@ -49,7 +83,7 @@ genrule2(
|
||||
"//lib/js:highlightjs_files",
|
||||
":top_sources",
|
||||
":css_sources",
|
||||
":gr-app",
|
||||
":app_sources",
|
||||
# we extract from the zip, but depend on the component for license checking.
|
||||
"@webcomponentsjs//:zipfile",
|
||||
"//lib/js:webcomponentsjs",
|
||||
@@ -57,7 +91,7 @@ genrule2(
|
||||
outs = ["polygerrit_ui.zip"],
|
||||
cmd = " && ".join([
|
||||
"mkdir -p $$TMP/polygerrit_ui/{styles,fonts,bower_components/{highlightjs,webcomponentsjs},elements}",
|
||||
"cp $(locations :gr-app) $$TMP/polygerrit_ui/elements/",
|
||||
"for f in $(locations :app_sources); do ext=$${f##*.}; cp -p $$f $$TMP/polygerrit_ui/elements/gr-app.$$ext; done",
|
||||
"cp $(locations //lib/fonts:sourcecodepro) $$TMP/polygerrit_ui/fonts/",
|
||||
"for f in $(locations :top_sources); do cp $$f $$TMP/polygerrit_ui/; done",
|
||||
"for f in $(locations :css_sources); do cp $$f $$TMP/polygerrit_ui/styles; done",
|
||||
|
||||
Reference in New Issue
Block a user