简体   繁体   English

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

[英]Error after compiling Polymer Dart to JS. (The “smoke” library has not been configured)

Аfter compiling Dart code (which use Dart Polymer) to JS. Аfter将Dart代码(使用Dart Polymer)编译为JS。 I get the following error: 我收到以下错误:

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

Sometimes the message was: 有时消息是:

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'

What's wrong here? 怎么了 Here is my code: 这是我的代码:

UPDATE : now code beyond is improved and work correctly after pub build . 更新 :现在,超越了的代码得到了改进,并且在pub build后可以正常工作。 I change folder/file structure and update polymer to the latest version. 我更改文件夹/文件结构并将聚合物更新为最新版本。

pubspec.yaml 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

web/templates/ui-elements.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>

web/templates/ui-elements.dart 网页/模板/ 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 (dummy entry file) 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>

web/main.dart 网络/ main.dart

import 'package:polymer/polymer.dart';

main() {
  initPolymer();
}

@whenPolymerReady
void onReady() {
}

web/main.html (entry point) after pub build . pub build之后的web / main.html (入口点)。 Real mess after compiling. 编译后真正混乱。 So many js files some of them takes size even more than 300kb. 如此多的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>

You don't need initPolymer when you use @whenPolymerReady . 你不需要initPolymer当您使用@whenPolymerReady The entire main() method is redundant in your example. 整个main()方法在您的示例中是多余的。

Did you register your entry page properly in the Polymer transformer configuration in pubspec.yaml ? 您是否在pubspec.yaml的Polymer变压器配置中正确注册了进入页面?

Smoke needs a transformer but if you have the Polymer transformer configured properly the Smoke transformer is included. Smoke需要一个变压器,但是如果您正确配置了Polymer变压器,则包括Smoke变压器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM