import analyze from 'rollup-plugin-analyzer'
import command from 'rollup-plugin-command'
import del from 'rollup-plugin-delete'
+import { defineConfig } from 'rollup'
const availableParallelism = () => {
let availableParallelism = 1
const maxWorkers = Math.floor(availableParallelism() / 2)
-export default [
+export default defineConfig([
{
- input: 'src/index.ts',
+ input: './src/index.ts',
strictDeprecations: true,
output: [
{
format: 'cjs',
...(isDevelopmentBuild && {
- dir: 'lib',
+ dir: './lib',
sourcemap: true,
preserveModules: true,
- preserveModulesRoot: 'src'
+ preserveModulesRoot: './src'
}),
...(!isDevelopmentBuild && {
- file: 'lib/index.js',
+ file: './lib/index.js',
plugins: [terser({ maxWorkers })]
})
},
{
format: 'esm',
...(isDevelopmentBuild && {
- dir: 'lib',
+ dir: './lib',
sourcemap: true,
entryFileNames: '[name].mjs',
+ chunkFileNames: '[name]-[hash].mjs',
preserveModules: true,
- preserveModulesRoot: 'src'
+ preserveModulesRoot: './src'
}),
...(!isDevelopmentBuild && {
- file: 'lib/index.mjs',
+ file: './lib/index.mjs',
plugins: [terser({ maxWorkers })]
})
}
plugins: [
typescript({
tsconfig: isDevelopmentBuild
- ? 'tsconfig.development.json'
- : 'tsconfig.production.json'
+ ? './tsconfig.development.json'
+ : './tsconfig.production.json'
}),
del({
- targets: ['lib/*']
+ targets: ['./lib/*']
}),
isAnalyzeBuild && analyze(),
isDocumentationBuild && command('pnpm typedoc')
},
{
input: './lib/dts/index.d.ts',
- output: [{ format: 'esm', file: 'lib/index.d.ts' }],
+ output: [{ format: 'esm', file: './lib/index.d.ts' }],
external: [
'node:async_hooks',
'node:cluster',
plugins: [
dts(),
del({
- targets: ['lib/dts'],
+ targets: ['./lib/dts'],
hook: 'buildEnd'
}),
isAnalyzeBuild && analyze()
]
}
-]
+])