angular/devtools/tools/linking/index.bzl
Paul Gschwendtner 115c2f8d38 build: fix linking of cdk/material in devtools and simplify code (#60516)
This commit fixes the linking of CDK/Material which recently broke
because the CDK/Material package now comes with potential shared FESM
chunks; that our current hard-coded, manual linking process doesn't know
about. This ultimately resulted in duplicate code, breaking
Material/CDK.

This commit fixes that.

In addition to the fix, we simplify our linking significantly and reduce
the rather large complexity around linking, or having to specify every
entry-point manually, by linking the full package and putting it into
a different location. This is also what we conceptually are doing in
Angular Material as part of the `rules_js` migration.

PR Close #60516
2025-03-21 14:37:56 -07:00

19 lines
643 B
Python

load("@build_bazel_rules_nodejs//:index.bzl", "npm_package_bin")
load("//devtools/tools/linking:linker_mapping.bzl", "linker_mapping")
def link_package(name, package_name, npm_package):
npm_package_bin(
name = "%s_package_out" % name,
data = [npm_package],
args = ["./external/npm/node_modules/%s" % package_name, "$(@D)"],
output_dir = True,
tool = "//devtools/tools/linking:linker_bin",
)
linker_mapping(
name = name,
srcs = [":%s_package_out" % name],
package = npm_package,
module_name = package_name,
subpath = "./%s_package_out" % name,
)