From e4ad0030255cb5126a76112268400452ecc46d5c Mon Sep 17 00:00:00 2001 From: Georgi Angelov Date: Tue, 17 Sep 2024 12:19:20 +0300 Subject: [PATCH] chore: limit Terser threads --- src/index.cjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.cjs b/src/index.cjs index ad2068f..0c71235 100644 --- a/src/index.cjs +++ b/src/index.cjs @@ -3,6 +3,7 @@ const path = require('path'); const merge = require('lodash.merge'); const nodeExternals = require('webpack-node-externals'); const webpack = require('webpack'); +const TerserPlugin = require("terser-webpack-plugin") const DEFAULT_CHUNK_FILENAME = 'chunks/[name].[chunkhash].js'; const DEFAULT_ASSET_FILENAME = 'assets/[name].[hash][ext][query]'; @@ -58,6 +59,14 @@ class ScratchWebpackConfigBuilder { } : path.resolve(this._srcPath, 'index'), optimization: { minimize: isProduction, + minimizer: [ + new TerserPlugin({ + // Limiting Terser to use only 2 threads. At least for building scratch-gui + // this results in a performance gain (from ~60s to ~36s) on a MacBook with + // M1 Pro and 32GB of RAM and halving the memory usage (from ~11GB at peaks to ~6GB) + parallel: 2 + }) + ], ...( shouldSplitChunks ? { splitChunks: {