独立核验(12 条宣称逐条对源码验证)发现 5 处**硬伤**与 2 处**数字过期**, 本提交按"能改代码就让宣称成立、改不动就如实描述"的原则全部收口。 让实现符合文档(2 处): 1. **插件 priority 此前不生效** — `register()` 虽按 priority 插入数组,但 `install()` 在 register 内**立即**执行,因此 install 与钩子顺序 = config 数组 顺序(实测 priority low=1/high=100/mid=50 时钩子按 low→high→mid 触发, 只有 `getPlugins()` 是 high,mid,low)。而 README/CONTRIBUTING/constants 一直宣称"越大越先执行"。 现在 Core 注册前按 priority **稳定降序**排序(同优先级保持数组顺序), install 与钩子都按优先级执行 → 宣称成立。新增 `tests/v080-plugin-priority.test.ts` 锁定 install 顺序、钩子顺序、稳定性、缺省值。 2. **连接池静态方法不在类型系统里** — `MetonaSqlark.connect/disconnect/ disconnectAll/getActiveConnections` 由 connection-manager 用 `as unknown as Record<string, unknown>` 注入,README 的连接池表格在 TypeScript 下全部 TS2339。现在在类上声明为可选静态成员,注入处去掉断言。 如实描述(3 处): 3. **MVCC 快照隔离**(README 三处 + 实现对照)— `snapshotLsn` / `prevVersion` 只写不读,事务读走 `txnSnapshot`+LSM,commit 即清理版本链,并发 `beginTransaction` 抛 `TX_ACTIVE`。改为"快照回滚(事务串行,非 MVCC 隔离)", 并在 README 架构图与维护语句表里同步措辞。 4. **"存储引擎(5 种)"** — 实际是 4 种模式 + 3 种后端,引擎类只有 4 个 (Memory / KVStore / Hybrid / Aria),OPFS 是后端而非引擎。标题与条目已改写, 并写明"`disk`/`hybrid` 恒用 KVStore"。 5. **`diskEngine` 生效范围** — 仅 `mode:'aria'` 生效;`constants.ts` 的注释 此前写成"仅 mode='disk'|'hybrid' 时生效"(正好写反),已改正;README 配置表、 快速开始示例与 Aria 示例同步标注。 数字口径统一(可复现): - 测试 1872(90 套件)+ 14 e2e,另 4 个重型套件在独立 CI job 串行运行; - 覆盖率 语句 90.43% / 分支 82.21% / 函数 94.27% / 行 93.44%; - README 明确写出**产出这些数字的完整命令**(与 CI 常规 job 一致), 并要求改动覆盖范围/阈值时同步更新表格(G5)。 - CHANGELOG 0.8.0 条目与 site 首页/文档页同步。 另修 **CONTRIBUTING 的钩子契约**:明确写出"返回值被忽略(不能取消/改写)、 就地改参数在 Table API 生效、抛异常可取消、SQL 路径的 beforeInsert 收到副本" —— 此前只写 "allow intercepting",容易被理解为返回值可改变行为。 验证:全量 90 套件 / 1872 测试通过(+4 重型套件);覆盖率四项均高于阈值; typecheck(src+tests)、lint、build 零错误零告警;e2e 14 项通过;dist 已重建。
127 lines
3.4 KiB
JavaScript
127 lines
3.4 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,
|
||
},
|
||
// react/vue 为 peer dependency(integrations 子路径),不打包
|
||
external: ['react', 'vue'],
|
||
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,
|
||
},
|
||
external: ['react', 'vue'],
|
||
plugins: basePlugins,
|
||
},
|
||
// CommonJS(.cjs 后缀:package.json 为 type:module,.js 会被 Node 按 ESM 解析)
|
||
{
|
||
input: 'src/index.ts',
|
||
output: {
|
||
file: 'dist/metona-sqlark.cjs',
|
||
format: 'cjs',
|
||
exports: 'named',
|
||
sourcemap: true,
|
||
},
|
||
external: ['react', 'vue'],
|
||
plugins: basePlugins,
|
||
},
|
||
// UMD minified
|
||
{
|
||
input: 'src/index.ts',
|
||
output: {
|
||
file: 'dist/metona-sqlark.min.js',
|
||
format: 'umd',
|
||
name: 'MetonaSqlark',
|
||
exports: 'named',
|
||
sourcemap: false,
|
||
},
|
||
external: ['react', 'vue'],
|
||
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()],
|
||
},
|
||
// v0.8.0: React / Vue 集成产物。
|
||
// 此前 package.json 的 "./react" / "./vue" 直接指向 **src/ 下的裸 TS 源码**,
|
||
// 而这两个文件带 `// @ts-nocheck` → 使用者拿到的是未编译代码 + 类型为 any
|
||
// 的声明("开箱即用 hooks"这一宣称不成立)。现在构建成真实 ESM 产物,
|
||
// 配套手写精确声明(见 src/integrations/*.d.ts 的说明)。
|
||
// react / vue 保持 external(peer dependency),不打包进产物。
|
||
{
|
||
input: 'src/integrations/react.ts',
|
||
output: { file: 'dist/react.js', format: 'es', sourcemap: true },
|
||
external: ['react'],
|
||
plugins: basePlugins,
|
||
},
|
||
{
|
||
input: 'src/integrations/vue.ts',
|
||
output: { file: 'dist/vue.js', format: 'es', sourcemap: true },
|
||
external: ['vue'],
|
||
plugins: basePlugins,
|
||
},
|
||
]),
|
||
];
|