Merge branch 'master' of github.com:poolifier/poolifier
[poolifier.git] / rollup.config.mjs
index 23d260d05ee6af1dc374dbfb98007c851dc13479..e3af7e1d8af9657fe50be3750b7aa4acd8671a25 100644 (file)
@@ -24,7 +24,6 @@ const availableParallelism = () => {
 const isDevelopmentBuild = env.BUILD === 'development'
 const isAnalyzeBuild = env.ANALYZE
 const isDocumentationBuild = env.DOCUMENTATION
-const sourcemap = env.SOURCEMAP !== 'false'
 
 const maxWorkers = Math.floor(availableParallelism() / 2)
 
@@ -35,6 +34,7 @@ export default defineConfig([
     output: [
       {
         format: 'cjs',
+        sourcemap: true,
         ...(isDevelopmentBuild && {
           dir: './lib',
           preserveModules: true,
@@ -43,13 +43,11 @@ export default defineConfig([
         ...(!isDevelopmentBuild && {
           file: './lib/index.js',
           plugins: [terser({ maxWorkers })]
-        }),
-        ...(sourcemap && {
-          sourcemap
         })
       },
       {
         format: 'esm',
+        sourcemap: true,
         ...(isDevelopmentBuild && {
           dir: './lib',
           entryFileNames: '[name].mjs',
@@ -60,53 +58,35 @@ export default defineConfig([
         ...(!isDevelopmentBuild && {
           file: './lib/index.mjs',
           plugins: [terser({ maxWorkers })]
-        }),
-        ...(sourcemap && {
-          sourcemap
         })
       }
     ],
-    external: [
-      'node:async_hooks',
-      'node:cluster',
-      'node:crypto',
-      'node:events',
-      'node:fs',
-      'node:os',
-      'node:perf_hooks',
-      'node:worker_threads'
-    ],
+    external: [/^node:*/],
     plugins: [
       typescript({
         tsconfig: './tsconfig.build.json',
         compilerOptions: {
-          sourceMap: sourcemap
+          sourceMap: true
         }
       }),
       del({
         targets: ['./lib/*']
       }),
-      isAnalyzeBuild && analyze(),
-      isDocumentationBuild && command('pnpm typedoc')
+      Boolean(isAnalyzeBuild) && analyze(),
+      Boolean(isDocumentationBuild) && command('pnpm typedoc')
     ]
   },
   {
     input: './lib/dts/index.d.ts',
     output: [{ format: 'esm', file: './lib/index.d.ts' }],
-    external: [
-      'node:async_hooks',
-      'node:cluster',
-      'node:events',
-      'node:perf_hooks',
-      'node:worker_threads'
-    ],
+    external: [/^node:*/],
     plugins: [
       dts(),
       del({
         targets: ['./lib/dts'],
         hook: 'buildEnd'
       }),
-      isAnalyzeBuild && analyze()
+      Boolean(isAnalyzeBuild) && analyze()
     ]
   }
 ])