diff --git a/closure/compiler/closure_js_library.bzl b/closure/compiler/closure_js_library.bzl index ae2f380552..fa23204cec 100644 --- a/closure/compiler/closure_js_library.bzl +++ b/closure/compiler/closure_js_library.bzl @@ -82,19 +82,19 @@ def closure_js_library_impl( ijs_file = _maybe_declare_file( actions, deprecated_ijs_file, '%s.i.js' % label.name) - # Create a list of direct children of this rule. If any direct dependencies - # have the exports attribute, those labels become direct dependencies here. - deps = unfurl(deps, provider="closure_js_library") - # Wrapper around a ts_library. It's like creating a closure_js_library with # the runtime_deps of the ts_library, and the srcs are the tsickle outputs from # the ts_library. if ts_lib: - lib = ts_lib - srcs = srcs + lib.typescript.transitive_es6_sources.to_list() - deps = deps + lib.typescript.runtime_deps.to_list() + srcs = srcs + ts_lib.typescript.transitive_es6_sources.to_list() + # Note that we need to modify deps before calling unfurl below for exports to work. + deps = deps + ts_lib.typescript.runtime_deps.to_list() suppress = suppress + ["checkTypes", "reportUnknownTypes", "analyzerChecks", "JSC_EXTRA_REQUIRE_WARNING"] + # Create a list of direct children of this rule. If any direct dependencies + # have the exports attribute, those labels become direct dependencies here. + deps = unfurl(deps, provider="closure_js_library") + # Collect all the transitive stuff the child rules have propagated. Bazel has # a special nested set data structure that makes this efficient. js = collect_js(deps, closure_library_base, bool(srcs), no_closure_library) diff --git a/closure/compiler/test/typescript/BUILD b/closure/compiler/test/typescript/BUILD index 50487e0764..149a368e8d 100644 --- a/closure/compiler/test/typescript/BUILD +++ b/closure/compiler/test/typescript/BUILD @@ -33,8 +33,8 @@ fake_ts_library( ) closure_js_library( - name="b_js", - ts_lib=":b", + name = "b_js", + ts_lib = ":b", ) closure_js_library( @@ -54,3 +54,48 @@ file_test( content = "", file = "b_js-stderr.txt", ) + +closure_js_binary( + name = "c_bin", + entry_points = ["c"], + deps = ["c"], +) + +file_test( + name = "c_bin_noWarnings", + content = "", + file = "c_bin-stderr.txt", +) + +fake_ts_library( + name = "ts_closure", + runtime_deps = ["//closure/library"], +) + +fake_ts_library( + name = "use_closure", + srcs = ["use_closure.js"], + deps = ["ts_closure"], +) + +closure_js_library( + name = "use_closure_js", + ts_lib = "use_closure", +) + +closure_js_binary( + name = "use_closure_bin", + deps = ["use_closure_js"], +) + +file_test( + name = "use_closure_js_noWarnings", + content = "", + file = "use_closure_js-stderr.txt", +) + +file_test( + name = "use_closure_bin_noWarnings", + content = "", + file = "use_closure_bin-stderr.txt", +) diff --git a/closure/compiler/test/typescript/a.js b/closure/compiler/test/typescript/a.js index e87cfef072..64d6b52697 100644 --- a/closure/compiler/test/typescript/a.js +++ b/closure/compiler/test/typescript/a.js @@ -18,6 +18,6 @@ goog.provide('a'); /** * Function A. */ -function a() { +a.a = function() { console.log('a'); -} +}; diff --git a/closure/compiler/test/typescript/b.js b/closure/compiler/test/typescript/b.js index 603a701b6d..f121b59c9e 100644 --- a/closure/compiler/test/typescript/b.js +++ b/closure/compiler/test/typescript/b.js @@ -20,7 +20,7 @@ goog.require('a'); /** * Function B. */ -function b() { - a(); +b.b = function() { + a.a(); console.log('b'); -} +}; diff --git a/closure/compiler/test/typescript/c.js b/closure/compiler/test/typescript/c.js index efb05816c5..fb1f5774b8 100644 --- a/closure/compiler/test/typescript/c.js +++ b/closure/compiler/test/typescript/c.js @@ -20,7 +20,9 @@ goog.require('b'); /** * Function C. */ -function c() { - b(); +c.c = function() { + b.b(); console.log('c'); -} +}; + +goog.exportSymbol('test.c',c.c); \ No newline at end of file diff --git a/closure/compiler/test/typescript/use_closure.js b/closure/compiler/test/typescript/use_closure.js new file mode 100644 index 0000000000..d99faf8ff0 --- /dev/null +++ b/closure/compiler/test/typescript/use_closure.js @@ -0,0 +1,2 @@ +import {TagName} from 'goog:goog.dom'; +console.log(TagName.A); \ No newline at end of file