Watchify w/gulp和babel逐渐变慢
每次watchify检测到变化,捆绑时间就会变慢。我的吞咽任务一定出了什么问题。有人有什么想法吗Watchify w/gulp和babel逐渐变慢,gulp,browserify,babeljs,watchify,Gulp,Browserify,Babeljs,Watchify,每次watchify检测到变化,捆绑时间就会变慢。我的吞咽任务一定出了什么问题。有人有什么想法吗 gulp.task('bundle', function() { var bundle = browserify({ debug: true, extensions: ['.js', '.jsx'], entries: path.resolve(paths.root, files.entry) });
gulp.task('bundle', function() {
var bundle = browserify({
debug: true,
extensions: ['.js', '.jsx'],
entries: path.resolve(paths.root, files.entry)
});
executeBundle(bundle);
});
gulp.task('bundle-watch', function() {
var bundle = browserify({
debug: true,
extensions: ['.js', '.jsx'],
entries: path.resolve(paths.root, files.entry)
});
bundle = watchify(bundle);
bundle.on('update', function(){
executeBundle(bundle);
});
executeBundle(bundle);
});
function executeBundle(bundle) {
var start = Date.now();
bundle
.transform(babelify.configure({
ignore: /(bower_components)|(node_modules)/
}))
.bundle()
.on("error", function (err) { console.log("Error : " + err.message); })
.pipe(source(files.bundle))
.pipe(gulp.dest(paths.root))
.pipe($.notify(function() {
console.log('bundle finished in ' + (Date.now() - start) + 'ms');
}))
}
我遇到了同样的问题,并通过将环境变量DEBUG设置为babel来研究它。e、 g:
$ DEBUG=babel gulp
在检查调试输出后,我注意到babelify多次运行转换
罪魁祸首是每次执行包时,我实际上都添加了转换。你似乎也有同样的问题
移动
.transform(babelify.configure({
忽略:/(鲍尔_组件)|(节点_模块)/
}))
从内部executeBundle
进入任务。新的bundle watch
可以这样编写:
gulp.task('bundle-watch',function(){
var bundle=browserify({
是的,
扩展:['.js','.jsx'],
条目:path.resolve(path.root,files.entry)
});
bundle=watchify(bundle);
bundle.transform(babelify.configure({
忽略:/(鲍尔_组件)|(节点_模块)/
}))
bundle.on('update',function(){
可执行绑定(bundle);
});
可执行绑定(bundle);
});
我想我已经修复了它,将这两个选项添加到包中似乎可以修复它:cache:{},packageCache:{}这些选项是使用watchify所必需的。我已经配置了这些选项,但仍然看到类似的问题。每次运行时,重建时间都会增加,即使只是触摸文件(没有实际更改),直到最终文件崩溃,并出现RangeError:Maximum call stack size Oversed
@Emily将您的问题作为问题发布。希望我能对此进行更多的投票。我要花很长时间才能弄明白。真是太棒了!将转换从称为“每次watchify更新”的方法中移出,修复了我在构建过程中遇到的一个类似问题,该问题随着时间的推移逐渐变得越来越长。