Skip to content

Commit d05f1a7

Browse files
authored
chore(webapp): migrate from Remix compiler to Vite (#4188)
Replaces Remix compiler with the Vite plugin. The Express server (cluster, socket.io, ws) and the Docker image contract are unchanged.
1 parent dc87b88 commit d05f1a7

38 files changed

Lines changed: 489 additions & 322 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
Suppress a build-time warning that could appear in Vite-based projects when the optional `@ai-sdk/otel` package is not installed.

apps/webapp/app/components/StaleAssetRecovery.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// Recovers from a rolling deploy rotating the content-hashed /build assets out from
1+
// Recovers from a rolling deploy rotating the content-hashed /assets files out from
22
// under a page. Each image serves only its own build and hard-404s unknown hashes, so
33
// a client can request a hash the serving replica doesn't have and get missing styles
4-
// or a failed asset load. On such a /build load failure we do a bounded full document
4+
// or a failed asset load. On such an asset load failure we do a bounded full document
55
// reload: the fresh document (and, under sticky routing, all of its assets) lands on a
66
// single live build, so the asset resolves. Bounded via sessionStorage so it can never
77
// loop; when the budget is spent it stops rather than reloading forever.
@@ -39,7 +39,7 @@ export function staleAssetRecoveryScript() {
3939
}
4040

4141
function recover() {
42-
// One recovery per page: a broken load fails several /build assets at once and each
42+
// One recovery per page: a broken load fails several hashed assets at once and each
4343
// fires its own error event before location.reload() commits — without this guard a
4444
// single incident would burn the entire reload budget.
4545
if (recovering) return;
@@ -62,7 +62,9 @@ export function staleAssetRecoveryScript() {
6262
: el.tagName === "SCRIPT"
6363
? (el as HTMLScriptElement).src
6464
: null;
65-
if (url && url.indexOf("/build/") !== -1) recover();
65+
// Match the pathname, not the full URL — a query string or third-party
66+
// URL containing /assets/ must not burn the reload budget.
67+
if (url && new URL(url, location.href).pathname.indexOf("/assets/") !== -1) recover();
6668
},
6769
true
6870
);

apps/webapp/app/components/primitives/Avatar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from "@heroicons/react/20/solid";
1111
import type { Prisma } from "@trigger.dev/database";
1212
import { z } from "zod";
13-
import { logger } from "~/services/logger.server";
1413
import { cn } from "~/utils/cn";
1514

1615
export const AvatarType = z.enum(["icon", "letters", "image"]);
@@ -45,7 +44,7 @@ export function parseAvatar(json: Prisma.JsonValue, defaultAvatar: Avatar): Avat
4544
const parsed = AvatarData.safeParse(json);
4645

4746
if (!parsed.success) {
48-
logger.error("Invalid org avatar", { json, error: parsed.error });
47+
console.error("Invalid org avatar", { json, error: parsed.error });
4948
return defaultAvatar;
5049
}
5150

apps/webapp/app/presenters/v3/UsagePresenter.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { DataPoint } from "regression";
2-
import { linear } from "regression";
2+
// Default-import: regression is CJS and its named exports aren't statically
3+
// analyzable under ESM interop.
4+
import regression from "regression";
5+
const { linear } = regression;
36
import type { PrismaClientOrTransaction } from "~/db.server";
47
import { env } from "~/env.server";
58
import { clickhouseFactory } from "~/services/clickhouse/clickhouseFactoryInstance.server";

apps/webapp/app/root.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import type { LinksFunction, LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
22
import type { ShouldRevalidateFunction } from "@remix-run/react";
3-
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
3+
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
44
import { type UseDataFunctionReturn, typedjson, useTypedLoaderData } from "remix-typedjson";
55
import { ExternalScripts } from "remix-utils/external-scripts";
66
import type { ToastMessage } from "~/models/message.server";
77
import { commitSession, getSession } from "~/models/message.server";
8-
import tailwindStylesheetUrl from "~/tailwind.css";
8+
// Fonts imported here so Vite rebases the urls and emits the woff2 assets
9+
import "non.geist";
10+
import "non.geist/mono";
11+
import tailwindStylesheetUrl from "~/tailwind.css?url";
912
import { RouteErrorDisplay } from "./components/ErrorDisplay";
1013
import { StaleAssetRecovery } from "./components/StaleAssetRecovery";
1114
import { AppContainer, MainCenteredContainer } from "./components/layout/AppLayout";
@@ -145,7 +148,6 @@ export default function App() {
145148
<ScrollRestoration />
146149
<ExternalScripts />
147150
<Scripts />
148-
<LiveReload />
149151
</body>
150152
</html>
151153
</>

apps/webapp/app/routes/api.v1.errors.$errorId.ignore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ParamsSchema = z.object({
99
errorId: z.string(),
1010
});
1111

12-
export const { action, loader } = createActionApiRoute(
12+
const route = createActionApiRoute(
1313
{
1414
params: ParamsSchema,
1515
body: IgnoreErrorRequestBody,
@@ -56,3 +56,6 @@ export const { action, loader } = createActionApiRoute(
5656
return json(updated);
5757
}
5858
);
59+
60+
export const action = route.action;
61+
export const loader = route.loader;

apps/webapp/app/routes/api.v1.errors.$errorId.resolve.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ParamsSchema = z.object({
99
errorId: z.string(),
1010
});
1111

12-
export const { action, loader } = createActionApiRoute(
12+
const route = createActionApiRoute(
1313
{
1414
params: ParamsSchema,
1515
body: ResolveErrorRequestBody,
@@ -48,3 +48,6 @@ export const { action, loader } = createActionApiRoute(
4848
return json(updated);
4949
}
5050
);
51+
52+
export const action = route.action;
53+
export const loader = route.loader;

apps/webapp/app/routes/api.v1.errors.$errorId.unresolve.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const ParamsSchema = z.object({
88
errorId: z.string(),
99
});
1010

11-
export const { action, loader } = createActionApiRoute(
11+
const route = createActionApiRoute(
1212
{
1313
params: ParamsSchema,
1414
method: "POST",
@@ -40,3 +40,6 @@ export const { action, loader } = createActionApiRoute(
4040
return json(updated);
4141
}
4242
);
43+
44+
export const action = route.action;
45+
export const loader = route.loader;

apps/webapp/app/routes/api.v1.idempotencyKeys.$key.reset.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const BodySchema = z.object({
1313
taskIdentifier: z.string().min(1, "Task identifier is required"),
1414
});
1515

16-
export const { action } = createActionApiRoute(
16+
const route = createActionApiRoute(
1717
{
1818
params: ParamsSchema,
1919
body: BodySchema,
@@ -50,3 +50,7 @@ export const { action } = createActionApiRoute(
5050
}
5151
}
5252
);
53+
54+
export const action = route.action;
55+
// The builder's loader handles CORS OPTIONS preflight
56+
export const loader = route.loader;

apps/webapp/app/routes/api.v1.orgs.$orgParam.projects.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
createLoaderPATApiRoute,
1111
} from "~/services/routeBuilders/apiBuilder.server";
1212
import { ServiceValidationError } from "~/v3/services/common.server";
13-
import { isCuid } from "cuid";
13+
import cuid from "cuid";
14+
const { isCuid } = cuid;
1415

1516
const ParamsSchema = z.object({
1617
orgParam: z.string(),

0 commit comments

Comments
 (0)