Files
SnowLuma/packages/core/vitest.config.ts
DrSmoothl 3d739c255a feat(proton): proof-of-concept migration — longmsg parity test
Migrates a self-contained subset of bridge/proto/longmsg.ts to the new
@snowluma/proton compile-time DSL form and verifies wire-format parity
against the legacy runtime ProtoSchema encoder. End-to-end proof that
the toolchain works in core's vitest pipeline.

What's covered:
  - LongMsgUid / LongMsgSettings / SendLongMsgInfo / SendLongMsgReq /
    SendLongMsgResp / SendLongMsgRespResult / RecvLongMsgInfo /
    RecvLongMsgReq / RecvLongMsgResp / RecvLongMsgRespResult
  - The three schemas that pull in PushMsgBody (LongMsgContent /
    LongMsgAction / LongMsgResult) stay on the legacy API for now, since
    migrating them requires also migrating message.ts and element.ts.

Toolchain changes:
  - @snowluma/proton gets a tsup build step. The ./vite subpath now
    points at the built dist/index.js so it is loadable as plain Node
    ESM from vite.config.ts / vitest.config.ts (the source-only .ts
    layout can't be consumed from outside the Vite transform pipeline).
    The . (runtime) subpath stays at TS source — it's only ever
    imported from user code, which IS Vite-transformed.
  - prepare script ensures dist/ exists after pnpm install.
  - @snowluma/core depends on @snowluma/proton (workspace:*) and adds
    protobufVitePlugin() to its vitest config so test files get
    transformed.

Documented divergence:
  proton follows proto3 semantics: fields equal to their default value
  (0 / false / "" / empty bytes) are NOT emitted on the wire. The legacy
  runtime encoder always emits them. Both forms are round-trippable
  through a conforming proto3 reader. The parity test pins this
  behaviour explicitly.

8/8 parity tests pass.
2026-05-19 08:19:13 +08:00

32 lines
1001 B
TypeScript

import { defineConfig } from 'vitest/config';
import path from 'path';
import { fileURLToPath } from 'url';
import protobufVitePlugin from '@snowluma/proton/vite';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
plugins: [protobufVitePlugin()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},
test: {
include: ['tests/**/*.test.ts'],
environment: 'node',
// Suppress the logger's file transport during tests so the suite
// doesn't litter cwd with logs/snowluma-*.log files. Tests that
// explicitly cover file output set their own SNOWLUMA_LOG_FILE='1'
// + SNOWLUMA_LOG_DIR=<tmp>.
//
// Run at debug level so tests asserting on debug-level log entries
// (e.g. action dispatch entry lines) actually see them via the
// ring buffer / subscribers, which sit behind the console-level gate.
env: {
SNOWLUMA_LOG_FILE: '0',
SNOWLUMA_LOG_LEVEL: 'debug'
}
}
});