-
Notifications
You must be signed in to change notification settings - Fork 57
Transform InjectorGenerator No Element #162
Comments
DI2 is used by angular and a lot of its libs do not have a |
It requires a main method so it can insert code to initialize DI at the top of the main function. If your library is to be used by other libraries, you can do what Angular does and call the DI transformer in its transformer. Then apps with a main method will list Angular as a transformer which will call DI, so it avoids Angular itself running the DI transformer without a main method. |
If I don't have a main method the di transformer (run by angulars transformer) throws this: Build error:
Transform InjectorGenerator on raxa|web/lib/raxa.dart threw error: Bad state: No element
dart:collection/iterable.dart 319 IterableBase.first
http://localhost:41984/packages/di/transformer/injector_generator.dart 377:10 _Processor._editMain
http://localhost:41984/packages/di/transformer/injector_generator.dart 73:14 _Processor.process
http://localhost:41984/packages/di/transformer/injector_generator.dart 25:59 InjectorGenerator.applyResolver
http://localhost:41984/packages/code_transformers/src/resolvers.dart 113:44 Transformer&ResolverTransformer.applyToEntryPoints.<fn>.<fn>
dart:async/future.dart 118 Future.Future.<fn>
dart:async-patch/timer_patch.dart 12 Timer._createTimer.<fn>
dart:io/timer_impl.dart 292 _handleTimeout
dart:isolate-patch/isolate_patch.dart 122 _RawReceivePortImpl._handleMessage
dart:collection IterableBase.first
http://localhost:41984/packages/di/transformer/injector_generator.dart 377:10 _Processor._editMain
http://localhost:41984/packages/di/transformer/injector_generator.dart 73:14 _Processor.process
http://localhost:41984/packages/di/transformer/injector_generator.dart 25:59 InjectorGenerator.applyResolver
http://localhost:41984/packages/code_transformers/src/resolvers.dart 113:44 Transformer&ResolverTransformer.applyToEntryPoints.<fn>.<fn>
dart:isolate _RawReceivePortImpl._handleMessage
[Error from _Serial on raxa|web/main.dart]:
Could not load asset raxa|web/lib/raxa.dart
[Error from _Serial on raxa|web/main.dart]:
Could not load asset raxa|web/lib/raxa.dart With this main method: |
I just updated my copy of the Dart SDK to 1.7.2 and am now receiving the same error. Where does the main method need to be added? |
OMG!!!! The same here. Here is my sample (I'm using Dart 1.8.3 + Angular 1.0)
|
@jarredkenny To the entry page for example |
I found out that it only occures if the source is not in /web |
Same error even if my source are all in /web. |
@seguins I tried it with your patch and AD 1.1 - still the same. One of my samples is in
If I pub build example/mm_uia_overlay I get a ton of errors like:
BUT!!!!
It works... |
It's strange because, you have an error at line 374 of package:di/transformer/injector_generator.dart and in my file, there is nothing at the line : https://github.com/seguins/di.dart/blob/no_main/lib/transformer/injector_generator.dart#L374 Maybe there is a kind of cache ? |
In Version 2 the transformer now requires that all my libraries need to have a main method.
Why is this required / is this a bug
The text was updated successfully, but these errors were encountered: