/* eslint-disable n/no-unpublished-import */
+import * as os from 'node:os';
+
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
+import { copy } from '@web/rollup-plugin-copy';
import analyze from 'rollup-plugin-analyzer';
-import copy from 'rollup-plugin-copy';
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'],
{
dir: 'dist',
format: 'esm',
- exports: 'auto',
- ...(isDevelopmentBuild && { sourcemap: true }),
- ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }),
+ sourcemap: sourceMap,
+ plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })],
},
],
external: [
'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',
json(),
typescript({
tsconfig: 'tsconfig.json',
+ compilerOptions: {
+ sourceMap,
+ },
}),
del({
targets: [
],
}),
copy({
- targets: [{ src: 'src/assets', dest: 'dist/' }],
+ rootDir: 'src',
+ patterns: 'assets/**/*.json',
+ exclude: [
+ 'assets/config-template.json',
+ 'assets/*config[-_.]*.json',
+ 'assets/idtags-template.json',
+ 'assets/authorization-tags-template.json',
+ 'assets/ui-protocol/**/*',
+ ],
}),
isAnalyzeBuild && analyze(),
],