Open History to see the last commit
1import { defineConfig, mergeConfig } from 'vitest/config'
2import { tanstackViteConfig } from '@tanstack/vite-config'
3import packageJson from './package.json'
4
5const config = defineConfig({
6 test: {
7 name: packageJson.name,
8 dir: './',
9 watch: false,
10 globals: true,
11 environment: 'node',
12 include: ['tests/**/*.test.ts'],
13 // Resume-join tests wait REJOIN_CONNECT_DEADLINE_MS (2s) inside
14 // waitFor({ timeout: 5_000 }). Default 5s testTimeout loses that race
15 // when nx runs this suite in parallel with the rest of test:pr.
16 testTimeout: 15_000,
17 // Re-route the no-op devtools factories to the real implementations
18 // for the whole test suite. The shipping default is no-op (so the
19 // heavy bridge classes stay out of `@tanstack/ai-client`'s main
20 // bundle); tests assert on devtools event emission and need the
21 // real bridges.
22 setupFiles: ['./tests/use-real-devtools-bridges.ts'],
23 coverage: {
24 provider: 'v8',
25 reporter: ['text', 'json', 'html', 'lcov'],
26 exclude: [
27 'node_modules/',
28 'dist/',
29 'tests/',
30 '**/*.test.ts',
31 '**/*.config.ts',
32 '**/types.ts',
33 ],
34 include: ['src/**/*.ts'],
35 },
36 },
37})
38
39export default mergeConfig(
40 config,
41 tanstackViteConfig({
42 // `devtools.ts` is a separately-published subpath
43 // (`@tanstack/ai-client/devtools`) holding the heavy bridge
44 // implementations; declare it as its own entry so the build emits
45 // it independently and the main entry can stay free of the bridge
46 // classes (they're imported only via `import type` from clients).
47 entry: [
48 './src/index.ts',
49 './src/devtools.ts',
50 './src/byok.ts',
51 './src/ui.ts',
52 ],
53 srcDir: './src',
54 cjs: false,
55 }),
56)