- 4种存储引擎:Memory / IndexedDB / OPFS / Hybrid - 完整SQL支持:SELECT/INSERT/UPDATE/DELETE/JOIN/GROUP BY/HAVING/DISTINCT - Query Builder链式API + TypeScript泛型支持 - 聚合函数:COUNT/SUM/AVG/MIN/MAX - 事务、插件系统(14 hooks)、发布订阅、数据迁移、导入导出 - React/Vue框架集成 - 264个测试用例,93.46%覆盖率 - 零运行时依赖
104 lines
2.2 KiB
JavaScript
104 lines
2.2 KiB
JavaScript
import resolve from '@rollup/plugin-node-resolve';
|
|
import commonjs from '@rollup/plugin-commonjs';
|
|
import terser from '@rollup/plugin-terser';
|
|
import typescript from '@rollup/plugin-typescript';
|
|
import dts from 'rollup-plugin-dts';
|
|
import serve from 'rollup-plugin-serve';
|
|
import livereload from 'rollup-plugin-livereload';
|
|
|
|
const isDev = process.env.ROLLUP_WATCH;
|
|
const isProd = process.env.NODE_ENV === 'production';
|
|
|
|
const basePlugins = [
|
|
resolve(),
|
|
commonjs(),
|
|
typescript({
|
|
tsconfig: './tsconfig.json',
|
|
declaration: false,
|
|
}),
|
|
];
|
|
|
|
const devPlugins = isDev ? [
|
|
serve({
|
|
open: true,
|
|
contentBase: ['site', 'dist'],
|
|
port: 3001,
|
|
}),
|
|
livereload({
|
|
watch: ['src', 'site'],
|
|
}),
|
|
] : [];
|
|
|
|
export default [
|
|
// UMD development (always built)
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-sqlark.js',
|
|
format: 'umd',
|
|
name: 'MetonaSqlark',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: [...basePlugins, ...devPlugins],
|
|
},
|
|
// Only build all formats in production
|
|
...(isDev ? [] : [
|
|
// ES Module
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-sqlark.esm.js',
|
|
format: 'es',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// CommonJS
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-sqlark.cjs.js',
|
|
format: 'cjs',
|
|
exports: 'named',
|
|
sourcemap: true,
|
|
},
|
|
plugins: basePlugins,
|
|
},
|
|
// UMD minified
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-sqlark.min.js',
|
|
format: 'umd',
|
|
name: 'MetonaSqlark',
|
|
exports: 'named',
|
|
sourcemap: false,
|
|
},
|
|
plugins: [
|
|
...basePlugins,
|
|
terser({
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
pure_funcs: ['console.log', 'console.warn'],
|
|
passes: 2,
|
|
},
|
|
format: { comments: false },
|
|
mangle: { toplevel: true },
|
|
}),
|
|
],
|
|
},
|
|
// TypeScript declarations bundle
|
|
{
|
|
input: 'src/index.ts',
|
|
output: {
|
|
file: 'dist/metona-sqlark.d.ts',
|
|
format: 'es',
|
|
},
|
|
plugins: [dts()],
|
|
},
|
|
]),
|
|
];
|