@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 46 lines 1.73 KB
Raw
1 import path from "node:path";
2 import type * as vite from "vite";
3 import { assert, describe, expect, it } from "vitest";
4 import { optionsPlugin } from "../plugins/options.ts";
5
6 describe("vite worker entry resolution", () => {
7 const callConfig = async (userConfig: vite.UserConfig) => {
8 const plugin = optionsPlugin.vite({ compatibilityDate: "2025-07-01" });
9 assert(typeof plugin.config === "function", "plugin.config is not a function");
10 return (await plugin.config.call({ meta: {} } as never, userConfig, {
11 command: "build",
12 mode: "production",
13 } as vite.ConfigEnv)) as vite.UserConfig;
14 };
15
16 it("resolves a relative ssr input against the vite root", async () => {
17 // The user entry is resolved with no importer, so without this a relative
18 // input resolves against `process.cwd()` — the wrong base when the build
19 // runs outside the project root (e.g. a monorepo infra package).
20 const config = await callConfig({
21 root: "/project",
22 environments: {
23 ssr: { build: { rollupOptions: { input: "./workers/app.ts" } } },
24 },
25 });
26 expect(config.environments?.ssr?.build?.rollupOptions?.input).toEqual({
27 app: `\0distilled:worker-entry:${path.resolve("/project", "./workers/app.ts").replaceAll("\\", "/")}`,
28 });
29 });
30
31 it("leaves virtual module inputs untouched", async () => {
32 const config = await callConfig({
33 root: "/project",
34 environments: {
35 ssr: {
36 build: {
37 rollupOptions: { input: "virtual:react-router/server-build" },
38 },
39 },
40 },
41 });
42 expect(config.environments?.ssr?.build?.rollupOptions?.input).toEqual({
43 "server-build": "\0distilled:worker-entry:virtual:react-router/server-build",
44 });
45 });
46 });