Problems with Dart/Polymer build output files / everything compiled/pasted into index.html

Issue

I’m probably missing something very basic here, but I’ve spent quite a while searching for just about any term I could come up with.

I wanted to check out Dart and Dart.Polymer, so I grabbed some examples from various tutorials. I managed to get everything working, but it seems ALL HTML/JS/CSS content from custom Polymer elements and paper-/iron-/… elements get pasted to index.html, along with various other JavaScript stuff.
This leads to my index.html being 16.000+ lines long in release mode builds, (20.000 in debug) in this Dart Academy Tutorial, and here is the corresponding source in GitHub

The tutorial also links to a live version that has pretty HTML/imports.

The same happens with the basic Polymer sample project in Webstorm.

My different setups:

  • Windows 10 and Ubuntu 14.04 (tried both)

  • Dart SDK current stable and dev version

  • pub build –mode:release and debug, from commandline and within Webstorm
  • various transformers, various orders, various dependency versions in pubspec.yaml

Aside from the index.html file my output folder seems fine, elements are present in e.g. output_folder/build/web/packages/polymer_elements/.

I know that everything that is compiled into the index is necessary, but why does it not generate links to the files in the created build/polymer_elements folder? I assume it is possible and the live versions of the examples I found have not been edited manually to link to all elements and scripts and cut them from index.html. I know it probably does not even affect load times in a significant way, but it still bugs me.

Thanks for any help in advance, don’t be shy to point out if I read over something very basic or just did not search for the right term 😀

Solution

This is a deployment optimization, similar to the vulcanize tool for polymer js, except that its the default in Dart. Html imports create tons of extra requests which is slower than just downloading the one large file.

Answered By – Jake MacDonald

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

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