fix(bazel): ng_module rule does not expose flat module information in Ivy (#36971)

The `ng_module` rule supports the generation of flat module bundles. In
View Engine, information about this flat module bundle is exposed
as a Bazel provider. This is helpful as other rules like `ng_package`
could rely on this information to determine entry-points for the APF.

With Ivy this currently does not work because the flat module
information is not exposed in the provider. The reason for this is
unclear. We should also provide this information in Ivy so that rules
like `ng_package` can also determine the correct entry-points when a
package is built specifically with `--config=ivy`.

PR Close #36971
This commit is contained in:
Paul Gschwendtner
2020-05-07 15:35:05 +02:00
committed by atscott
parent f2f5f7fc6e
commit b76a2dc2cb
4 changed files with 25 additions and 22 deletions

View File

@ -8,9 +8,14 @@
def _extract_flat_module_index(ctx):
files = []
for dep in ctx.attr.deps:
if hasattr(dep, "angular"):
metadata = dep.angular.flat_module_metadata
files.extend([metadata.metadata_file, metadata.typings_file])
if hasattr(dep, "angular") and hasattr(dep.angular, "flat_module_metadata"):
flat_module = dep.angular.flat_module_metadata
files.append(flat_module.typings_file)
# The flat module metadata file could be `None` for targets
# built with Ivy. No metadata files are generated in ngtsc.
if flat_module.metadata_file != None:
files.append(flat_module.metadata_file)
return [DefaultInfo(files = depset(files))]
extract_flat_module_index = rule(