Skip to content

Commit 152b979

Browse files
authored
Include TS declarations from generated sources in node_modules_package (#17)
* Include TS declarations in ts_library `JsInfo` * Include TsInfo in `nodejs_modules_package` transitive files instead This avoids breaking several rules that expect JsInfo not to include type declarations. Seems like "transitive files" are just the files going in the package.
1 parent 1a41ea8 commit 152b979

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nodejs/rules.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ load("@rules_pkg//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo"
55
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
66
load("//commonjs:providers.bzl", "CjsInfo", "create_globals", "gen_manifest", "package_path")
77
load("//javascript:providers.bzl", "JsInfo")
8+
load("//typescript:providers.bzl", "TsInfo")
89
load("//util:path.bzl", "nearest", "relativize", "runfile_path")
910
load(":providers.bzl", "NodejsInfo", "NodejsRuntimeInfo")
1011

@@ -372,6 +373,7 @@ def nodejs_modules(name, deps, **kwargs):
372373
def _nodejs_modules_package_impl(ctx):
373374
deps_cjs = [target[CjsInfo] for target in ctx.attr.deps]
374375
deps_js = [target[JsInfo] for target in ctx.attr.deps]
376+
deps_ts = [target[TsInfo] for target in ctx.attr.deps if (TsInfo in target)]
375377
label = ctx.label
376378
links_cjs = [target[CjsInfo] for target in ctx.attr.links]
377379
workspace = ctx.workspace_name
@@ -390,7 +392,7 @@ def _nodejs_modules_package_impl(ctx):
390392
package_paths_nonempty = {}
391393

392394
transitive_files = depset(
393-
transitive = [js_info.transitive_files for js_info in deps_js],
395+
transitive = [info.transitive_files for info in (deps_js + deps_ts)],
394396
)
395397
files_map = {}
396398
for file in transitive_files.to_list():

0 commit comments

Comments
 (0)