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 13, 2019
1 parent c8e61c5 commit 975dbce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 13 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,20 @@ 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
6 changes: 4 additions & 2 deletions packages/typescript/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ rules_nodejs_dev_dependencies()

# We use git_repository since Renovate knows how to update it.
# With http_archive it only sees releases/download/*.tar.gz urls
# TODO(alexeagle): switch to upstream after landing tsconfig.json change
# in the tsc_wrapped compilation
git_repository(
name = "build_bazel_rules_typescript",
commit = "66505d1e39bc1be973ffbb1e3f83df4d7e1373ef",
remote = "http://github.com/bazelbuild/rules_typescript.git",
commit = "6038e5986e367be9b5fd7d7aa5cc48322956d488",
remote = "http://github.com/alexeagle/rules_typescript.git",
)

# We have a source dependency on build_bazel_rules_typescript
Expand Down

0 comments on commit 975dbce

Please sign in to comment.