tachybase_todo/packages/core/cli/rollup.config.js

75 lines
1.4 KiB
JavaScript
Raw Normal View History

import { builtinModules, createRequire } from 'node:module';
import esbuild from 'rollup-plugin-esbuild';
import process from 'node:process';
import dts from 'rollup-plugin-dts';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { defineConfig } from 'rollup';
const require = createRequire(import.meta.url);
const pkg = require('./package.json');
const entries = {
cli: 'src/cli.ts',
};
const external = [
...builtinModules,
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
'pathe',
'birpc',
'vite',
'node:url',
'node:events',
'node:vm',
];
const plugins = [
resolve({
preferBuiltins: true,
}),
json(),
commonjs(),
esbuild({
target: 'esnext',
}),
];
const configs = defineConfig([
{
input: entries,
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].mjs',
chunkFileNames: 'chunk-[name].mjs',
},
external,
plugins,
onwarn,
},
]);
if (!process.env.BUILD_NO_DTS) {
configs.push({
input: entries,
output: {
dir: 'dist',
entryFileNames: '[name].d.ts',
format: 'esm',
},
external,
plugins: [dts({ respectExternal: true })],
onwarn,
});
}
export default configs;
function onwarn(message) {
if (['EMPTY_BUNDLE', 'CIRCULAR_DEPENDENCY'].includes(message.code)) return;
console.error(message);
}