Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

AngularDart apps do not work without the transformer #1344

Closed
antonmoiseev opened this issue Aug 12, 2014 · 19 comments
Closed

AngularDart apps do not work without the transformer #1344

antonmoiseev opened this issue Aug 12, 2014 · 19 comments
Milestone

Comments

@antonmoiseev
Copy link

AngularDart 0.13.0 now requires angular transformer to be enabled. Here is an example of a minimal app to reproduce:

index.html:

<!DOCTYPE html>
<html>
  <head></head>
  <body>
    <script type="application/dart" src="main.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>

main.dart:

import 'package:angular/application_factory.dart';
main() => applicationFactory().run();

Without the enabled transformer it throws an exception:

Exception: Module.DEFAULT_REFLECTOR not initialized for dependency injection. http://goo.gl/XFXx9G

My understanding is if I use applicationFactory().run() I run DI in the dynamic mode, so it shouldn't require any static code transformation.

Manually setting Module.DEFAULT_REFLECTOR = new DynamicTypeFactories(); doesn't help, it still requires transformer to be enabled.

Due to the issue with Angular transformer, it brings major inconvenience in development workflow, so I'd rather avoid it for now.

@vicb
Copy link
Contributor

vicb commented Aug 12, 2014

Could you pub upgrade and try again ? (what is your DI version)

@antonmoiseev
Copy link
Author

Just tried, all the dependencies are up to date. di version is 2.0.2.

@vicb
Copy link
Contributor

vicb commented Aug 12, 2014

Ah but you're using the compiled version, right ?

@antonmoiseev
Copy link
Author

Not sure what you mean by compiled version. The issue is reproducible in both - Chromium (37.0.2062.0 (287872) and Chrome (36.0.1985.125).

@vicb
Copy link
Contributor

vicb commented Aug 12, 2014

Do you launch via the Dart Editor (or pub serve) ?

@antonmoiseev
Copy link
Author

pub serve

@vicb
Copy link
Contributor

vicb commented Aug 12, 2014

Then the di transformer is executed... and is not compatible with the dynamic app factory.
A workaround could be to serve you folder (without going through pub serve), like with python simpleHTTPServer.
A solution is to the fix the linked issue - with the transformers.

@antonmoiseev
Copy link
Author

So, di transformer is always executed even if I run the app in Dartium? How to run in a completely dynamic mode then? The solution you mentioned won't enable dynamic mode.

BTW, The same behavior even if I launch app using Dart Editor (I believe Dart Editor uses pub serve internally for a long time by now).

@zoechi
Copy link
Contributor

zoechi commented Aug 13, 2014

I think this is related to http://dartbug.com/19168

@vicb
Copy link
Contributor

vicb commented Aug 13, 2014

So, di transformer is always executed even if I run the app in Dartium? How to run in a completely dynamic mode then? The solution you mentioned won't enable dynamic mode.

simpleHTTPServer or any similar solution, I think there is an equivalent in Dart now

BTW, The same behavior even if I launch app using Dart Editor (I believe Dart Editor uses pub serve internally for a long time by now).

Yep, DE uses pub serve

@antonmoiseev
Copy link
Author

@zoechi thanks. Indeed, they seem related. There is an issue with dart2js transformer, here I guess di transformer introduces the downgrade.

@vicb Sorry for bothering you 😉, but I still have questions. SimpleHTTPServer only partialy workarounds the problem, since it disables all the transformers, not only angular/di ones. Before upgrading to 0.13.0 I was able to comment out angular transformer in pubspec.yaml and work in a completely dynamic mode using pub serve and Dartium. Resolving issue with angular transformer won't bring the dynamic mode back. My understanding is that di/module_transformer.dart introduced in di 2.0.0, causes this issue. The things I want to find out here:

  1. Will we be able to work in a dynamic mode without any static code transformations with pub serve and Dartium? (Because before we could)
  2. If so, what issue should I track to be notified when the problem is resolved?

@vicb
Copy link
Contributor

vicb commented Aug 13, 2014

As of today pub serve will always run the DI transformer.

May be you can open an issue on the DI repo to initiate a discussion on this topic.

One solution would be to not run the DI transformer by default but to trigger it from the client lib (angular in our case). This would probably solve your issue - still we need to make sure it actually works. On the flip side running the dynamic version makes little sense.

The best would be to have #1276 solved

@zoechi
Copy link
Contributor

zoechi commented Aug 13, 2014

Running the dynamic version might only be interesting in setups where a web server different from pub serve is used during development but this is not uncommon.

If Angular doesn't work without a transformers the 3rd party server needs to be configured so that it forwards specific requests to pub serve. This can become quite cumbersome.

@vicb
Copy link
Contributor

vicb commented Aug 13, 2014

If Angular doesn't work without a transformers the 3rd party server needs to be configured so that it forwards specific requests to pub serve. This can become quite cumbersome.

Hopefully it works w/o transformers :)

@Pajn
Copy link

Pajn commented Aug 13, 2014

Hopefully it works w/o transformers :)

It does, I develop by serving my app through my custom server without any transformers at all.
The problem seems to be when serving through pub without the angular transformer.

@antonmoiseev
Copy link
Author

Running the dynamic version might only be interesting in setups where a web server different from pub serve is used during development but this is not uncommon.

@zoechi Sorry, I don't clearly understand the point. Why dynamic mode is only interesting for non-pub web servers? We do want to run our app using pub serve, but we don't want to use angular and di transformers during development:

  1. Besides angular and di transformers we had two other transformers enabled till recently - implicit assets transformer (which is now deprecated), and our custom validation transformer. Without pub serve we can't use them.
  2. At the same time angular and di add significant turn-around time in the development workflow. So we'd rather use them only during testing and while deploying in production.

And in fact AngularDart apps do not work without transformers right now if they hosted using pub serve.

@zoechi
Copy link
Contributor

zoechi commented Aug 14, 2014

I just tried to provide a use case that demonstrates that support for running without transformer is useful/important. If there are other use cases I was not aware of this is fine too ;-)

@rkirov rkirov added this to the post v1.0 milestone Oct 9, 2014
@rkirov
Copy link
Contributor

rkirov commented Oct 9, 2014

Out of scope for angular.dart, we don't plan to support non-transformer workflows (sorry).

@rkirov rkirov closed this as completed Oct 9, 2014
@zoechi
Copy link
Contributor

zoechi commented Oct 12, 2014

As far as I know it is planned to run transformers in pub serve only when a non-Dart browser requests a site. From the discussions at dartbug.com I got the impression it is considered a bug that transformers are run when Dartium requests a page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants