最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Gulp babel es2015 transform very slow - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question edited Jan 21, 2016 at 14:27 severin asked Jan 21, 2016 at 13:38 severinseverin 5,5039 gold badges36 silver badges51 bronze badges 2
  • 1 You should ensure your dependencies are deduped with npm depupe and consider upgrading to npm@3. Babel can be quite slow if not deduped well. – loganfsmyth Commented Jan 21, 2016 at 17:47
  • npm3 did the trick, thanks! Down to 600ms with my original script, guess I can live with that. If you wanna make that an answer I'll accept it :) – severin Commented Jan 22, 2016 at 9:43
Add a comment  | 

1 Answer 1

Reset to default 21

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.

发布评论

评论列表(0)

  1. 暂无评论