react-universally icon indicating copy to clipboard operation
react-universally copied to clipboard

Add webpack's new cache loader

Open ctrlplusb opened this issue 8 years ago • 7 comments

https://github.com/webpack-contrib/cache-loader

ctrlplusb avatar Apr 26 '17 12:04 ctrlplusb

never try it before, will it replace happy pack usage?

diondirza avatar Apr 26 '17 13:04 diondirza

Possibly. It's a new kid on the block. We'll have to do some testing.

ctrlplusb avatar Apr 26 '17 13:04 ctrlplusb

I dont think it will be a 1:1 replacement for HappyPack. Main reason is HappyPack allows bundling to happen on different threads. Would be curious to see if running them in tandem gives a benefit.

strues avatar Apr 26 '17 16:04 strues

Yeah, definitely not a 1:1 replacement, however if the benefits of happypack ontop of cache-loader are negligible I would vote in favour of removing happypack to reduce complexity.

ctrlplusb avatar May 03 '17 08:05 ctrlplusb

The problem with HappyPack is that even though the workload is distributed between threads, the work itself is not separate enough to get the benefits I'd like.

The main webpack script gets a thread, and each of the loaders (new HappyPack()) get a thread (as I understand it). But almost all the work lies with the babel-loader, which only gets a single thread. Imagine if we could split that into multiple threads.

But its still faster than normal, both with and without the HappyPack cache.

birkir avatar May 03 '17 16:05 birkir

@birkir if you change the HappyPack plugin to look like this

import os from 'os';
import { execSync } from 'child_process';
import appRootDir from 'app-root-dir';

import HappyPack from 'happypack';

export function happyPackPlugin({ name, loaders }) {
   const compilerThreadPool = HappyPack.ThreadPool({
    size: os.cpus().length,
  });
  return new HappyPack({
    id: name,
    verbose: false,
    threadPool: compilerThreadPool,
    loaders,
  });
}

It will delegate the most resource intensive plugins, like babel-loader to use more threads than say sass-loader

strues avatar May 03 '17 19:05 strues

Got it! Now seeing my CPU on full blast!

birkir avatar May 03 '17 19:05 birkir