X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=26739f65d88ca4d12f75c24425ac19ef3dedcbda;hb=969cec5862c49b555353627fb4ce098f032051a0;hp=8f1f26562a4817d75a018129b3a09f76fd9129ab;hpb=4a6421b5261d2ebc33281682654361c5c4b2d069;p=poolifier.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 8f1f2656..26739f65 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -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,23 @@ export default defineConfig([ format: 'cjs', ...(isDevelopmentBuild && { dir: './lib', - sourcemap: true, + entryFileNames: '[name].cjs', + chunkFileNames: '[name]-[hash].cjs', preserveModules: true, preserveModulesRoot: './src' }), ...(!isDevelopmentBuild && { - file: './lib/index.js', - sourcemap: true, + file: './lib/index.cjs', plugins: [terser({ maxWorkers })] + }), + ...(sourcemap && { + sourcemap }) }, { format: 'esm', ...(isDevelopmentBuild && { dir: './lib', - sourcemap: true, entryFileNames: '[name].mjs', chunkFileNames: '[name]-[hash].mjs', preserveModules: true, @@ -58,49 +61,39 @@ export default defineConfig([ }), ...(!isDevelopmentBuild && { file: './lib/index.mjs', - sourcemap: true, 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' + tsconfig: './tsconfig.build.json', + compilerOptions: { + sourceMap: sourcemap + } }), 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() ] } ])