简体   繁体   English

jspm不会将代码从ES6转换为ES5

[英]jspm does not transpile code from ES6 to ES5

Running jspm bundle-sfx some/input some/output.js does not transpile my code from ES6 to ES5. 运行jspm bundle-sfx some/input some/output.js不会将我的代码从ES6转发到ES5。 This makes the output file unusable. 这使输出文件不可用。

Example contents of input file: 输入文件的示例内容:

[1,2,3,4].map((i)=>i*i);

As explained by jspm author here : 正如jspm作者在这里解释的那样:

ES6 transpilation only happens for ES6 modules, not ES6 files written in CommonJS. ES6转换只发生在ES6模块上,而不是用CommonJS编写的ES6文件。

It means that transpilation happens only for files using module syntax ( import , export ). 这意味着只有使用模块语法( importexport )的文件才会发生转换。 It can be forced though by adding "format es6"; 可以通过添加"format es6";强制它"format es6"; at the top of the source file as so: 在源文件的顶部如下:

"format es6";
[1,2,3,4].map((i)=>i*i);

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

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