From e7f562106d08da89cecc5d31cfdb5e9886376337 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Mon, 23 Mar 2026 21:15:40 -0700 Subject: [PATCH] fix(ppt): dep injection --- apps/sim/lib/execution/pptx-vm.ts | 4 ++++ apps/sim/next.config.ts | 9 +-------- apps/sim/package.json | 3 ++- docker/app.Dockerfile | 7 ++----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/apps/sim/lib/execution/pptx-vm.ts b/apps/sim/lib/execution/pptx-vm.ts index 007054df09..1179454400 100644 --- a/apps/sim/lib/execution/pptx-vm.ts +++ b/apps/sim/lib/execution/pptx-vm.ts @@ -33,7 +33,11 @@ let cachedWorkerPath: string | undefined function getWorkerPath(): string { if (cachedWorkerPath) return cachedWorkerPath const candidates = [ + path.join(currentDir, '..', '..', 'dist', 'pptx-worker.cjs'), path.join(currentDir, 'pptx-worker.cjs'), + path.join(process.cwd(), 'apps', 'sim', 'dist', 'pptx-worker.cjs'), + path.join(process.cwd(), 'apps', 'sim', 'lib', 'execution', 'pptx-worker.cjs'), + path.join(process.cwd(), 'dist', 'pptx-worker.cjs'), path.join(process.cwd(), 'lib', 'execution', 'pptx-worker.cjs'), ] const found = candidates.find((p) => fs.existsSync(p)) diff --git a/apps/sim/next.config.ts b/apps/sim/next.config.ts index fceb71dfa1..ede66f5987 100644 --- a/apps/sim/next.config.ts +++ b/apps/sim/next.config.ts @@ -90,14 +90,7 @@ const nextConfig: NextConfig = { ], outputFileTracingIncludes: { '/api/tools/stagehand/*': ['./node_modules/ws/**/*'], - '/*': [ - './node_modules/sharp/**/*', - './node_modules/@img/**/*', - // pptxgenjs and the PPTX worker are required at runtime by the subprocess. - // Neither has a static import that Next.js can trace, so we include them explicitly. - './node_modules/pptxgenjs/**/*', - './lib/execution/pptx-worker.cjs', - ], + '/*': ['./node_modules/sharp/**/*', './node_modules/@img/**/*', './dist/pptx-worker.cjs'], }, experimental: { optimizeCss: true, diff --git a/apps/sim/package.json b/apps/sim/package.json index 6dab8edcf8..6ded664025 100644 --- a/apps/sim/package.json +++ b/apps/sim/package.json @@ -12,7 +12,8 @@ "dev:webpack": "next dev --webpack", "dev:sockets": "bun run socket/index.ts", "dev:full": "bunx concurrently -n \"App,Realtime\" -c \"cyan,magenta\" \"bun run dev\" \"bun run dev:sockets\"", - "build": "next build", + "build": "bun run build:pptx-worker && next build", + "build:pptx-worker": "bun build ./lib/execution/pptx-worker.cjs --target=node --format=cjs --outfile ./dist/pptx-worker.cjs", "start": "next start", "prepare": "cd ../.. && bun husky", "test": "vitest run", diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index c8516635bd..b9a8fc13d9 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -108,14 +108,11 @@ COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/.next/static ./apps/sim/ # Copy isolated-vm native module (compiled for Node.js in deps stage) COPY --from=deps --chown=nextjs:nodejs /app/node_modules/isolated-vm ./node_modules/isolated-vm -# Copy PPTX runtime dependency -COPY --from=deps --chown=nextjs:nodejs /app/node_modules/pptxgenjs ./node_modules/pptxgenjs - # Copy the isolated-vm worker script COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/execution/isolated-vm-worker.cjs ./apps/sim/lib/execution/isolated-vm-worker.cjs -# Copy the PPTX worker script -COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/execution/pptx-worker.cjs ./apps/sim/lib/execution/pptx-worker.cjs +# Copy the bundled PPTX worker artifact +COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/dist/pptx-worker.cjs ./apps/sim/dist/pptx-worker.cjs # Guardrails setup with pip caching COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/guardrails/requirements.txt ./apps/sim/lib/guardrails/requirements.txt