| --- 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]) |