Gulp babel es2015转换非常缓慢 [英] Gulp babel es2015 transform very slow

查看:133
本文介绍了Gulp babel es2015转换非常缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用gulp在我的JavaScript上运行babel-preset-es2015,但即使在一行代码中也需要永久使用。我最初尝试用我的脚本包大约700位,然后用一行虚拟脚本。第一个案件大约需要9s - 1行我需要8.38s。

这是我确切的设置:



package.json:

  {
devDependencies:{
gulp:^ 3.9 .0,
gulp-babel:^ 6.1.1,
babel:^ 6.3.26,
babel-preset-es2015:^ 6.3.13

babel:{
预设:[es2015]
}
}

gulpfile.js:

  gulp .task('js',function(){
return gulp.src('dummyscript.js')
.pipe(concat('site.bundle.js'))
.pipe (babel())
.pipe(gulp.dest(paths.dest.scripts));

});

dummy.js:

  console.log('dummy script'); 

我正在运行node v4.2.4和npm v2.14.12。



其他操作如吞噬反应和gulp-uglify都需要约180ms的组合。



发生了什么事?

解决方案

Babel 6有很多高度嵌套的子依赖关系。如果你有一个非平坦的依赖树,这可能会很慢。在你的情况下,你使用的是npm 2,你需要 npm dedupe 或者安装 npm @ 3 然后重新安装这样你的依赖关系就变平了。


I am trying to run the babel-preset-es2015 on my JavaScript using gulp, but it takes forever even on one line of code. I originally tried with my script bundle that is about 700 loc, and then with a dummy script that is 1 line. The first case takes about 9s - with 1 line i takes 8.38s.

This is my exact setup:

package.json:

{
    "devDependencies": {
        "gulp": "^3.9.0",
        "gulp-babel": "^6.1.1",
        "babel": "^6.3.26",
        "babel-preset-es2015": "^6.3.13"
    }, 
   "babel": {
       "presets": [ "es2015" ]
    }
}

gulpfile.js:

gulp.task('js', function () {
    return gulp.src('dummyscript.js')
      .pipe(concat('site.bundle.js'))   
      .pipe(babel())  
      .pipe(gulp.dest(paths.dest.scripts));

});

dummy.js:

console.log('dummy script');

I'm running node v4.2.4 and npm v2.14.12.

Other operations like gulp-react and gulp-uglify all take about 180ms combined.

What is going on?

解决方案

Babel 6 has many highly-nested subdependencies. This can be quite slow if you have a non-flattened dependency tree. In your case, you are using npm 2, you will need to either npm dedupe or install npm@3 and reinstall so that your dependencies are flattened.

这篇关于Gulp babel es2015转换非常缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆