X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=2c8d35564c05b9925bfaf91e3c39f4aa582abc7d;hb=d632062f209c41719300e32cf0e4c06e151ecc4b;hp=82b5b79aa27de94041111165e4d95eb415334288;hpb=31b5738e12a713a409827124e88d8bc03bbed519;p=e-mobility-charging-stations-simulator.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 82b5b79a..2c8d3556 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,5 +1,5 @@ /* eslint-disable n/no-unpublished-import */ -import os from 'os'; +import * as os from 'node:os'; import json from '@rollup/plugin-json'; import terser from '@rollup/plugin-terser'; @@ -8,8 +8,23 @@ 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; +const sourceMap = !!isDevelopmentBuild; export default { input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], @@ -18,8 +33,8 @@ export default { { dir: 'dist', format: 'esm', - sourcemap: !!isDevelopmentBuild, - plugins: [terser({ maxWorkers: os.cpus().length / 2 })], + sourcemap: sourceMap, + plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })], }, ], external: [ @@ -29,17 +44,19 @@ export default { 'ajv-formats', 'basic-ftp', 'chalk', + 'date-fns', + 'deep-clone', 'http-status-codes', - 'just-clone', 'just-merge', 'mnemonist/lru-map-with-delete.js', - 'moment', + 'mnemonist/queue.js', 'mongodb', 'node:async_hooks', 'node:crypto', 'node:events', 'node:fs', 'node:http', + 'node:http2', 'node:path', 'node:perf_hooks', 'node:stream', @@ -57,6 +74,9 @@ export default { json(), typescript({ tsconfig: 'tsconfig.json', + compilerOptions: { + sourceMap, + }, }), del({ targets: [ @@ -73,8 +93,9 @@ export default { patterns: 'assets/**/*.json', exclude: [ 'assets/config-template.json', - 'assets/*config[-_]*.json', + 'assets/*config[-_.]*.json', 'assets/idtags-template.json', + 'assets/authorization-tags-template.json', 'assets/ui-protocol/**/*', ], }),