我正在尝试使用 gulp 在我的 JavaScript 上运行 babel-preset-es2015,但即使在一行代码上也需要很长时间.我最初尝试使用大约 700 loc 的脚本包,然后使用 1 行的虚拟脚本.第一种情况大约需要 9s - 1 行 i 需要 8.38s.
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.
这是我的确切设置:
package.json:
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:
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.
I'm running node v4.2.4 and npm v2.14.12.
gulp-react 和 gulp-uglify 等其他操作加起来大约需要 180 毫秒.
Other operations like gulp-react and gulp-uglify all take about 180ms combined.
发生了什么事?
Babel 6 有很多高度嵌套的子依赖.如果你有一个非扁平的依赖树,这可能会很慢.在您的情况下,您使用的是 npm 2,您将需要 npm dedupe 或安装 npm@3 并重新安装,以便您的依赖项被扁平化.
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 转换很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
由于 MIME 类型而未加载样式表Stylesheet not loaded because of MIME-type(由于 MIME 类型而未加载样式表)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)