vsavkin / angulardart-sample-app

A sample Web application built using AngularDart
Other
102 stars 27 forks source link

fix(pubspec): Add the angular transformer #20

Closed vicb closed 10 years ago

vicb commented 10 years ago

This is needed for built code to work

see https://github.com/angular/di.dart/issues/161

codingoptimist commented 10 years ago

Thanks for your quick response vicb, following your suggestion this is where Iam:

Adding transformers: - angular using angular: ">=0.13.0 <0.14.0" causes: Breaking on exception: Type 'DynamicMetadataExtractor' not found in generated typeFactory maps. Is the type's constructor injectable and annotated for injection? But this is with a workaround in place ie. import 'package:di/src/reflector_dynamic.dart'; class TalkToMeApp extends Module { TalkToMeApp() : super.withReflector(new DynamicTypeFactories()) { bind(SomeCtrl); bind(SomeOtherCtrl);}} That same error occurs even with the work-a-round removed.

However, using angular: ">=0.12.0 < 0.13.0"
with transformers: - angular added and environment sdk set to:
sdk: ">=0.8.10 < 2.0.0" or as sdk: ">=0.1.5.8 < 2.0.0"
with work-a-round removed, now everything works fine.

Is there a fix for the error when upgraded to angular 0.13.0?

vicb commented 10 years ago

The DynamicMetadataExtractor should not be used by the transformed code, let me investigate this issue.

vicb commented 10 years ago

The issue is that this application uses a pattern that is not supported by the angular transformer: the angular application is started from a library (talk_to_me).

The angular transformer would only transform your application code (talk_to_me_main.dart) but would not change the lib code. Then the library code use the un-transformed version of the application factory which returns a dynamic application while a static application should be used.

Even before 0.13, the code was not transformed but the changes in the DI trigger this issue. Before 0.13 the DI was initialized by the angular Application. This means that before 0.13 you are using a DynamicInjector which explains why it works.

With the new DI (v2) The DI initialization code is added to the application main function (in talk_to_me_main.dart) by the transformer. The good point is that you are now using a static injector, as expected. The bad point is that you are using a dynamic application that can not work with the static injector.

I'll create a ticket on the angular issue tracker to discuss if this is pattern we want to support.

codingoptimist commented 10 years ago

OK, Thank you, it sounds very touch 'n' go, 50:50 Not sure what I could do to help this along as I don't know enough at this stage, so i'll have to sit it out and wait for a verdict and hopefully a fix of some sort.

Thanks again for your time.