Skip to content

Commit 8eb45e3

Browse files
fix(ppt): dep injection (#3732)
1 parent 852dc93 commit 8eb45e3

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

apps/sim/lib/execution/pptx-vm.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ let cachedWorkerPath: string | undefined
3333
function getWorkerPath(): string {
3434
if (cachedWorkerPath) return cachedWorkerPath
3535
const candidates = [
36+
path.join(currentDir, '..', '..', 'dist', 'pptx-worker.cjs'),
3637
path.join(currentDir, 'pptx-worker.cjs'),
38+
path.join(process.cwd(), 'apps', 'sim', 'dist', 'pptx-worker.cjs'),
39+
path.join(process.cwd(), 'apps', 'sim', 'lib', 'execution', 'pptx-worker.cjs'),
40+
path.join(process.cwd(), 'dist', 'pptx-worker.cjs'),
3741
path.join(process.cwd(), 'lib', 'execution', 'pptx-worker.cjs'),
3842
]
3943
const found = candidates.find((p) => fs.existsSync(p))

apps/sim/next.config.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,7 @@ const nextConfig: NextConfig = {
9090
],
9191
outputFileTracingIncludes: {
9292
'/api/tools/stagehand/*': ['./node_modules/ws/**/*'],
93-
'/*': [
94-
'./node_modules/sharp/**/*',
95-
'./node_modules/@img/**/*',
96-
// pptxgenjs and the PPTX worker are required at runtime by the subprocess.
97-
// Neither has a static import that Next.js can trace, so we include them explicitly.
98-
'./node_modules/pptxgenjs/**/*',
99-
'./lib/execution/pptx-worker.cjs',
100-
],
93+
'/*': ['./node_modules/sharp/**/*', './node_modules/@img/**/*', './dist/pptx-worker.cjs'],
10194
},
10295
experimental: {
10396
optimizeCss: true,

apps/sim/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"dev:webpack": "next dev --webpack",
1313
"dev:sockets": "bun run socket/index.ts",
1414
"dev:full": "bunx concurrently -n \"App,Realtime\" -c \"cyan,magenta\" \"bun run dev\" \"bun run dev:sockets\"",
15-
"build": "next build",
15+
"build": "bun run build:pptx-worker && next build",
16+
"build:pptx-worker": "bun build ./lib/execution/pptx-worker.cjs --target=node --format=cjs --outfile ./dist/pptx-worker.cjs",
1617
"start": "next start",
1718
"prepare": "cd ../.. && bun husky",
1819
"test": "vitest run",

docker/app.Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,11 @@ COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/.next/static ./apps/sim/
108108
# Copy isolated-vm native module (compiled for Node.js in deps stage)
109109
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/isolated-vm ./node_modules/isolated-vm
110110

111-
# Copy PPTX runtime dependency
112-
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/pptxgenjs ./node_modules/pptxgenjs
113-
114111
# Copy the isolated-vm worker script
115112
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/execution/isolated-vm-worker.cjs ./apps/sim/lib/execution/isolated-vm-worker.cjs
116113

117-
# Copy the PPTX worker script
118-
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/execution/pptx-worker.cjs ./apps/sim/lib/execution/pptx-worker.cjs
114+
# Copy the bundled PPTX worker artifact
115+
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/dist/pptx-worker.cjs ./apps/sim/dist/pptx-worker.cjs
119116

120117
# Guardrails setup with pip caching
121118
COPY --from=builder --chown=nextjs:nodejs /app/apps/sim/lib/guardrails/requirements.txt ./apps/sim/lib/guardrails/requirements.txt

0 commit comments

Comments
 (0)