Skip to content

Commit 866287e

Browse files
committed
build: improve ts_project interop to work with esbuild bundling
Improves the `ts_project` interop to work with Esbuild bundling. Right now we can end up with multiple copies of the same source file. e.g. input might import from `@angular/cdk/testing` and end up with the version of `rules_nodejs` linker, while other imports to the native `ts_library` targets end up being mapped to their actual sources in the `bazel-bin`, and not inside `node_modules`
1 parent fa74f5e commit 866287e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/bazel/ts_project_interop.bzl

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@aspect_rules_js//js:providers.bzl", "JsInfo", "js_info")
22
load("@aspect_rules_ts//ts:defs.bzl", _ts_project = "ts_project")
33
load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "JSEcmaScriptModuleInfo", "JSModuleInfo", "LinkablePackageInfo")
44
load("@devinfra//bazel/ts_project:index.bzl", "strict_deps_test")
5+
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "LinkerPackageMappingInfo")
56

67
def _ts_deps_interop_impl(ctx):
78
types = []
@@ -81,6 +82,18 @@ def _ts_project_module_impl(ctx):
8182
files = info.sources,
8283
),
8384
)
85+
providers.append(
86+
LinkerPackageMappingInfo(
87+
mappings = depset([
88+
struct(
89+
package_name = ctx.attr.module_name,
90+
package_path = "",
91+
link_path = ctx.label.package,
92+
),
93+
]),
94+
node_modules_roots = depset([]),
95+
),
96+
)
8497

8598
return providers
8699

0 commit comments

Comments
 (0)