From 975dbce0fea076f16164e0d8b970095a1fc7cde5 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 10 May 2019 10:55:51 -0700 Subject: [PATCH] fix(typescript): include transitive_declarations These were missing from node_module_library and break downstream ts_library which should include them in files[] Fixes https://github.com/bazelbuild/rules_typescript/issues/381 --- internal/npm_install/node_module_library.bzl | 20 +++++++++++++------- packages/typescript/WORKSPACE | 6 ++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/internal/npm_install/node_module_library.bzl b/internal/npm_install/node_module_library.bzl index 45272af66a..137d706f17 100644 --- a/internal/npm_install/node_module_library.bzl +++ b/internal/npm_install/node_module_library.bzl @@ -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]) diff --git a/packages/typescript/WORKSPACE b/packages/typescript/WORKSPACE index 4037c59a11..ba4ef69eb5 100644 --- a/packages/typescript/WORKSPACE +++ b/packages/typescript/WORKSPACE @@ -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