简体   繁体   English

如何在网络扩展中使用ECMAScript 6?

[英]How to use ECMAScript 6 in webextensions?

I am trying to use ECMAScript 6 in my webextension in Chrome 51 (in my background.js code) but I get an error on the first import: "Unexpected token import". 我试图在Chrome 51的webextension中使用ECMAScript 6(在我的background.js代码中),但是在第一次导入时出现错误:“意外的令牌导入”。 I enabled experimental javascript features in Chrome. 我在Chrome中启用了实验性JavaScript功能。 Is there any information available anywhere about using ECMAScript6 in webextensions? 是否有任何有关在Webextensions中使用ECMAScript6的信息?

Firefox supports most parts of ES6 , but not modules . Firefox支持ES6的大多数部分 ,但不支持模块 It's being worked on under bug 568953 . 正在根据错误568953进行处理

Native support for ES6 modules is quite a thing. 对ES6模块的本地支持是一件很重要的事情。 A common way to go is to have a build that bundles modules. 常见的做法是拥有将模块捆绑在一起的构建。 rollup is commonly used for that. 汇总通常用于此目的。

I just created a skeleton for webExt add-ons that does this. 我刚刚为webExt附加组件创建了一个框架来完成此任务。

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

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