Skip to content

Commit

Permalink
fix(typescript): include transitive_declarations
Browse files Browse the repository at this point in the history
These were missing from node_module_library
and break downstream ts_library which should include them in files[]

Fixes bazelbuild/rules_typescript#381
  • Loading branch information
alexeagle committed Jun 14, 2019
1 parent c8e61c5 commit bbcfcdd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions internal/npm_install/node_module_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ def _node_module_library_impl(ctx):
# use in rules such as ts_devserver
scripts = depset(ctx.files.scripts)

# declarations are a subset of sources that are decleration files
declarations = depset([f for f in ctx.files.srcs if f.path.endswith(".d.ts")])
# declarations are a subset of sources that are declaration files
declarations = depset([
f
for f in ctx.files.srcs
if f.path.endswith(".d.ts") and
# exclude eg. external/npm/node_modules/protobufjs/node_modules/@types/node/index.d.ts
# these would be duplicates of the typings provided directly in another dependency
len(f.path.split("/node_modules/")) < 3
])

# transitive_declarations are all .d.ts files in srcs plus those in direct & transitive dependencies
transitive_declarations = depset(transitive = [declarations])

# transitive_declarations are all direct & transitive decleration files
transitive_declarations = depset()
for src in ctx.attr.srcs:
if hasattr(src, "typescript"):
transitive_declarations = depset(transitive = [transitive_declarations, src.typescript.transitive_declarations])
for dep in ctx.attr.deps:
if hasattr(dep, "typescript"):
transitive_declarations = depset(transitive = [transitive_declarations, dep.typescript.transitive_declarations])
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ rules_nodejs_dev_dependencies()
# With http_archive it only sees releases/download/*.tar.gz urls
git_repository(
name = "build_bazel_rules_typescript",
commit = "66505d1e39bc1be973ffbb1e3f83df4d7e1373ef",
commit = "b1fa8ad9d15a4b46da800b33333512e538c69bd4",
remote = "http://github.com/bazelbuild/rules_typescript.git",
)

Expand Down

0 comments on commit bbcfcdd

Please sign in to comment.