Skip to content

Commit 8975fc2

Browse files
committed
Improves build parallelism
1 parent f8b2863 commit 8975fc2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

webpack.config.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import fs from 'fs';
1616
import HtmlPlugin from 'html-webpack-plugin';
1717
import ImageMinimizerPlugin from 'image-minimizer-webpack-plugin';
1818
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
19+
import { createRequire } from 'module';
20+
import { availableParallelism } from 'os';
1921
import path from 'path';
2022
import { validate } from 'schema-utils';
2123
import TerserPlugin from 'terser-webpack-plugin';
24+
import { fileURLToPath } from 'url';
2225
import webpack from 'webpack';
2326
import WebpackRequireFromPlugin from 'webpack-require-from';
24-
import { fileURLToPath } from 'url';
25-
import { createRequire } from 'module';
2627

2728
const __filename = fileURLToPath(import.meta.url);
2829
const __dirname = path.dirname(__filename);
@@ -31,6 +32,12 @@ const { DefinePlugin, optimize, WebpackError } = webpack;
3132

3233
const require = createRequire(import.meta.url);
3334

35+
const cores = Math.max(Math.floor(availableParallelism() / 6) - 1, 1);
36+
const eslintWorker = {
37+
max: cores,
38+
filesPerWorker: 100,
39+
};
40+
3441
/**
3542
* @param {{ analyzeBundle?: boolean; analyzeDeps?: boolean; esbuild?: boolean; skipLint?: boolean } | undefined } env
3643
* @param {{ mode: 'production' | 'development' | 'none' | undefined }} argv
@@ -84,7 +91,7 @@ function getExtensionConfig(target, mode, env) {
8491
plugins.push(
8592
new ESLintLitePlugin({
8693
files: path.join(__dirname, 'src', '**', '*.ts'),
87-
worker: true,
94+
worker: eslintWorker,
8895
eslintOptions: {
8996
cache: true,
9097
cacheLocation: path.join(__dirname, '.eslintcache/', target === 'webworker' ? 'browser/' : ''),
@@ -352,7 +359,7 @@ function getWebviewsConfig(mode, env) {
352359
plugins.push(
353360
new ESLintLitePlugin({
354361
files: path.join(basePath, '**', '*.ts?(x)'),
355-
worker: true,
362+
worker: eslintWorker,
356363
eslintOptions: {
357364
cache: true,
358365
cacheLocation: path.join(__dirname, '.eslintcache', 'webviews/'),

0 commit comments

Comments
 (0)