Skip to content

Commit

Permalink
feat(bazel): provide LinkablePackageInfo from ng_module (#37778)
Browse files Browse the repository at this point in the history
Adds the `LinkablePackageInfo` to the `ng_module` rule. This allows
the linker to properly link `ng_module` targets in Node runtime
actions. Currently this does not work properly and packages like
`@angular/core` are not linked, so we cannot rely on the linker.

https://github.com/bazelbuild/rules_nodejs/blob/9a5de3728b05bf1647bbb87ad99f54e626604705/internal/linker/link_node_modules.bzl#L144-L146.

PR Close #37778
  • Loading branch information
gregmagolan authored and atscott committed Jul 10, 2020
1 parent 822652a commit 6cd10a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/bazel/src/external.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ load(
)
load(
"@build_bazel_rules_nodejs//:providers.bzl",
_LinkablePackageInfo = "LinkablePackageInfo",
_NpmPackageInfo = "NpmPackageInfo",
_js_ecma_script_module_info = "js_ecma_script_module_info",
_js_named_module_info = "js_named_module_info",
_node_modules_aspect = "node_modules_aspect",
)

LinkablePackageInfo = _LinkablePackageInfo
NpmPackageInfo = _NpmPackageInfo
node_modules_aspect = _node_modules_aspect

Expand Down
10 changes: 10 additions & 0 deletions packages/bazel/src/ng_module.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ load(
"DEFAULT_NG_COMPILER",
"DEFAULT_NG_XI18N",
"DEPS_ASPECTS",
"LinkablePackageInfo",
"NpmPackageInfo",
"TsConfigInfo",
"compile_ts",
Expand Down Expand Up @@ -646,6 +647,15 @@ def _ng_module_impl(ctx):
# once it is no longer needed.
])

if ctx.attr.module_name:
path = "/".join([p for p in [ctx.bin_dir.path, ctx.label.workspace_root, ctx.label.package] if p])
ts_providers["providers"].append(LinkablePackageInfo(
package_name = ctx.attr.module_name,
path = path,
files = ts_providers["typescript"]["es5_sources"],
_tslibrary = True,
))

return ts_providers_dict_to_struct(ts_providers)

local_deps_aspects = [node_modules_aspect, _collect_summaries_aspect]
Expand Down

0 comments on commit 6cd10a1

Please sign in to comment.