Polymer + Dart2js Not Working

Issue

When I create a new application using the Polymer library, it generates a sample project. The project works just fine in Dartium, but when I compile it (using pub build), it doesn’t work anymore.

I get two 404’s and an uncaught typeerror.

Here is my console output in Chrome.

GET file:///home/michael/Code/sample/build/web/packages/shadow_dom/shadow_dom.debug.js  sample.html:1
GET file:///home/michael/Code/sample/build/web/packages/custom_element/custom-elements.debug.js  sample.html:2
Uncaught TypeError: Object #<HTMLDocument> has no method 'registerElement' sample.html_bootstrap.dart.js:6681
    wi sample.html_bootstrap.dart.js:6681
    ei sample.html_bootstrap.dart.js:9102
    Ok sample.html_bootstrap.dart.js:9099
    QL sample.html_bootstrap.dart.js:2184
    aX.vV sample.html_bootstrap.dart.js:759
    Vg sample.html_bootstrap.dart.js:644
    (anonymous function) sample.html_bootstrap.dart.js:12464
    init.currentScript sample.html_bootstrap.dart.js:12444
    (anonymous function) sample.html_bootstrap.dart.js:12458
    (anonymous function) sample.html_bootstrap.dart.js:12585

These files exist in build/web/packages/, so I’m not sure why I’m getting a 404.

This worked fine before I updated to the latest Dart SDK (dev channel). Is it just a bug in there, what might be going on?

Thanks.

Update:

I saw a Dart issue that I was having another issue with, so I applied their fix to the sample project, and now I only get the Uncaught TypeError. Now my output looks like this:

Uncaught TypeError: Object #<HTMLDocument> has no method 'registerElement' sample.html_bootstrap.dart.js:6518
    wi sample.html_bootstrap.dart.js:6518
    ei sample.html_bootstrap.dart.js:8949
    Ok sample.html_bootstrap.dart.js:8946
    QL sample.html_bootstrap.dart.js:2142
    aX.vV sample.html_bootstrap.dart.js:725
    Vg sample.html_bootstrap.dart.js:587
    (anonymous function) sample.html_bootstrap.dart.js:12313
    init.currentScript sample.html_bootstrap.dart.js:12293
    (anonymous function) sample.html_bootstrap.dart.js:12307
    (anonymous function) sample.html_bootstrap.dart.js:12434

Solution

I got it to work by placing a dependency constraint on polymer. My pubspec.yaml file now looks like this:

name: sample
description: A sample Polymer application
dependencies:
  browser: any
  polymer: "0.9.5"
transformers:
- polymer:
    entry_points: web/sample.html

Answered By – Michael Peterson

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *