dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
181 stars 33 forks source link

polymer sample code in 17.1 missing reflectable dependency?! #703

Closed floitschG closed 8 years ago

floitschG commented 8 years ago

From @HannesRammer on July 3, 2016 1:16

I just created a new project with polymer sample code, and I have to add the reflectable package to make it run, so i thought maybe it would make sense to add them directly on generation

I am on windows 10 insider dart stable 17.1
intellij 2016.1.3 environment: sdk: '>=1.9.0 <2.0.0'

this is my pubspec dependency list

dependencies: browser: ^0.10.0
polymer_elements: ^1.0.0-rc.8 polymer: ^1.0.0-rc.15 web_components: ^0.12.0 analyzer: ">=0.27.1 <0.27.2" #I needed to add this since im on win10 reflectable: "^0.5.2" #I need to add this line else I get the error msg below

Uncaught Unhandled exception: Bad state: Reflectable has not been initialized. Did you forget to add the main file to the reflectable transformer's entry_points in pubspec.yaml?

Copied from original issue: dart-lang/sdk#26820

floitschG commented 8 years ago

From @zoechi on July 3, 2016 13:31

Can you please share the minimal code that allows to reproduce? How does the entry_point transformer configuration look like?

floitschG commented 8 years ago

From @HannesRammer on July 3, 2016 22:27

I only created new dart project in intellij using polymer app example code.

floitschG commented 8 years ago

From @zoechi on July 4, 2016 6:33

How did you create it? What are the exact steps. How does the entry point config look like in pubspec.yaml?

floitschG commented 8 years ago

From @HannesRammer on July 5, 2016 11:0

In intelliJ

  1. click File
  2. click New
  3. click Project
  4. select dart
  5. select generate sample content
  6. select Polymer Web Application
  7. click next
  8. click finish
  9. run pub get/update 10 .debug index.html - results in a 404
  10. add analyzer: ">=0.27.0 <0.27.2" to pubspec,yaml
  11. run pub get/update
  12. debug index.html - results in

Uncaught Unhandled exception: Bad state: Reflectable has not been initialized. Did you forget to add the main file to the reflectable transformer's entry_points in pubspec.yaml?

  1. add reflectable: "^0.5.2" to pubspec,yaml
  2. run pub get/update
  3. debug index.html - DONE, now its working

----------START pubspec.yaml-------------- name: 'untitled' version: 0.0.1 description: A web app built using polymer.dart.

author: Your Name email@example.com

homepage: https://www.example.com

environment: sdk: '>=1.9.0 <2.0.0'

dependencies: browser: ^0.10.0 polymer_elements: ^1.0.0-rc.8 polymer: ^1.0.0-rc.15 web_components: ^0.12.0 analyzer: ">=0.27.0 <0.27.2" reflectable: "^0.5.2"

transformers:

floitschG commented 8 years ago

From @eernstg on July 5, 2016 14:29

That kind of reporting is much more actionable, thanks a lot!

I've worked on reflectable but not directly on polymer, so I'll give my 2 cents from that point of view.

I cannot reproduce the 'Reflectable has not been initialized' exception (I think I've followed your description at every step, and it just works at step 10 here, with no need to add any dependencies). But I can give you a bit of information about the situation where you will get that exception:

Essentially, 'Reflectable has not been initialized' means that the initialization code for reflectable has not been executed, and then the first attempt to use the compile-time database which enables the mirror features offered by reflectable will fail with that exception. It does not have to happen immediately: your application might not use mirrors at all for a while. One way this can happen is if you are using reflectable directly, requesting reflectable as a transformer in pubspec.yaml, and then forgetting to specify your application as an entry point.

In this case you are using polymer, however, and this means that the reflectable transformer is not needed in pubspec.yaml. Polymer has its own transformer which imports the reflectable transformer as code (among others), so only the polymer transformer should be in pubspec.yaml, and it will pass on its entry points to reflectable.

I'm sure @jakemac53 has more specific input on how the problem you described could arise, and what to do about it (and possibly placing this issue on polymer rather than sdk), but this should at least give you some background.