npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

faster-js-for-node

v1.0.0

Published

This is a tool that is used to optimize which babel plugins should be used to transform es6/7/next features according to the runtime node enviroment and the babel config

Downloads

8

Readme

Faster JS For Node

A tool is used to optimize which babel plugins should be used to transform es6/7/next features according to the runtime node enviroment and the babel config.

node 有很多版本,4.0.0 以后的版本都开始支持 es2015 的 features。利用 babel 可以将我们的 esnext 代码做适当转换,让其可以运行在 node 上。node 6.5.0 已经支持了 99% 的 es2015 的 features。那么是不是这 99% 的 features 我们就可以不用经过转换直接跑在 node 上了呢?

答案是肯定的,但是我们忽略了一个问题,就是这些代码运行速度如何呢?是不是 esnext 在 node 上跑的速度就比 es5 快呢?目前来看,答案是否定的。这里参考了 alloyteam 的一篇名为 “nodejs support es6 features”(链接见文尾)的文章,其中性能一节就提到了这个问题。当时眼前一亮,感觉这是一个能做出点成果的方向,决定就这个问题做的更深入点。于是就有了这个项目,其目标就是针对不同版本的 node 环境,检测其支持的 esnext 的 features,同时测试这些 features 的运行速度,与 babel 转换的代码的运行速度对比,根据运行速度快慢的对比,给出推荐的 babel plugin 配置选项。

完成功能

  1. 目前只支持 node 6.5 及以上版本

环境要求

babel: 6.x node: >= 6.5.x

用法说明

var fasterJS = require('faster-js-for-node');

var res = fasterJS({
  babelrc: false,
  presets: [
    'react',
    'es2015',
    'stage-0'
  ],
  plugins: [
    'transform-runtime',
    'transform-object-rest-spread',
    'transform-decorators-legacy'
  ]
});

res.then(ret => {
  console.log('recommendedPluginArr', ret.recommendedPluginArr);
  console.log('recommenedRemovePluginArr', ret.recommenedRemovePluginArr);
});

参考资料:

  1. babel 开发必看
  2. nodejs support es6 features
  3. babel 首页
  4. babel try it out
  5. ES6 features
  6. ES6-benchmark
  7. node green
  8. es5/6/7 compat-table