-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(bazel): ng_module rule does not expose flat module information in Ivy #36971
fix(bazel): ng_module rule does not expose flat module information in Ivy #36971
Conversation
4cae009
to
7c7d0da
Compare
Due to our weird cyclic dependency with the framework repository, we need to apply changes from angular/angular#36971 before the PR can actually land in framework. This is because the changes of that PR fail in the components repo job as we apply patches that conflict with the new changes. At the same time though, we cannot make the components repo compatible until the framework PR landed. We work around this as usually done, by applying the upstream changes through a patch. Then we can resolve conflicts and the framework PR can land. Eventually we can then remove the patch again from the components repo.
7c7d0da
to
3b9bbfd
Compare
This is blocked on angular/components#19276 so that the components repo job can turn green. Review on this PR would be still appreciated though 😄 |
I'm delegating the compiler approval as I don't know about any of this stuff. Btw, this is currently failing CI even without the components tests. |
8b76b03
to
25f7697
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should discuss this one in person with @alxhub as there as several things at play here.
I looked into this in the past and it wasn't quite clear what we should about the issue you are highlighting.
This was primarily because it was not even clear if we needed this feature at all or if we could simply if significantly.
In the past when the VE compiler was compiling a library into npm-shippable format, it also had to re-export private symbols referenced by component metadata within this lib via the flat index file. These reexports were necessary so that these symbols could be imported by factories produced much later by the second compiler pass invoked from within the app that used this library.
With ivy we no longer need these private symbol reexports because the factories are inlined into the original classes. In fact the final ivy npm package (g.co/apf) format will be different than what it is today but these plans have not solidified yet and Alex is doing exploration in this area.
One possible resolution for this PR could be that we merge this change as a temporary improvement that will likely be replaced/augmented further by Alex's changes before we actually start shipping this format to npm.
@IgorMinar I agree that long-term this needs to be reconsidered (i.e. packaging w/ Ivy in general), but in the current state,
Not using the flat module index has the downside that index paths need to be guessed in the In a current Bazel project, switching between compilation modes should be possible. So, even if flat module indices are not technically needed with the Ivy configuration, they are needed as a layer of indirection to make the switch between Happy to discuss this more. Let me know if this should happen in the PR, or if you want set up a meeting. |
If I am understanding this correctly, it seems that having |
@josephperrott Yeah, that seems correct to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change on the surface looks okay to me. It does what it says on the box :)
There's a larger issue here, though, that I think we should discuss before going down this route.
Eventually we want to switch away from ng_module.bzl
entirely, and compile Angular packages as ts_library
invocations with an Angular plugin. Ideally in most cases this will be a switch we flip inside the ng_module
alias, but it seems like the ng_package
machinery relies on special knowledge of Angular outputs in order to function. Given that this information won't be available from ts_library
outputs, I think the right fix to this problem is to make ng_package
work in the absence of any special information about its inputs. I recognize that's not an easy problem to solve, but I think we should look at what that would take.
@alxhub That's a really good point. I agree that Also agreed that this is probably more difficult than it initially sounds. How do you want to proceed on this? My thinking is that this change is still not necessarily coupled to I'd be happy to help with this issue in the long-term. |
Due to our weird cyclic dependency with the framework repository, we need to apply changes from angular/angular#36971 before the PR can actually land in framework. This is because the changes of that PR fail in the components repo job as we apply patches that conflict with the new changes. At the same time though, we cannot make the components repo compatible until the framework PR landed. We work around this as usually done, by applying the upstream changes through a patch. Then we can resolve conflicts and the framework PR can land. Eventually we can then remove the patch again from the components repo.
Due to our weird cyclic dependency with the framework repository, we need to apply changes from angular/angular#36971 before the PR can actually land in framework. This is because the changes of that PR fail in the components repo job as we apply patches that conflict with the new changes. At the same time though, we cannot make the components repo compatible until the framework PR landed. We work around this as usually done, by applying the upstream changes through a patch. Then we can resolve conflicts and the framework PR can land. Eventually we can then remove the patch again from the components repo.
Due to our weird cyclic dependency with the framework repository, we need to apply changes from angular/angular#36971 before the PR can actually land in framework. This is because the changes of that PR fail in the components repo job as we apply patches that conflict with the new changes. At the same time though, we cannot make the components repo compatible until the framework PR landed. We work around this as usually done, by applying the upstream changes through a patch. Then we can resolve conflicts and the framework PR can land. Eventually we can then remove the patch again from the components repo.
25f7697
to
f031e27
Compare
I'm good with the changes from a dev-infra perspective, but will let @IgorMinar sign off for bazel as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, except that I'd like is to move away from the "flat module" terminology in this code. The provider doesn't provide info about flat modules, but rather about "entryPoints".
Historically we often confused the "flat module" and "entry point" terminology because it was complicated by odd requirements that View Engine had.
For the historical context: the index file used to create/bundle the flat module file, or FESM, had to be generated because of reexports of private symbols from within the flattened module to ensure that factories built by ngc didn't have deep imports into the flattened module. These deep imports would not work with FESMs and the generated reexports ensured that everything still worked. It was a terrible hack, but thankfully as soon as VE is deleted we'll no longer have to think about it.
In the meantime, I strongly suggest that we rename the terminology we use in these providers to entry points. I'm fine ok if this is done in a follow up PR as long as it's done eventually. Thanks
@IgorMinar Yeah, that's a good point. One concern I'd have with changing this to Though long-term, if we get to the point with Ivy where flat module files are no longer generated, we won't have a good way to determine an entry-point file (unless we add some configuration-level heuristics or an other attribute like I feel like it would be best to just keep terminology as is (namely flat module metadata) and revisit once VE is gone. I assume once we get there, it will involve more thinking on how |
@devversion sgtm I do think that the flatModuleId and flatModuleOutFile compiler options should be deprecated as at the time we release Ivy support for libraries because those options don't make sense with Ivy and should be supported by Ivy just to easy the migration from VE to Ivy for libraries. https://angular.io/guide/angular-compiler-options#flatmoduleid |
… Ivy 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`.
f031e27
to
c629713
Compare
… 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 issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
… Ivy (angular#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 angular#36971
The
ng_module
rule supports the generation of flat module bundles. InView 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 apackage is built specifically with
--config=ivy
.This allows us re-enable the tests we previously had to disable when switching to APF. The tests started failing because previously the entry-points were hardcoded, but now we rely on the automatic resolution of those. And apparently tests highlighted that the resolution is incorrect in Ivy.