Transpiling a Polymer Element

假如想象 提交于 2019-12-11 07:28:53

问题


I'm scaffolding Polymer 1.x Elements using $ polymer init. These elements are not Polymer applications. They are just elements.

All my elements are coded in ES6. I'd like to transpile my elements down to ES5.

Considering that $ polymer build does not support single Element projects, what solutions can I use to achieve the above?


回答1:


Transpiling Polymer to es5 is done in 3 steps:

  1. Vulcanize your element(s) by inlining the script and CSS:

    vulcanize element.html --inline-script --inline-css > element.v.html

  2. Pipe the output to Cripser. Crisper is a tool that extracts all inline and creates a standalone .js file.

    crisper -s element.v.html -h element.v.html -j element.js

  3. Run the standalone JS file through Babel:

    babel element.js -o element.js

Old Answer(wrong):You need to use vulcanize directly. for instance:

 vulcanize target.html > build.html


来源:https://stackoverflow.com/questions/44722220/transpiling-a-polymer-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!