X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=1034ffc812825d1adcc7005ac13ce24f48b8f02d;hb=a37fc6dc8267e22b2b2d35773525980b81f014e8;hp=3ab0886e357ae04aebb05d6e15065cfbdd7414b6;hpb=e3018bc4b27b43106073e4c4cda031cc37715027;p=e-mobility-charging-stations-simulator.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 3ab0886e..1034ffc8 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,78 +1,88 @@ +/* eslint-disable n/no-unpublished-import */ +import { cpus } 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'; -import istanbul from 'rollup-plugin-istanbul'; -import { terser } from 'rollup-plugin-terser'; -import ts from 'rollup-plugin-ts'; const isDevelopmentBuild = process.env.BUILD === 'development'; +const isAnalyzeBuild = process.env.ANALYZE; export default { - input: ['src/start.ts', 'src/ui/httpd/start.ts', 'src/charging-station/ChargingStationWorker.ts'], + input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], + strictDeprecations: true, output: [ { dir: 'dist', - format: 'es', - exports: 'auto', - sourcemap: true, - preserveModules: true, - preserveModulesRoot: 'src', - entryFileNames: '[name].mjs', - ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }), - }, - { - dir: 'dist', - format: 'cjs', - exports: 'auto', - sourcemap: true, - preserveModules: true, - preserveModulesRoot: 'src', - entryFileNames: '[name].cjs', - ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }), + format: 'esm', + sourcemap: !!isDevelopmentBuild, + plugins: [terser({ maxWorkers: cpus().length / 2 })], }, ], external: [ '@mikro-orm/core', '@mikro-orm/reflection', 'ajv', - 'ajv-draft-04', 'ajv-formats', 'basic-ftp', 'chalk', - 'crypto', - 'express', - 'fs', - 'mnemonist/lru-map-with-delete', + 'http-status-codes', + 'just-clone', + 'just-merge', + 'mnemonist/lru-map-with-delete.js', + 'mnemonist/queue.js', 'moment', 'mongodb', - 'path', - 'perf_hooks', + 'node:async_hooks', + 'node:crypto', + 'node:events', + 'node:fs', + 'node:http', + 'node:path', + 'node:perf_hooks', + 'node:stream', + 'node:url', + 'node:util', + 'node:worker_threads', 'poolifier', - 'proper-lockfile', - 'reflect-metadata', 'tar', - 'url', - 'uuid', 'winston', 'winston-daily-rotate-file', 'winston/lib/winston/transports/index.js', - 'worker_threads', 'ws', ], plugins: [ json(), - ts({ + typescript({ tsconfig: 'tsconfig.json', - browserslist: false, + compilerOptions: { + sourceMap: !!isDevelopmentBuild, + }, }), - isDevelopmentBuild && istanbul(), del({ - targets: ['dist/*', '!dist/assets', 'dist/assets/*.json', 'dist/assets/station-templates'], + targets: [ + 'dist/*', + '!dist/assets', + 'dist/assets/*.json', + 'dist/assets/json-schemas', + 'dist/assets/station-templates', + 'dist/assets/ui-protocol', + ], }), 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/**/*', + ], }), - isDevelopmentBuild && analyze(), + isAnalyzeBuild && analyze(), ], };