将Polymer Dart编译为JS后出错。 (“smoke”库尚未配置)

时间:2015-04-27 16:16:20

标签: dart dart-polymer dart-pub dart2js

将Dart代码(使用Dart Polymer)编译成JS。我收到以下错误:

Uncaught 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).

有时消息是:

No elements registered in a while, but still waiting on 1 element to be registered. Check that you have a class with an @CustomTag annotation for each of the following tags: 'app-element'

这里有什么问题?这是我的代码:

更新:现在,pub build之后的代码已经改进并正常运行。我更改文件夹/文件结构并将聚合物更新到最新版本。

pubspec.yaml

name: app
dependencies:
  browser: any
  #do not forget update to latest version by running pub update 
  polymer: any
transformers:
- polymer:
    entry_points:
    - web/main.html

网络/模板/ UI-elements.html

<polymer-element name="app-globals"></polymer-element>

<polymer-element name="app-element">
  <template>
    <link rel="stylesheet" href="/main.css"/>
    <content></content>
  </template>
  <script type="application/dart" src="ui-elements.dart"></script>
</polymer-element>

网络/模板/ UI-elements.dart

@CustomTag('app-globals')
class AppGlobals extends PolymerElement{
  AppGlobals.created() : super.created();
}

@CustomTag('app-element')
class AppElement extends PolymerElement {
  AppElement.created() : super.created();
}

web / main.html (虚拟条目文件)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  </head>
  <body>
    <app-element></app-element>
    <script type="application/dart" src="main.dart"></script>
  </body>
</html>

网络/ main.dart

import 'package:polymer/polymer.dart';

main() {
  initPolymer();
}

@whenPolymerReady
void onReady() {
}
pub build之后

web / main.html (切入点)。编译后真正的混乱。如此多的js文件,其中一些大小甚至超过300kb。

<!DOCTYPE html><html lang="en"><head><script src="packages/web_components/webcomponents.min.js"></script><script src="packages/web_components/dart_support.js"></script>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  </head>
  <body><div hidden=""><style shim-shadowdom="">
/*******************************
          Flex Layout
*******************************/

html /deep/ [layout][horizontal], html /deep/ [layout][vertical] {
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
}

html /deep/ [layout][horizontal][inline], html /deep/ [layout][vertical][inline] {
  display: -ms-inline-flexbox;
  display: -webkit-inline-flex;
  display: inline-flex;
}

......tons of other styles...........

</style>

<script src="packages/polymer/src/js/polymer/polymer.min.js"></script>

<script>
// TODO(sigmund): remove this script tag (dartbug.com/19650). This empty
// script tag is necessary to work around a bug in Chrome 36.
</script>

<!-- unminified for debugging:
<link rel="import" href="src/js/polymer/layout.html">
<script src="src/js/polymer/polymer.js"></script>
-->
<polymer-element name="app-globals"></polymer-element>

<!-- APP ELEMENT -->
<polymer-element name="app-element" class="bck-medusa w-100 h-100">
  <template>
    <link rel="stylesheet" href="../main.css">
    <content></content>
  </template>
</polymer-element>
</div>
    <script src="main.html.polymer.bootstrap.dart.js" async=""></script>


</body></html>

1 个答案:

答案 0 :(得分:1)

使用initPolymer时,您不需要@whenPolymerReady。在您的示例中,整个main()方法都是多余的。

您是否在pubspec.yaml

中的聚合物变压器配置中正确注册了您的输入页面

烟雾需要变压器,但如果你正确配置了聚合物变压器,则包含烟雾变压器。