X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=baaeda78fe4753b19b52de5620f07ace98e20512;hb=a675e34bb7d1711aace56f6ed8cdb4f91453e39d;hp=2e1e811a09393b99e20cb55de67f05daf394ddf5;hpb=5983297441ae1af1d5a6e9ecc38ba04f8777724b;p=e-mobility-charging-stations-simulator.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 2e1e811a..baaeda78 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,5 +1,5 @@ /* eslint-disable n/no-unpublished-import */ -import { cpus } from 'node:os'; +import * as os from 'node:os'; import json from '@rollup/plugin-json'; import terser from '@rollup/plugin-terser'; @@ -8,6 +8,20 @@ import { copy } from '@web/rollup-plugin-copy'; import analyze from 'rollup-plugin-analyzer'; import del from 'rollup-plugin-delete'; +const availableParallelism = () => { + // eslint-disable-next-line no-shadow + let availableParallelism = 1; + try { + availableParallelism = os.availableParallelism(); + } catch { + const numberOfCpus = os.cpus(); + if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) { + availableParallelism = numberOfCpus.length; + } + } + return availableParallelism; +}; + const isDevelopmentBuild = process.env.BUILD === 'development'; const isAnalyzeBuild = process.env.ANALYZE; @@ -19,7 +33,7 @@ export default { dir: 'dist', format: 'esm', sourcemap: !!isDevelopmentBuild, - plugins: [terser({ maxWorkers: cpus().length / 2 })], + plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })], }, ], external: [ @@ -29,11 +43,12 @@ export default { 'ajv-formats', 'basic-ftp', 'chalk', + 'date-fns', 'http-status-codes', 'just-clone', 'just-merge', - 'mnemonist', - 'moment', + 'mnemonist/lru-map-with-delete.js', + 'mnemonist/queue.js', 'mongodb', 'node:async_hooks', 'node:crypto',