From 19f4f826b4684cda8bb60ff34ca053458587dec0 Mon Sep 17 00:00:00 2001 From: premkumarsevugan Date: Sat, 29 Aug 2026 18:25:11 +0530 Subject: [PATCH] fix: onError callback getting raw Error objects instead of strings two spots in EditReactCanvas passed the Error straight through even tho onError expects a string, so anything rendering it would crash. matched the existing instanceof Error check a few lines below. also fixed importLines emitting a bogus react import for EditableText, and made prerenderMarkup run alongside bundleEntry/compileCss instead of after. --- src/builder/entry.ts | 4 ++++ src/builder/standalone.ts | 5 ++--- src/coreComponents/EditReactCanvas.tsx | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/builder/entry.ts b/src/builder/entry.ts index 5685144..6e36135 100644 --- a/src/builder/entry.ts +++ b/src/builder/entry.ts @@ -52,6 +52,10 @@ export function importLines(referencedGlobals: string[]): string { // whether or not the source ever spells `React`. if (name === "React") continue; + // Not a real export of any package -- callers are expected to strip + // back to plain JSX before reaching here. + if (name === "EditableText") continue; + if (name in baseScope) { add( name === "Helmet" || name === "HelmetProvider" diff --git a/src/builder/standalone.ts b/src/builder/standalone.ts index 060ef7b..d940588 100644 --- a/src/builder/standalone.ts +++ b/src/builder/standalone.ts @@ -239,12 +239,11 @@ export async function buildStandaloneSite( const source = await stripEditableText(code); const entry = await entryFor(source); - const [js, css] = await Promise.all([ + const [js, css, markup] = await Promise.all([ bundleEntry(entry, options), compileCss(source, options), + prerender ? prerenderMarkup(source) : Promise.resolve(""), ]); - - const markup = prerender ? await prerenderMarkup(source) : ""; const { head: hoisted, body } = splitHoisted(markup); const files: Record = {}; diff --git a/src/coreComponents/EditReactCanvas.tsx b/src/coreComponents/EditReactCanvas.tsx index b300700..441c16e 100644 --- a/src/coreComponents/EditReactCanvas.tsx +++ b/src/coreComponents/EditReactCanvas.tsx @@ -104,7 +104,7 @@ export default function EditReactCanvas({ // if error - onError callback if exist, return if (error) { if (onError) { - onError(error); + onError(error instanceof Error ? error.message : String(error)); } return } @@ -157,7 +157,7 @@ export default function EditReactCanvas({ var { transformedCode, error } = transformEditableTextToJSX(transformedCode); if (error) { if (onError) { - onError(error); + onError(error instanceof Error ? error.message : String(error)); } return }