mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
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
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
load("@build_bazel_rules_nodejs//:providers.bzl", "ExternalNpmPackageInfo", "JSModuleInfo")
|
|
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "LinkerPackageMappingInfo")
|
|
|
|
def _linker_mapping_impl(ctx):
|
|
return [
|
|
# Pass through the `ExternalNpmPackageInfo` which is needed for the linker
|
|
# resolving dependencies which might be external. e.g. `rxjs` for `@angular/core`.
|
|
ctx.attr.package[ExternalNpmPackageInfo],
|
|
JSModuleInfo(
|
|
direct_sources = depset(ctx.files.srcs),
|
|
sources = depset(ctx.files.srcs),
|
|
),
|
|
LinkerPackageMappingInfo(
|
|
mappings = depset([
|
|
struct(
|
|
package_name = ctx.attr.module_name,
|
|
package_path = "",
|
|
link_path = "%s/%s" % (ctx.label.package, ctx.attr.subpath),
|
|
),
|
|
]),
|
|
node_modules_roots = depset([]),
|
|
),
|
|
]
|
|
|
|
linker_mapping = rule(
|
|
implementation = _linker_mapping_impl,
|
|
attrs = {
|
|
"package": attr.label(),
|
|
"srcs": attr.label_list(allow_files = False),
|
|
"subpath": attr.string(),
|
|
"module_name": attr.string(),
|
|
},
|
|
)
|