lasso-js / lasso

Advanced JavaScript module bundler, asset pipeline and optimizer
581 stars 75 forks source link

Prebuilding takes up to 3 min for a regular sized project. #295

Open StarpTech opened 5 years ago

StarpTech commented 5 years ago

Hi, I'm using markojs and lasso. It works great together but building a marko website with ~13 pages and ~25 components takes up to 3 minutes on a good machine AMD Ryzen 5 2600X (12) @ 3.600G, SSD.

'use strict';

const { run } = require('@marko/prebuild');
const globby = require('globby');
const lassoConfig = require('./src/lasso-config');

async function prebuild() {
  const paths = await globby(['src/pages/*/*.marko']);
  await run({
    config: lassoConfig, // Either a lasso config object, or a path to one.
    flags: [], // Lasso flags to use when building the pages.
    pages: paths
  });
  // All templates have their prebuild.json files written to disk.
  console.log('Prebuild completed!');
}

prebuild().catch(err => {
  throw err;
});

Are you aware of that? How can we improve it?

DylanPiercey commented 5 years ago

@StarpTech I'm curious what the build time is when you disable the lasso-babel-transform if that is possible in your setup. If not then perhaps only enabling the bare minimum transforms.

I have a feeling that babel might be the bottleneck here and if so a solution may be better caching (or excluding node_modules if that works for you). The [webpack babel loader](babel-loader webpack) comes which caching, so maybe we should do something similar.

StarpTech commented 5 years ago

Hi @DylanPiercey thank your for the tips. I tried several things like reduce the babel plugins, exclude node_modules, disable minifying, removing autoprefixer it takes always 48 seconds on my machine or around 2min on a small EC2 instance. Based on the setup this is huge.