angulardart / angular

Fast and productive web framework provided by Dart
https://pub.dev/packages/angular
MIT License
1.83k stars 231 forks source link

Cleanup and start deprecating the reflector #571

Closed matanlurey closed 7 years ago

matanlurey commented 7 years ago

The Reflector class was important in AngularDart <=3.0, because it powered both the ReflectiveInjector (the only real way for creating new injectors at runtime) and DynamicComponentLoader (the only real way for imperatively creating components).

As of 4.x, we'd like to deprecate, and start removing parts of the reflection recording where possible. This is going to greatly help tree-shaking (no storing of factories in a global Map), code-size (as a result), and steer users onto the "golden path" of a static/optimizable application.

Some of the [internal] API will need to be maintained longer term (with or without flags), and some will be deprecated and removed ASAP, as simple alternatives exist.

Changes with no flags

These changes to the API won't be flagged.

Next, we currently record dependencies and a factory for classes that are not explicitly annotated with @Injectable. That's unfortunate because they aren't used as such 99.9% of the time, but you always pay the cost. Users can add @Injectable() to these classes to retain the behavior.

Next, we currently have a legacy router that requires use of the reflector, primarily for looking up @RouteConfig annotations. We'd like to deprecate that as well, but it needs to work until a new router is available. As such, we should make sure we are only recording @RouteConfig:

Changes potentially with flags

TBD.

matanlurey commented 7 years ago

Marking closed! All the changes are in!