-export default {
- input: 'src/index.ts',
- output: {
- ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
- format: 'cjs',
- sourcemap: !!isDevelopmentBuild,
- ...(isDevelopmentBuild && { preserveModules: true }),
- ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
- ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
+export default defineConfig([
+ {
+ input: './src/index.ts',
+ strictDeprecations: true,
+ output: [
+ {
+ format: 'cjs',
+ ...(isDevelopmentBuild && {
+ dir: './lib',
+ preserveModules: true,
+ preserveModulesRoot: './src'
+ }),
+ ...(!isDevelopmentBuild && {
+ file: './lib/index.js',
+ plugins: [terser({ maxWorkers })]
+ }),
+ ...(sourcemap && {
+ sourcemap
+ })
+ },
+ {
+ format: 'esm',
+ ...(isDevelopmentBuild && {
+ dir: './lib',
+ entryFileNames: '[name].mjs',
+ chunkFileNames: '[name]-[hash].mjs',
+ preserveModules: true,
+ preserveModulesRoot: './src'
+ }),
+ ...(!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'
+ ],
+ plugins: [
+ typescript({
+ tsconfig: './tsconfig.build.json',
+ compilerOptions: {
+ sourceMap: sourcemap
+ }
+ }),
+ del({
+ targets: ['./lib/*']
+ }),
+ isAnalyzeBuild && analyze(),
+ isDocumentationBuild && command('pnpm typedoc')
+ ]