Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: avoid Vite static analysis of html2canvas dynamic import

esengineb6a9652da0c3
diff --git a/editor/src/bridge/McpBridge.ts b/editor/src/bridge/McpBridge.ts
index 5409030a7..d6d3b2768 100644
--- a/editor/src/bridge/McpBridge.ts
+++ b/editor/src/bridge/McpBridge.ts
@@ -298,8 +298,9 @@ export class McpBridge {
if (!el) throw new Error(`Panel not found: ${panelId}`);
try {
+ const modName = 'html2' + 'canvas';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const mod = await import(/* webpackIgnore: true */ /* @vite-ignore */ 'html2canvas' as any) as any;
+ const mod = await (Function('m', 'return import(m)') as (m: string) => Promise<any>)(modName);
const html2canvas = mod.default ?? mod;
const canvas = await html2canvas(el, {
scale: 1,