refactor: cleanup task function(s) handling code
[poolifier.git] / rollup.config.mjs
index 28d0e3a98bf2def9fcf6b4102d1dec6299d988b5..a6d7eae8e9b583565924217c1d953b2c861d27a7 100644 (file)
@@ -1,16 +1,18 @@
 import * as os from 'node:os'
 import { env } from 'node:process'
 import * as os from 'node:os'
 import { env } from 'node:process'
-import { dts } from 'rollup-plugin-dts'
+
 import terser from '@rollup/plugin-terser'
 import typescript from '@rollup/plugin-typescript'
 import terser from '@rollup/plugin-terser'
 import typescript from '@rollup/plugin-typescript'
+import { defineConfig } from 'rollup'
 import analyze from 'rollup-plugin-analyzer'
 import command from 'rollup-plugin-command'
 import del from 'rollup-plugin-delete'
 import analyze from 'rollup-plugin-analyzer'
 import command from 'rollup-plugin-command'
 import del from 'rollup-plugin-delete'
-import { defineConfig } from 'rollup'
+import { dts } from 'rollup-plugin-dts'
 
 const availableParallelism = () => {
   let availableParallelism = 1
   try {
 
 const availableParallelism = () => {
   let availableParallelism = 1
   try {
+    // eslint-disable-next-line n/no-unsupported-features/node-builtins
     availableParallelism = os.availableParallelism()
   } catch {
     const cpus = os.cpus()
     availableParallelism = os.availableParallelism()
   } catch {
     const cpus = os.cpus()
@@ -41,15 +43,15 @@ export default defineConfig([
               entryFileNames: '[name].cjs',
               chunkFileNames: '[name]-[hash].cjs',
               preserveModules: true,
               entryFileNames: '[name].cjs',
               chunkFileNames: '[name]-[hash].cjs',
               preserveModules: true,
-              preserveModulesRoot: './src'
+              preserveModulesRoot: './src',
             }
           : {
               file: './lib/index.cjs',
             }
           : {
               file: './lib/index.cjs',
-              plugins: [terser({ maxWorkers })]
+              plugins: [terser({ maxWorkers })],
             }),
         ...(sourcemap && {
             }),
         ...(sourcemap && {
-          sourcemap
-        })
+          sourcemap,
+        }),
       },
       {
         format: 'esm',
       },
       {
         format: 'esm',
@@ -59,31 +61,31 @@ export default defineConfig([
               entryFileNames: '[name].mjs',
               chunkFileNames: '[name]-[hash].mjs',
               preserveModules: true,
               entryFileNames: '[name].mjs',
               chunkFileNames: '[name]-[hash].mjs',
               preserveModules: true,
-              preserveModulesRoot: './src'
+              preserveModulesRoot: './src',
             }
           : {
               file: './lib/index.mjs',
             }
           : {
               file: './lib/index.mjs',
-              plugins: [terser({ maxWorkers })]
+              plugins: [terser({ maxWorkers })],
             }),
         ...(sourcemap && {
             }),
         ...(sourcemap && {
-          sourcemap
-        })
-      }
+          sourcemap,
+        }),
+      },
     ],
     external: [/^node:*/],
     plugins: [
       typescript({
         tsconfig: './tsconfig.build.json',
         compilerOptions: {
     ],
     external: [/^node:*/],
     plugins: [
       typescript({
         tsconfig: './tsconfig.build.json',
         compilerOptions: {
-          sourceMap: sourcemap
-        }
+          sourceMap: sourcemap,
+        },
       }),
       del({
       }),
       del({
-        targets: ['./lib/*']
+        targets: ['./lib/*'],
       }),
       isAnalyzeBuild && analyze(),
       }),
       isAnalyzeBuild && analyze(),
-      isDocumentationBuild && command('pnpm typedoc')
-    ]
+      isDocumentationBuild && command('pnpm typedoc'),
+    ],
   },
   {
     input: './lib/dts/index.d.ts',
   },
   {
     input: './lib/dts/index.d.ts',
@@ -94,9 +96,9 @@ export default defineConfig([
       dts(),
       del({
         targets: ['./lib/dts'],
       dts(),
       del({
         targets: ['./lib/dts'],
-        hook: 'buildEnd'
+        hook: 'buildEnd',
       }),
       }),
-      isAnalyzeBuild && analyze()
-    ]
-  }
+      isAnalyzeBuild && analyze(),
+    ],
+  },
 ])
 ])