mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
39 lines
842 B
JavaScript
39 lines
842 B
JavaScript
|
import typescript from '@rollup/plugin-typescript';
|
||
|
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
||
|
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,
|
||
|
},
|
||
|
exclude: ['tests/**/*']
|
||
|
}),
|
||
|
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'),
|
||
|
];
|