从聚合物启动工具包1.1.0开始,我将工具包中的所有现有代码修改为ES6/ES6 2015,包括以下内容:gulpfile.js, app.js, routing.html, my-greeting.html, my-list.html, my-greeting-basic.html and my-listing-basic.html
。按照docs文件夹中es6 babel食谱的说明,我运行了gulp serve
来验证应用程序是否正确工作,但所有现有的测试都失败了。
chrome 48 ✖ Test Suite Initialization
Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
chrome 48 Tests failed: 2 failed tests
以上对于chrome 41
、firefox 44
和safari 9.0
也是如此。
看来wct运行未编译的代码,我找不到任何选项允许wct抢先编译任务,或者指向.tmp
或dist
文件夹进行测试。
这里有一个修改的例子..。
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<dom-module id="my-list">
<template>
<style>
:host {
display: block;
}
</style>
<ul>
<template is="dom-repeat" items="{{items}}">
<li><span class="paper-font-body1">{{item}}</span></li>
</template>
</ul>
</template>
<script>
(() => {
'use strict';
class MyList {
beforeRegister() {
let is = this.constructor.name
.replace(/\W+/g, '-')
.replace(/([a-z\d])([A-Z])/g, '$1-$2')
.toLowerCase();
this.is = is;
this.properties = {
items : {
type : Array,
notify : true,
}
};
}
ready() {
this.items = [
'Responsive Web App boilerplate',
'Iron Elements and Paper Elements',
'End-to-end Build Tooling (including Vulcanize)',
'Unit testing with Web Component Tester',
'Routing with Page.js',
'Offline support with the Platinum Service Worker Elements'
];
}
}
Polymer(MyList);
})();
</script>
</dom-module>
发布于 2015-10-12 15:40:22
在通过Babel添加ES2015支持文档中添加文档、描述测试ES6/ES6 2015代码的首选方法之前,“我的叉子聚合物起动器-工具包”有一个修改过的gulpfile.js
和wtc.conf.js
,允许ES6/ES6 2015元素、测试和代码正确测试。
基本上,我修改了wtc.conf.js
配置文件以指向dist
,而不是用于测试套件和bower_components
路径映射的app
。为了确保正确构建项目,wct
gulp任务(在gulpfile.js
中)被注入了与gulp serve
任务相同的依赖项。
免责声明-让我说我不认为是理想的方法,它只是一个临时的补丁解决方案,所以我可以继续使用测试和ES2015。
我个人喜欢WTC
目前不需要构建,使开发过程更加流畅和动态。也许,当它检测到ES2015时,它可以注入Babel浏览器的支持。
https://stackoverflow.com/questions/32957704
复制相似问题