import { GojiTarget } from '@goji/core' ; import webpack from 'webpack' ; import os from 'os' ; export const getEnvForPreprocess = ( nodeEnv , target ) => ( { NODE_ENV : nodeEnv , TARGET : target , } ) ; const MOST_ECONOMICAL_WORKER_COUNT = 3 ; export const getThreadLoader = ( nodeEnv ) : Array < webpack . RuleSetRule > => { if ( process . env . CI === 'true' ) { return [ ] ; } const threadCount = os . cpus ( ) ?. length ?? 1 ; const workerCount = Math . max ( 1 , Math . min ( threadCount - 1 , MOST_ECONOMICAL_WORKER_COUNT ) ) ; const options = { workers : workerCount , poolTimeout : nodeEnv === 'production' ? 2000 : Infinity , } ; return [ { loader : require . resolve ( 'thread-loader' ) , options , } , ] ; } ;