angulardart-community / angular

Fast and productive web framework provided by Dart.
https://pub.dev/packages/ngdart
MIT License
114 stars 15 forks source link

refactor!: remove Testabiliy and TestabilityRegistry from minimal application and make it injectable #28

Closed ykmnkmi closed 2 years ago

ykmnkmi commented 2 years ago

Testability is the only API that relies on the js package (not js_util) and that increases the build size. Now, in order to use the Testability API, you need to inject it manually using GenerateInjector with testabilityProvider:

@GenerateInjector([testabilityProvider])
final InjectorFactory appInjector = ng.appInjector$Injector;

void main() {
  runApp(ng.MyAppComponentNgFactory, createInjector: appInjector);
}

For example, the build size of the hello_world (without js package) example was 163,315 and is now 101,983.

Also some ToDo fixes.

ykmnkmi commented 2 years ago

Or remove Testability API?

GZGavinZhao commented 2 years ago

Nice code size reduction!

I agree with this mostly, but maybe not remove it for now. I think it is still useful to be able to know the state (particularly the isStable stuff) from the JS side for testing & potentially SSR. Not automatically injecting it is enough.