Skip to content

Commit a9ba3f4

Browse files
committed
feat(webapp): migrate from the classic Remix compiler to Vite
Workspace packages resolve to TS source via the @triggerdotdev/source condition; server.ts keeps the Express/cluster/ws wiring with vite middleware in dev and the ESM server bundle in prod. Fixes surfaced by the stricter ESM pipeline: destructured route exports, server-only imports in routes/components, CJS interop (redlock, cuid, regression), browser node-global shims, font asset handling, and a websockets TDZ.
1 parent 82d325a commit a9ba3f4

34 files changed

Lines changed: 386 additions & 287 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+
Annotate the optional `@ai-sdk/otel` dynamic import with `@vite-ignore` so Vite-based bundlers don't warn about an unanalyzable import.

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 { AppContainer, MainCenteredContainer } from "./components/layout/AppLayout";
1114
import { ShortcutsProvider } from "./components/primitives/ShortcutsProvider";
@@ -135,7 +138,6 @@ export default function App() {
135138
<ScrollRestoration />
136139
<ExternalScripts />
137140
<Scripts />
138-
<LiveReload />
139141
</body>
140142
</html>
141143
</>

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: 3 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,5 @@ export const { action } = createActionApiRoute(
5050
}
5151
}
5252
);
53+
54+
export const action = route.action;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { prisma } from "~/db.server";
77
import { createProject } from "~/models/project.server";
88
import { logger } from "~/services/logger.server";
99
import { authenticateApiRequestWithPersonalAccessToken } from "~/services/personalAccessToken.server";
10-
import { isCuid } from "cuid";
10+
import cuid from "cuid";
11+
const { isCuid } = cuid;
1112

1213
const ParamsSchema = z.object({
1314
orgParam: z.string(),

apps/webapp/app/routes/api.v1.queues.$queueParam.concurrency.override.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const BodySchema = z.object({
1010
concurrencyLimit: z.number().int().min(0).max(100000),
1111
});
1212

13-
export const { action } = createActionApiRoute(
13+
const route = createActionApiRoute(
1414
{
1515
body: BodySchema,
1616
params: z.object({
@@ -73,3 +73,5 @@ export const { action } = createActionApiRoute(
7373
);
7474
}
7575
);
76+
77+
export const action = route.action;

0 commit comments

Comments
 (0)