Merge branch 'master' into interleaved-weighted-round-robin-worker-choice-strategy
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 May 2023 11:43:29 +0000 (13:43 +0200)
committerGitHub <noreply@github.com>
Sun, 28 May 2023 11:43:29 +0000 (13:43 +0200)
rollup.config.mjs

index 02fc54c00e9f514e30134078d69b56a41a971c29..0d5964e544f2ff89ed258e88e9500301ce820a66 100644 (file)
@@ -1,3 +1,4 @@
+import os from 'os'
 import terser from '@rollup/plugin-terser'
 import typescript from '@rollup/plugin-typescript'
 import analyze from 'rollup-plugin-analyzer'
@@ -8,30 +9,38 @@ const isDevelopmentBuild = process.env.BUILD === 'development'
 const isAnalyzeBuild = process.env.ANALYZE
 const isDocumentationBuild = process.env.DOCUMENTATION
 
+const maxWorkers = os.cpus().length / 2
+
 export default {
   input: 'src/index.ts',
   strictDeprecations: true,
   output: [
     {
-      ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
       format: 'cjs',
       sourcemap: !!isDevelopmentBuild,
       ...(isDevelopmentBuild && {
+        dir: 'lib',
         preserveModules: true,
         preserveModulesRoot: 'src'
       }),
-      ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
+      ...(!isDevelopmentBuild && {
+        file: 'lib/index.js',
+        plugins: [terser({ maxWorkers })]
+      })
     },
     {
-      ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.mjs' }),
       format: 'esm',
       sourcemap: !!isDevelopmentBuild,
       ...(isDevelopmentBuild && {
+        dir: 'lib',
         entryFileNames: '[name].mjs',
         preserveModules: true,
         preserveModulesRoot: 'src'
       }),
-      ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
+      ...(!isDevelopmentBuild && {
+        file: 'lib/index.mjs',
+        plugins: [terser({ maxWorkers })]
+      })
     }
   ],
   external: [