fix: import type + lazy singleton pour dagre et pptxgenjs (Turbopack build)
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 23s
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 23s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
'use server'
|
||||
|
||||
import PptxGenJS from 'pptxgenjs'
|
||||
// import type is erased at build time — Turbopack won't try to resolve the module
|
||||
import type PptxGenJSModule from 'pptxgenjs'
|
||||
// Lazy singleton — actual module loaded at runtime only
|
||||
let _PptxGenJS: (new () => PptxGenJSModule) | null = null
|
||||
async function getPptxGenClass(): Promise<new () => PptxGenJSModule> {
|
||||
if (!_PptxGenJS) {
|
||||
const mod = await import('pptxgenjs')
|
||||
_PptxGenJS = (mod.default ?? mod) as unknown as new () => PptxGenJSModule
|
||||
}
|
||||
return _PptxGenJS
|
||||
}
|
||||
import { tool } from 'ai'
|
||||
import { z } from 'zod'
|
||||
import { toolRegistry } from './registry'
|
||||
@@ -960,10 +970,11 @@ function addClosingSlide(pres: PptxGenJS, spec: PresentationSpec, t: Theme, styl
|
||||
return s
|
||||
}
|
||||
|
||||
function buildPresentation(spec: PresentationSpec): PptxGenJS {
|
||||
async function buildPresentation(spec: PresentationSpec): Promise<PptxGenJSModule> {
|
||||
const { theme } = resolveTheme(spec)
|
||||
const style = STYLES[spec.style || 'soft'] || STYLES.soft!
|
||||
|
||||
const PptxGenJS = await getPptxGenClass()
|
||||
const pres = new PptxGenJS()
|
||||
pres.title = spec.title
|
||||
pres.author = 'Momento'
|
||||
@@ -1131,7 +1142,7 @@ RULES:
|
||||
}
|
||||
}
|
||||
|
||||
const pptx = buildPresentation(spec)
|
||||
const pptx = await buildPresentation(spec)
|
||||
const base64 = await pptx.write({ outputType: 'base64' }) as string
|
||||
|
||||
const canvas = await prisma.canvas.create({
|
||||
|
||||
Reference in New Issue
Block a user