loro/crates/loro-wasm/rollup.config.mjs

40 lines
860 B
JavaScript
Raw Normal View History

import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
2024-11-16 11:18:29 +00:00
const createConfig = (format, tsTarget, outputDir) => ({
input: {
'index': 'index.ts',
},
output: {
dir: outputDir,
format: format,
sourcemap: true,
entryFileNames: '[name].js',
},
plugins: [
typescript({
tsconfig: 'tsconfig.json',
compilerOptions: {
target: tsTarget,
declaration: true,
outDir: outputDir,
},
2024-11-16 11:18:29 +00:00
exclude: ['tests/**/*', 'vite.config.*']
}),
nodeResolve()
],
external: [/loro_wasm/]
});
// Create different bundle configurations
export default [
// CommonJS for Node.js
createConfig('cjs', 'ES2020', 'nodejs'),
// ESM for Web
createConfig('es', 'ES2020', 'web'),
// ESM for bundler
createConfig('es', 'ES2020', 'bundler'),
];