/* 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';
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;
dir: 'dist',
format: 'esm',
sourcemap: !!isDevelopmentBuild,
- plugins: [terser({ maxWorkers: cpus().length / 2 })],
+ plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })],
},
],
external: [
'ajv-formats',
'basic-ftp',
'chalk',
+ 'date-fns',
'http-status-codes',
'just-clone',
'just-merge',
'mnemonist/lru-map-with-delete.js',
- 'moment',
+ 'mnemonist/queue.js',
'mongodb',
'node:async_hooks',
'node:crypto',
json(),
typescript({
tsconfig: 'tsconfig.json',
+ compilerOptions: {
+ sourceMap: !!isDevelopmentBuild,
+ },
}),
del({
targets: [
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/**/*',