简体   繁体   English

针对不同节点版本的发布/目标npm软件包

[英]Publish/Target npm package for different node versions

I have written a node module using ES7 features. 我已经使用ES7功能编写了一个节点模块。 I've also created a build script which transpiles to ES5. 我还创建了一个可移植到ES5的构建脚本。

Is there a way to publish the module, so that a node 8/9 user uses the original code and older node versions use the transpiled code? 有没有一种发布模块的方法,以便节点8/9用户使用原始代码,而较旧的节点版本使用已编译的代码?

The reason why I want this, is because I expect a better performance on the none transpiled code. 之所以要这样做,是因为我希望在未转码的代码上有更好的性能。

As far as I understand, the perfomance differnce between the transpiled code and ES7 code is negligible. 据我了解,转译后的代码与ES7代码之间的性能差异可以忽略不计。

So it suffices to just publish the transpiled code. 因此,只需发布​​已转换的代码即可。

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

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