Workiva / dart_to_js_script_rewriter

A pub transformer that Rewrites Dart script tags to JavaScript script tags, eliminating 404s and speeding up initial loads. Use when building for deployment.
BSD 3-Clause "New" or "Revised" License
21 stars 20 forks source link

" zero or multiple dart scripts" error #18

Open proteme opened 8 years ago

proteme commented 8 years ago

Even though I have reference to a single dart script, I get the following error on "release" build.

[Error from ScriptCompactor on Project|web/index.html]:
Found either zero or multiple dart scripts in the entry point `web/index.html`. Exactly one was expected.

I do have references to two other JavaScript scripts in the same index.html.

I am not sure if I am doing something wrong, or this is a bug.

FaisalAbid commented 8 years ago

I may be mistaken, but I think ScriptCompactor is actually part of the DartSDK. This is an SDK bug, not dart_to_js_script_rewriter bug.

sethladd commented 8 years ago

Can you please post your pubspec.yaml ?

proteme commented 8 years ago

Thanks, Faisal and Seth.

Here is my pubspec.yaml:

name: Project
version: 0.0.1
author: <Hesh> <proteme@gmail.com>
description: Check those boxes
homepage: http://proteme.org/Anton
environment:
  sdk: '>=1.0.0 <2.0.0'
dependencies:
  browser: any
  core_elements: any
  firebase: any
  intl: any
  js_bridge: any
  paper_elements: any
  polymer: any
  string_tokenizer: any
  uuid: any
  test: any
  dart_to_js_script_rewriter: any
transformers:
- dart_to_js_script_rewriter
- polymer:
    entry_points:
    - web/index.html
    - web/rules.html
- $dart2js:
    commandLineOptions: [--enable-experimental-mirrors]

I also tried with removing one of the entry points, but with same results.

donny-dont commented 8 years ago

I see the same error in a polymer 1.0 application if I put dart_to_js_script_rewritter as the first transformer. Putting it after web_components makes it so the error doesn't appear but then the transformer doesn't seem to be doing its job as both script tags are still there.

jakemac53 commented 8 years ago

ah, the issue here is the dart_to_js_script_rewriter transformer should come after the polymer transformer. The ScriptCompactor is one of the Polymer phases, it looks in your entry point html for dart script tags and html imports, and bootstraps the app with a single dart file that imports all reachable dart files.