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.
[x] Create a new class with optional flags for doing less reflectable recording.
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.
[x] Remove recording @Component' as @Injectables.
[x] Remove recording @Directive' as @Injectables.
[x] Remove recording @Pipe as @Injectables.
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:
[x] Only record @RouteConfig as metadata annotation, nothing else.
The
Reflector
class was important in AngularDart<=3.0
, because it powered both theReflectiveInjector
(the only real way for creating new injectors at runtime) andDynamicComponentLoader
(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.@Component
' as@Injectable
s.@Directive
' as@Injectable
s.@Pipe
as@Injectable
s.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
:@RouteConfig
as metadata annotation, nothing else.Changes potentially with flags
TBD.