build(deps-dev): apply updates
[poolifier.git] / rollup.config.mjs
index 8f1f26562a4817d75a018129b3a09f76fd9129ab..b7abc9c5430f6212c6b5e7e79aa2f351285086d2 100644 (file)
@@ -24,6 +24,7 @@ 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)
 
@@ -36,21 +37,21 @@ export default defineConfig([
         format: 'cjs',
         ...(isDevelopmentBuild && {
           dir: './lib',
-          sourcemap: true,
           preserveModules: true,
           preserveModulesRoot: './src'
         }),
         ...(!isDevelopmentBuild && {
           file: './lib/index.js',
-          sourcemap: true,
           plugins: [terser({ maxWorkers })]
+        }),
+        ...(sourcemap && {
+          sourcemap
         })
       },
       {
         format: 'esm',
         ...(isDevelopmentBuild && {
           dir: './lib',
-          sourcemap: true,
           entryFileNames: '[name].mjs',
           chunkFileNames: '[name]-[hash].mjs',
           preserveModules: true,
@@ -58,8 +59,10 @@ export default defineConfig([
         }),
         ...(!isDevelopmentBuild && {
           file: './lib/index.mjs',
-          sourcemap: true,
           plugins: [terser({ maxWorkers })]
+        }),
+        ...(sourcemap && {
+          sourcemap
         })
       }
     ],
@@ -75,13 +78,16 @@ export default defineConfig([
     ],
     plugins: [
       typescript({
-        tsconfig: './tsconfig.build.json'
+        tsconfig: './tsconfig.build.json',
+        compilerOptions: {
+          sourceMap: sourcemap
+        }
       }),
       del({
         targets: ['./lib/*']
       }),
-      isAnalyzeBuild && analyze(),
-      isDocumentationBuild && command('pnpm typedoc')
+      Boolean(isAnalyzeBuild) && analyze(),
+      Boolean(isDocumentationBuild) && command('pnpm typedoc')
     ]
   },
   {
@@ -100,7 +106,7 @@ export default defineConfig([
         targets: ['./lib/dts'],
         hook: 'buildEnd'
       }),
-      isAnalyzeBuild && analyze()
+      Boolean(isAnalyzeBuild) && analyze()
     ]
   }
 ])