angulardart/angular

Why isn't the ngFactory coupled to the Component's class?

jodinathan opened this issue · 0 comments

Hello,

Thanks for the hard work with Angular!
We really like this project.

We have an internal (for now) version of Angular that has some tweaks and we will start migrating to Angular 7 and NNBD soon. As we do that we thought in making the components tightly coupled to the generated code. Basically, instead of generating stuff into .dart_tool we would make it generate the code in the same folder as the class and make the class extend the generated code. Pretty much like any other source generator package out there.

By letting the template directly use the class file through part of binding we aim to:

  • Remove exportAs.
  • Let the template use private stuff.
  • Make the generated class expose common things like the NgFactory and changeDetectionRef.markForCheck
  • Add methods to aid debugging
  • Comment the generated code with info so the dev can have a better understanding of what is happening
  • Allow implicit injection by making the original authored class only declare a getter.
    Example: abstract class MyComponent extends _Ng { ParentComponent get parent; }
    Would make the generated class have the parent property without having to use the constructor. Reasoning: We had a hard time refactoring components because the base class needed additional injections.

However, before we dig into that, we would like to know if you could please share info that could make we not follow that path or any suggestions/info at all.