I thought to try to finish off the Strategy Pattern chapter in Patterns in Polymer tonight. Only when I loaded some “play” code in Dartium, I saw the following error in the console:
Exception: The "smoke" library has not been configured. Make sure you import and configure one of the implementations (package:smoke/mirrors.dart or package:smoke/static.dart). #0 throwNotConfiguredError (package:smoke/src/implementation.dart:34:3) #1 typeInspector (package:smoke/src/implementation.dart:26:5) #2 query (package:smoke/smoke.dart:85:20) #3 _getPublishedProperties (package:polymer/src/declaration.dart:409:31) #4 PolymerDeclaration.publishAttributes (package:polymer/src/declaration.dart:175:39) #5 PolymerDeclaration.buildType (package:polymer/src/declaration.dart:95:22) #6 PolymerDeclaration.register (package:polymer/src/declaration.dart:72:14) #7 _hookJsPolymer.registerDart.<anonymous closure> (package:polymer/src/loader.dart:100:75) #8 _rootRun (dart:async/zone.dart:719) #9 _ZoneDelegate.run (dart:async/zone.dart:453) #10 _CustomizedZone.run (dart:async/zone.dart:663) #11 _hookJsPolymer.registerDart (package:polymer/src/loader.dart:99:22)Are. You. FREAKING. Kidding me?!
I specifically started tonight with writing so that I could get away from that stupid error. It is the same error that has plagued my testing efforts for the past two nights and now I am seeing it application code. Noooooo!
This was some relatively old Polymer.dart code that I am upgrading to the 0.10 version of the library. So I have already gone through it to tack on
component=1to the mime types so that the Dart VM will know to run all Polymer code in the same isolate:
<polymer-element name="store-changes-load"> <template><!-- ... --></template> <script src="store_changes_load.dart" type="application/dart;component=1"></script> </polymer-element>I have already fixed the dependencies of my play application to use the appropriate bleeding-edge versions of the libraries in my
name: change_history dependencies: polymer: ">0.10.0-pre" polymer_elements: ">0.2.0-pre" dev_dependencies: unittest: anySo why, oh why am I still getting “smoke” package exceptions? Well, the title of this post pretty much gives it away: since this is old code, I have not specified a Polymer pub transformer in my Dart Pub configuration. If I add it to
name: change_history dependencies: polymer: ">0.10.0-pre" polymer_elements: ">0.2.0-pre" dev_dependencies: unittest: any transformers: - polymer: entry_points: web/index.htmlThen all of my Polymer code magically starts working.
And yup, if I go back to the
pubspec.yamlfrom last night, add my test page to the list of files that are transformed by the Polymer transformer:
name: model_example dependencies: polymer: ">=0.10.0-pre" dev_dependencies: scheduled_test: any transformers: - polymer: entry_points: - web/index.html - test/index.htmlThen my test magically passes.
Ah, life on the bleeding edge. Sometimes it does cut deep. But lesson learned: always include all pages using Polymer elements in the list of Polymer transformers—even test pages. I will never, NEVER forget that.