M
M
Maa-Kut2017-02-03 23:44:00
JavaScript
Maa-Kut, 2017-02-03 23:44:00

How to speed up gulp/rollup/babel?

Good day to all.
There is such a question. I have a JS project (using ES6) containing, in total, about 250 js files of various calibers (most within a few hundred lines). All this joy is collected by a bunch of gulp/rollup/babel like this:

var gulp = require("gulp");
var sync = require("gulp-sync")(gulp);
var babel = require("rollup-plugin-babel");
var rollup = require("rollup-stream");
var source = require("vinyl-source-stream");
var buffer = require("vinyl-buffer");
var sourcemaps = require("gulp-sourcemaps");

var cache = false;
gulp.task("js", function () {
  return rollup({
    entry: "src/main.js",
    sourceMap: true,
    plugins: [babel()],
    cache: cache
  })
  .on("bundle", bundle => { cache = bundle; })
  .pipe(source('bundle.js'))
  .pipe(buffer())
  .pipe(sourcemaps.init({loadMaps: true}))
  .pipe(sourcemaps.write('.'))
  .pipe(gulp.dest("./build"));
});

gulp.task("watch", function () {
  gulp.watch("src/**", ["js"]);
});

gulp.task("default", sync.sync(["js", "watch"]));

In this form, all this joy works out in about 25 seconds. Reassembly "on the fly" (watch'em) lasts 3-4s. Maybe I'm snickering, but it seems to me that all this is somehow slow. Tried to disable treeshake rollup (in fact, I need all the code anyway); no visible effect. Is there anything else I can tweak to make this thing move faster?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Melikhov, 2017-02-03
@amelihovv

I don’t know if there is such a feature in rollup, but in webpack it greatly speeds up the assembly of Hot Module Replacement.
And if you want to speed up gulp, then I advise Ilya Kantor's screencast on it. https://www.youtube.com/watch?v=uPk6lQoTThE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question