diff --git a/closure/repositories.bzl b/closure/repositories.bzl index b262918f5a..17a49d3289 100644 --- a/closure/repositories.bzl +++ b/closure/repositories.bzl @@ -29,6 +29,7 @@ def rules_closure_dependencies( omit_args4j = False, omit_bazel_skylib = False, omit_clang = False, + omit_com_google_angular_tsickle_tslib = False, omit_com_google_auto_common = False, omit_com_google_auto_factory = False, omit_com_google_auto_value = False, @@ -54,12 +55,14 @@ def rules_closure_dependencies( omit_com_google_jsinterop_annotations = False, omit_com_google_protobuf = False, omit_com_google_protobuf_js = False, + omit_com_google_closure_templates = False, omit_com_google_template_soy = False, omit_com_google_template_soy_jssrc = False, omit_com_ibm_icu_icu4j = False, omit_com_squareup_javapoet = False, omit_fonts_noto_hinted_deb = False, omit_fonts_noto_mono_deb = False, + omit_incremental_dom = False, omit_javax_annotation_jsr250_api = False, omit_javax_inject = False, omit_libexpat_amd64_deb = False, @@ -89,6 +92,8 @@ def rules_closure_dependencies( bazel_skylib() if not omit_clang: clang() + if not omit_com_google_angular_tsickle_tslib: + com_google_angular_tsickle_tslib() if not omit_com_google_auto_common: com_google_auto_common() if not omit_com_google_auto_factory: @@ -139,6 +144,8 @@ def rules_closure_dependencies( com_google_protobuf() if not omit_com_google_protobuf_js: com_google_protobuf_js() + if not omit_com_google_closure_templates: + com_google_closure_templates() if not omit_com_google_template_soy: com_google_template_soy() if not omit_com_google_template_soy_jssrc: @@ -151,6 +158,8 @@ def rules_closure_dependencies( fonts_noto_hinted_deb() if not omit_fonts_noto_mono_deb: fonts_noto_mono_deb() + if not omit_incremental_dom: + incremental_dom() if not omit_javax_annotation_jsr250_api: javax_annotation_jsr250_api() if not omit_javax_inject: @@ -240,6 +249,17 @@ def clang(): macos_sha256 = "633a833396bf2276094c126b072d52b59aca6249e7ce8eae14c728016edb5e61", ) +def com_google_angular_tsickle_tslib(): + http_archive( + name = "com_google_angular_tsickle_tslib", + sha256 = "41f9692b4d9af0bab343457aaa4b7619a84618570cd24039e093223a2971cc89", + strip_prefix = "tsickle-e482bc9fd3be72191bafdd23afaab2c8e83787a0/third_party/tslib", + build_file = "@io_bazel_rules_closure//closure/templates:soy_tslib.BUILD", + urls = [ + "https://github.com/angular/tsickle/archive/e482bc9fd3be72191bafdd23afaab2c8e83787a0.tar.gz", + ], + ) + def com_google_auto_common(): java_import_external( name = "com_google_auto_common", @@ -748,6 +768,16 @@ def com_google_protobuf_js(): ], ) +def com_google_closure_templates(): + http_archive( + name = "com_google_closure_templates", + sha256 = "b8863e45841cb89e9c1e29d46eaabfb4599724d85ef081dbb6f9dfc6ffc58c99", + strip_prefix = "closure-templates-a1c02e60ae88ed1b7db92722ea25ac7d396514fc", + urls = [ + "https://github.com/google/closure-templates/archive/a1c02e60ae88ed1b7db92722ea25ac7d396514fc.tar.gz", + ], + ) + def com_google_template_soy(): java_import_external( name = "com_google_template_soy", @@ -786,6 +816,12 @@ def com_google_template_soy(): "SoyToJbcSrcCompiler", "SoyToJsSrcCompiler", "SoyToPySrcCompiler", + "SoyToIncrementalDomSrcCompiler", + "SoyMsgExtractor", + "SoyHeaderCompiler", + "SoyConformanceChecker", + "SoyPluginValidator", + "SoyVeMetadataGenerator", ) ]), ) @@ -842,6 +878,16 @@ def fonts_noto_mono_deb(): sha256 = "71ff715cf50a74a8cc11b02e7c906b69a242d3d677e739e0b2d18cd23b7de375", ) +def incremental_dom(): + http_archive( + name = "incremental_dom", + sha256 = "33b060bb04c38b4c5c9c203de702dcbc482128be0cead6c5e9e9658dfae8b715", + strip_prefix = "incremental-dom-a6c91ebc569110993c7c4130f0456504f624459a", + urls = [ + "https://github.com/tabspring/incremental-dom/archive/a6c91ebc569110993c7c4130f0456504f624459a.tar.gz", + ], + ) + def javax_annotation_jsr250_api(): java_import_external( name = "javax_annotation_jsr250_api", diff --git a/closure/templates/BUILD b/closure/templates/BUILD index 0932884be1..3b7edcc797 100644 --- a/closure/templates/BUILD +++ b/closure/templates/BUILD @@ -17,7 +17,7 @@ package(default_visibility = ["//visibility:public"]) licenses(["notice"]) # Apache 2.0 load("@rules_java//java:defs.bzl", "java_library") -load("//closure:defs.bzl", "closure_js_library", "closure_js_proto_library") +load("//closure:defs.bzl", "closure_js_library", "closure_js_proto_library", "closure_proto_library") java_library( name = "templates", @@ -29,12 +29,18 @@ closure_js_proto_library( srcs = ["@com_google_common_html_types_html_proto//file"], ) +closure_proto_library( + name = "soy_ve_metadata_proto", + deps = ["@com_google_closure_templates//src/main/protobuf:ve_metadata_proto"], +) + closure_js_library( name = "soy_jssrc", srcs = ["@com_google_template_soy_jssrc"], lenient = True, deps = [ ":soy_html_proto", + "//closure/protobuf:jspb", "@com_google_javascript_closure_library//closure/goog/array", "@com_google_javascript_closure_library//closure/goog/asserts", "@com_google_javascript_closure_library//closure/goog/debug", @@ -59,6 +65,39 @@ closure_js_library( ], ) +closure_js_library( + name = "soy_idom", + srcs = ["@com_google_template_soy_jssrc//:idom"], + lenient = True, + deps = [ + ":soy_tslib", + ":soy_jssrc", + ":soy_html_proto", + ":soy_ve_metadata_proto", + "//closure/protobuf:jspb", + "@com_google_javascript_closure_library//closure/goog/asserts", + "@com_google_javascript_closure_library//closure/goog/soy", + "@com_google_javascript_closure_library//closure/goog/soy:data", + "@com_google_javascript_closure_library//closure/goog/string", + "@incremental_dom//closure", + ], + suppress = [ + "nonStandardJsDocs", + ], +) + +closure_js_library( + name = "soy_tslib", + srcs = [ + "soy_tslib.js", + "@com_google_angular_tsickle_tslib//:tslib", + ], + lenient = True, + deps = [ + # None. + ], +) + java_library( name = "safe_html_types", exports = ["@com_google_common_html_types"], diff --git a/closure/templates/closure_js_template_library.bzl b/closure/templates/closure_js_template_library.bzl index e910371b72..649a495da7 100644 --- a/closure/templates/closure_js_template_library.bzl +++ b/closure/templates/closure_js_template_library.bzl @@ -21,6 +21,12 @@ load("//closure/private:defs.bzl", "SOY_FILE_TYPE", "unfurl") load("//closure/templates:closure_templates_plugin.bzl", "SoyPluginInfo") _SOYTOJSSRCCOMPILER = "@com_google_template_soy//:SoyToJsSrcCompiler" +_SOYIDOMCOMPILER = "@com_google_template_soy//:SoyToIncrementalDomSrcCompiler" + +_IDOM_DEPS = [ + str(Label("//closure/templates:soy_idom")), + str(Label("//closure/templates:soy_tslib")), +] def _impl(ctx): args = ["--outputPathFormat=%s/{INPUT_DIRECTORY}/{INPUT_FILE_NAME}.js" % @@ -29,7 +35,7 @@ def _impl(ctx): args += ["--googMsgsAreExternal"] if ctx.attr.should_generate_soy_msg_defs: args += ["--shouldGenerateGoogMsgDefs"] - if ctx.attr.bidi_global_dir: + if (not ctx.attr.idom) and ctx.attr.bidi_global_dir: args += ["--bidiGlobalDir=%s" % ctx.attr.bidi_global_dir] if ctx.attr.plugins: args += ["--pluginModules=%s" % ",".join([ @@ -89,6 +95,7 @@ _closure_js_template_library = rule( "should_generate_soy_msg_defs": attr.bool(), "bidi_global_dir": attr.int(default = 1, values = [1, -1]), "soy_msgs_are_external": attr.bool(), + "idom": attr.bool(), "compiler": attr.label(cfg = "host", executable = True, mandatory = True), "defs": attr.string_list(), }, @@ -106,8 +113,12 @@ def closure_js_template_library( bidi_global_dir = None, soy_msgs_are_external = None, defs = [], + jsdeps = [], + idom = False, + compiler = None, **kwargs): - compiler = str(Label(_SOYTOJSSRCCOMPILER)) + default_compiler = (idom and str(Label(_SOYIDOMCOMPILER))) or str(Label(_SOYTOJSSRCCOMPILER)) + resolved_compiler = compiler or default_compiler js_srcs = [src + ".js" for src in srcs] _closure_js_template_library( name = name + "_soy_js", @@ -121,8 +132,9 @@ def closure_js_template_library( should_generate_soy_msg_defs = should_generate_soy_msg_defs, bidi_global_dir = bidi_global_dir, soy_msgs_are_external = soy_msgs_are_external, - compiler = compiler, + compiler = resolved_compiler, defs = defs, + idom = idom, ) deps = deps + [ @@ -147,20 +159,27 @@ def closure_js_template_library( "@com_google_javascript_closure_library//closure/goog/string", "@com_google_javascript_closure_library//closure/goog/string:const", "@com_google_javascript_closure_library//closure/goog/uri", + "@io_bazel_rules_closure//closure/templates:soy_ve_metadata_proto", str(Label("//closure/templates:soy_jssrc")), ] closure_js_library( name = name, srcs = js_srcs, - deps = deps, + deps = deps + jsdeps + ( + idom and _IDOM_DEPS or [] + ), testonly = testonly, + lenient = True, suppress = suppress + [ "analyzerChecks", "deprecated", "reportUnknownTypes", "strictCheckTypes", "unusedLocalVariables", - ], + ] + (idom and [ + "strictModuleChecks", + "checkTypes", + ] or []), **kwargs ) diff --git a/closure/templates/soy_jssrc.BUILD b/closure/templates/soy_jssrc.BUILD index 1d940a213f..30f061e2fa 100644 --- a/closure/templates/soy_jssrc.BUILD +++ b/closure/templates/soy_jssrc.BUILD @@ -22,6 +22,24 @@ filegroup( "checks.js", "jspbconversions.js", "soydata_converters.js", + "soyutils_directives.js", + "soyutils_map.js", + "soyutils_newmaps.js", + "soyutils_templates.js", "soyutils_usegoog.js", ], ) + +filegroup( + name = "idom", + srcs = [ + "api_idom.js", + "element_lib_idom.js", + "global.js", + "shim.js", + "skiphandler.js", + "soyutils_idom.js", + "soyutils_velog.js", + "types.js", + ], +) diff --git a/closure/templates/soy_tslib.BUILD b/closure/templates/soy_tslib.BUILD new file mode 100644 index 0000000000..e787222af5 --- /dev/null +++ b/closure/templates/soy_tslib.BUILD @@ -0,0 +1,31 @@ +# Copyright 2016 The Closure Rules Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +package(default_visibility = ["//visibility:public"]) + +licenses(["notice"]) # Apache 2.0 + +filegroup( + name = "externs", + srcs = [ + "externs.js", + ], +) + +filegroup( + name = "tslib", + srcs = [ + "tslib.js", + ], +) diff --git a/closure/templates/soy_tslib.js b/closure/templates/soy_tslib.js new file mode 100644 index 0000000000..e34e527870 --- /dev/null +++ b/closure/templates/soy_tslib.js @@ -0,0 +1,8 @@ + +goog.module('google3.third_party.javascript.tslib.tslib'); + +const tslib = goog.require( + 'tslib' +); + +exports = tslib; diff --git a/java/com/google/javascript/jscomp/Diagnostics.java b/java/com/google/javascript/jscomp/Diagnostics.java index b3380076d5..2104dbb458 100644 --- a/java/com/google/javascript/jscomp/Diagnostics.java +++ b/java/com/google/javascript/jscomp/Diagnostics.java @@ -41,6 +41,9 @@ final class Diagnostics { CheckStrictDeps.DUPLICATE_PROVIDES, CheckStrictDeps.REDECLARED_PROVIDES, CheckStrictDeps.NOT_PROVIDED); + DiagnosticGroups.registerGroup("generatedTypescript", + ClosureCheckModule.GOOG_MODULE_MISPLACED, + ClosureCheckModule.EXPORT_NOT_AT_MODULE_SCOPE); } static final DiagnosticGroups GROUPS = new DiagnosticGroups(); @@ -87,6 +90,7 @@ final class Diagnostics { "externsValidation", "extraProvide", "extraRequire", + "generatedTypescript", "globalThis", "invalidCasts", "lateProvide", @@ -169,6 +173,7 @@ final class Diagnostics { // TODO(jart): Remove these when regression is fixed relating to jscomp being able to // identify externs files that were passed via srcs. CheckJSDoc.INVALID_MODIFIES_ANNOTATION, + ReplaceIdGenerators.NON_GLOBAL_ID_GENERATOR_CALL, CheckJSDoc.INVALID_NO_SIDE_EFFECT_ANNOTATION); static final ImmutableMap DIAGNOSTIC_TYPES = initDiagnosticTypes();