Skip to content

Commit

Permalink
Fix runtime_deps and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ribrdb committed Jul 7, 2018
1 parent 18a490f commit d1f20b9
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 17 deletions.
14 changes: 7 additions & 7 deletions closure/compiler/closure_js_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 47 additions & 2 deletions closure/compiler/test/typescript/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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",
)
4 changes: 2 additions & 2 deletions closure/compiler/test/typescript/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ goog.provide('a');
/**
* Function A.
*/
function a() {
a.a = function() {
console.log('a');
}
};
6 changes: 3 additions & 3 deletions closure/compiler/test/typescript/b.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ goog.require('a');
/**
* Function B.
*/
function b() {
a();
b.b = function() {
a.a();
console.log('b');
}
};
8 changes: 5 additions & 3 deletions closure/compiler/test/typescript/c.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 2 additions & 0 deletions closure/compiler/test/typescript/use_closure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import {TagName} from 'goog:goog.dom';
console.log(TagName.A);

0 comments on commit d1f20b9

Please sign in to comment.