From 5c3562c82918ccaeebcbbd23093d5962b7e7f5ea Mon Sep 17 00:00:00 2001 From: Nevada Perry Date: Wed, 18 Jun 2025 15:52:58 +0000 Subject: [PATCH 1/2] Include TS declarations in ts_library `JsInfo` I don't understand this well. Claude Code stumbled upon it as a fix for the regression we had after jumping from rules_js of August 2022 to March 2025 in our main repo. The issue is we have a ts_library containing .js, .js.map, and .d.ts files generated from X12 fixtures. Updating our pin on rules_js caused those .d.ts files to stop getting included in our node_modules_package target for VSCode type hints. (Other ts_library and js_import_ts targets were fine). --- ts-proto/rules.bzl | 2 +- typescript/rules.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ts-proto/rules.bzl b/ts-proto/rules.bzl index be44b35..bc476fb 100644 --- a/ts-proto/rules.bzl +++ b/ts-proto/rules.bzl @@ -247,7 +247,7 @@ def _ts_proto_libraries_impl(ctx): js_infos[lib.label] = create_js_info( cjs_root = cjs_root, - files = js, + files = js + declarations, deps = ts_proto.deps_js + [js_infos[label] for label in lib.deps], ) diff --git a/typescript/rules.bzl b/typescript/rules.bzl index 41d8c1a..22c00c1 100644 --- a/typescript/rules.bzl +++ b/typescript/rules.bzl @@ -360,7 +360,7 @@ def _ts_library_impl(ctx): js_info = create_js_info( cjs_root = cjs_root, deps = js_deps + compiler.runtime_js, - files = js, + files = js + declarations, ) ts_info = create_ts_info( From 125f77a73ac22addb7644478e7979a407d9b9d50 Mon Sep 17 00:00:00 2001 From: Nevada Perry Date: Mon, 23 Jun 2025 15:34:05 +0000 Subject: [PATCH 2/2] 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. --- nodejs/rules.bzl | 4 +++- ts-proto/rules.bzl | 2 +- typescript/rules.bzl | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nodejs/rules.bzl b/nodejs/rules.bzl index 6ef2244..3c92560 100644 --- a/nodejs/rules.bzl +++ b/nodejs/rules.bzl @@ -5,6 +5,7 @@ load("@rules_pkg//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo" load("@rules_pkg//pkg:tar.bzl", "pkg_tar") load("//commonjs:providers.bzl", "CjsInfo", "create_globals", "gen_manifest", "package_path") load("//javascript:providers.bzl", "JsInfo") +load("//typescript:providers.bzl", "TsInfo") load("//util:path.bzl", "nearest", "relativize", "runfile_path") load(":providers.bzl", "NodejsInfo", "NodejsRuntimeInfo") @@ -372,6 +373,7 @@ def nodejs_modules(name, deps, **kwargs): def _nodejs_modules_package_impl(ctx): deps_cjs = [target[CjsInfo] for target in ctx.attr.deps] deps_js = [target[JsInfo] for target in ctx.attr.deps] + deps_ts = [target[TsInfo] for target in ctx.attr.deps if (TsInfo in target)] label = ctx.label links_cjs = [target[CjsInfo] for target in ctx.attr.links] workspace = ctx.workspace_name @@ -390,7 +392,7 @@ def _nodejs_modules_package_impl(ctx): package_paths_nonempty = {} transitive_files = depset( - transitive = [js_info.transitive_files for js_info in deps_js], + transitive = [info.transitive_files for info in (deps_js + deps_ts)], ) files_map = {} for file in transitive_files.to_list(): diff --git a/ts-proto/rules.bzl b/ts-proto/rules.bzl index bc476fb..be44b35 100644 --- a/ts-proto/rules.bzl +++ b/ts-proto/rules.bzl @@ -247,7 +247,7 @@ def _ts_proto_libraries_impl(ctx): js_infos[lib.label] = create_js_info( cjs_root = cjs_root, - files = js + declarations, + files = js, deps = ts_proto.deps_js + [js_infos[label] for label in lib.deps], ) diff --git a/typescript/rules.bzl b/typescript/rules.bzl index 22c00c1..41d8c1a 100644 --- a/typescript/rules.bzl +++ b/typescript/rules.bzl @@ -360,7 +360,7 @@ def _ts_library_impl(ctx): js_info = create_js_info( cjs_root = cjs_root, deps = js_deps + compiler.runtime_js, - files = js + declarations, + files = js, ) ts_info = create_ts_info(