Skip to content

Commit 2378c0a

Browse files
committed
final commit?
1 parent 95d7142 commit 2378c0a

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

packages/template-vercel/create-snapshot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { put } from "@vercel/blob";
22
import { addBundleToSandbox, createSandbox } from "@remotion/vercel";
3-
import { ensureLocalBundle } from "./src/app/api/render/helpers";
3+
import { bundleRemotionProject } from "./src/app/api/render/helpers";
44

55
const getSnapshotBlobKey = () =>
66
`snapshot-cache/${process.env.VERCEL_DEPLOYMENT_ID ?? "local"}.json`;
@@ -13,7 +13,7 @@ const sandbox = await createSandbox({
1313
});
1414

1515
console.log("[create-snapshot] Adding Remotion bundle...");
16-
ensureLocalBundle(".remotion");
16+
bundleRemotionProject(".remotion");
1717
await addBundleToSandbox({ sandbox, bundleDir: ".remotion" });
1818

1919
console.log("[create-snapshot] Taking snapshot...");

packages/template-vercel/src/app/api/render/helpers.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
import { execSync } from "child_process";
2-
import { existsSync } from "fs";
3-
import path from "path";
42

5-
export function ensureLocalBundle(bundleDir: string): void {
6-
const fullBundleDir = path.join(process.cwd(), bundleDir);
7-
if (!existsSync(fullBundleDir)) {
8-
try {
9-
execSync(`node_modules/.bin/remotion bundle --out-dir ./${bundleDir}`, {
10-
cwd: process.cwd(),
11-
stdio: "pipe",
12-
});
13-
} catch (e) {
14-
const stderr = (e as { stderr?: Buffer }).stderr?.toString() ?? "";
15-
throw new Error(`Remotion bundle failed: ${stderr}`);
16-
}
3+
export function bundleRemotionProject(bundleDir: string): void {
4+
try {
5+
execSync(`node_modules/.bin/remotion bundle --out-dir ./${bundleDir}`, {
6+
cwd: process.cwd(),
7+
stdio: "inherit",
8+
});
9+
} catch (e) {
10+
const stderr = (e as { stderr?: Buffer }).stderr?.toString() ?? "";
11+
throw new Error(`Remotion bundle failed: ${stderr}`);
1712
}
1813
}
1914

packages/template-vercel/src/app/api/render/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
import { waitUntil } from "@vercel/functions";
88
import { COMP_NAME } from "../../../../types/constants";
99
import { RenderRequest } from "../../../../types/schema";
10-
import { ensureLocalBundle, formatSSE, type RenderProgress } from "./helpers";
10+
import { bundleRemotionProject, formatSSE, type RenderProgress } from "./helpers";
1111
import { restoreSnapshot } from "./restore-snapshot";
1212

1313
export async function POST(req: Request) {
@@ -46,7 +46,7 @@ export async function POST(req: Request) {
4646

4747
try {
4848
if (!process.env.VERCEL) {
49-
ensureLocalBundle(".remotion");
49+
bundleRemotionProject(".remotion");
5050
await addBundleToSandbox({ sandbox, bundleDir: ".remotion" });
5151
}
5252

0 commit comments

Comments
 (0)