repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat: randomize startup delays
[e-mobility-charging-stations-simulator.git]
/
rollup.config.mjs
diff --git
a/rollup.config.mjs
b/rollup.config.mjs
index e78c1e9e26e145eaffa217fb2b0813520e9cf6c4..c28aaf0460dd35fa7100ffffcba00c60c3c5b978 100644
(file)
--- a/
rollup.config.mjs
+++ b/
rollup.config.mjs
@@
-1,24
+1,41
@@
/* eslint-disable n/no-unpublished-import */
/* 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 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 { defineConfig } from 'rollup';
import analyze from 'rollup-plugin-analyzer';
import analyze from 'rollup-plugin-analyzer';
-import copy from 'rollup-plugin-copy';
import del from 'rollup-plugin-delete';
import del from 'rollup-plugin-delete';
+const availableParallelism = () => {
+ // eslint-disable-next-line no-shadow
+ let availableParallelism = 1;
+ try {
+ availableParallelism = os.availableParallelism();
+ } catch {
+ const cpus = os.cpus();
+ if (Array.isArray(cpus) && cpus.length > 0) {
+ availableParallelism = cpus.length;
+ }
+ }
+ return availableParallelism;
+};
+
const isDevelopmentBuild = process.env.BUILD === 'development';
const isAnalyzeBuild = process.env.ANALYZE;
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'],
+export default
defineConfig(
{
+ input: ['
./src/start.ts', './
src/charging-station/ChargingStationWorker.ts'],
strictDeprecations: true,
output: [
{
strictDeprecations: true,
output: [
{
- dir: 'dist',
+ dir: '
./
dist',
format: 'esm',
format: 'esm',
- exports: 'auto',
- ...(isDevelopmentBuild && { sourcemap: true }),
- ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }),
+ sourcemap: sourceMap,
+ plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })],
},
],
external: [
},
],
external: [
@@
-28,17
+45,19
@@
export default {
'ajv-formats',
'basic-ftp',
'chalk',
'ajv-formats',
'basic-ftp',
'chalk',
+ 'date-fns',
+ 'deep-clone',
'http-status-codes',
'http-status-codes',
- 'just-clone',
'just-merge',
'mnemonist/lru-map-with-delete.js',
'just-merge',
'mnemonist/lru-map-with-delete.js',
- 'm
oment
',
+ 'm
nemonist/queue.js
',
'mongodb',
'node:async_hooks',
'node:crypto',
'node:events',
'node:fs',
'node:http',
'mongodb',
'node:async_hooks',
'node:crypto',
'node:events',
'node:fs',
'node:http',
+ 'node:http2',
'node:path',
'node:perf_hooks',
'node:stream',
'node:path',
'node:perf_hooks',
'node:stream',
@@
-55,21
+74,32
@@
export default {
plugins: [
json(),
typescript({
plugins: [
json(),
typescript({
- tsconfig: 'tsconfig.json',
+ tsconfig: './tsconfig.json',
+ compilerOptions: {
+ sourceMap,
+ },
}),
del({
targets: [
}),
del({
targets: [
- 'dist/*',
- '!dist/assets',
- 'dist/assets/*.json',
- 'dist/assets/json-schemas',
- 'dist/assets/station-templates',
- 'dist/assets/ui-protocol',
+ '
./
dist/*',
+ '!
./
dist/assets',
+ '
./
dist/assets/*.json',
+ '
./
dist/assets/json-schemas',
+ '
./
dist/assets/station-templates',
+ '
./
dist/assets/ui-protocol',
],
}),
copy({
],
}),
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(),
],
}),
isAnalyzeBuild && analyze(),
],
-};
+}
)
;