Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

vite.config.ts

89 lines3.6 KB

1import "vite-plus/test/config";
2import { defineConfig, mergeConfig } from "vite-plus";
3​
4import baseConfig from "../../vite.config.ts";
5import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
6import packageJson from "./package.json" with { type: "json" };
7​
8// The bundle used to inline only workspace packages, leaving every third-party
9// runtime dep external. External deps must exist on the real filesystem (the WSL
10// backend runs plain `wsl.exe -- node`, which cannot read inside an asar), so the
11// desktop build unpacked `**\/node_modules\/**` wholesale: 13,875 loose files to
12// support 20 native binaries. NSIS install time tracks file count, not bytes.
13//
14// Inverted here — bundle everything except the packages that genuinely cannot be
15// inlined. See scripts/lib/cli-external-packages.ts for what earns an exemption.
16import {
17 isExternalCliDependency,
18 shouldBundleCliDependency,
19} from "../../scripts/lib/cli-external-packages.ts";
20​
21export { shouldBundleCliDependency };
22​
23const repoEnv = loadRepoEnv();
24const cliBuildChannel = packageJson.version.includes("-nightly.") ? "nightly" : "latest";
25​
26export default mergeConfig(
27 baseConfig,
28 defineConfig({
29 run: {
30 tasks: {
31 build: {
32 command: "node scripts/cli.ts build",
33 dependsOn: ["@t3tools/web#build"],
34 cache: false,
35 },
36 },
37 },
38 pack: {
39 entry: ["src/bin.ts"],
40 outDir: "dist",
41 sourcemap: true,
42 clean: true,
43 deps: {
44 // Both halves are required. `alwaysBundle` forces the JS dependencies in
45 // (declared deps are external by default, which is what this change is
46 // undoing). `neverBundle` forces the native packages out: returning
47 // false from `alwaysBundle` only means "no opinion", so a transitive
48 // dependency would still be bundled — which silently inlined
49 // msgpackr-extract and its loader, losing native acceleration.
50 alwaysBundle: shouldBundleCliDependency,
51 neverBundle: (id: string) => isExternalCliDependency(id),
52 onlyBundle: false,
53 },
54 banner: {
55 js: "#!/usr/bin/env node\n",
56 },
57 define: {
58 __T3CODE_BUILD_CHANNEL__: JSON.stringify(cliBuildChannel),
59 __T3CODE_BUILD_RELAY_URL__: JSON.stringify(repoEnv.T3CODE_RELAY_URL?.trim() ?? ""),
60 __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__: JSON.stringify(
61 repoEnv.T3CODE_CLERK_PUBLISHABLE_KEY?.trim() ?? "",
62 ),
63 __T3CODE_BUILD_CLERK_CLI_OAUTH_CLIENT_ID__: JSON.stringify(
64 repoEnv.T3CODE_CLERK_CLI_OAUTH_CLIENT_ID?.trim() ?? "",
65 ),
66 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_URL__: JSON.stringify(
67 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_URL?.trim() ?? "",
68 ),
69 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_DATASET__: JSON.stringify(
70 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET?.trim() ?? "",
71 ),
72 __T3CODE_BUILD_RELAY_CLIENT_OTLP_TRACES_TOKEN__: JSON.stringify(
73 repoEnv.T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN?.trim() ?? "",
74 ),
75 },
76 },
77 test: {
78 // The server suite exercises sqlite, git, temp worktrees, and orchestration
79 // runtimes heavily. Running files in parallel introduces load-sensitive flakes.
80 fileParallelism: false,
81 // Appended to the root setup, which mergeConfig concatenates.
82 setupFiles: ["./src/testUtils/gitConfig.setup.ts"],
83 // Server integration tests exercise sqlite, git, and orchestration together.
84 // Under package-wide runs they can exceed the default budget on loaded CI hosts.
85 hookTimeout: 120_000,
86 testTimeout: 120_000,
87 },
88 }),
89);