-export default {
- input: 'src/index.ts',
- strictDeprecations: true,
- output: [
- {
- ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
- format: 'cjs',
- sourcemap: !!isDevelopmentBuild,
- ...(isDevelopmentBuild && {
- preserveModules: true,
- preserveModulesRoot: 'src'
+const maxWorkers = Math.floor(availableParallelism() / 2)
+
+export default defineConfig([
+ {
+ input: './src/index.ts',
+ strictDeprecations: true,
+ output: [
+ {
+ format: 'cjs',
+ ...(isDevelopmentBuild
+ ? {
+ dir: './lib',
+ entryFileNames: '[name].cjs',
+ chunkFileNames: '[name]-[hash].cjs',
+ preserveModules: true,
+ preserveModulesRoot: './src'
+ }
+ : {
+ file: './lib/index.cjs',
+ plugins: [terser({ maxWorkers })]
+ }),
+ ...(sourcemap && {
+ sourcemap
+ })
+ },
+ {
+ format: 'esm',
+ ...(isDevelopmentBuild
+ ? {
+ dir: './lib',
+ entryFileNames: '[name].mjs',
+ chunkFileNames: '[name]-[hash].mjs',
+ preserveModules: true,
+ preserveModulesRoot: './src'
+ }
+ : {
+ file: './lib/index.mjs',
+ plugins: [terser({ maxWorkers })]
+ }),
+ ...(sourcemap && {
+ sourcemap
+ })
+ }
+ ],
+ external: [/^node:*/],
+ plugins: [
+ typescript({
+ tsconfig: './tsconfig.build.json',
+ compilerOptions: {
+ sourceMap: sourcemap
+ }