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: strip comments before parsing component defaults in editor

esengine5e664e8b7932
diff --git a/editor/src/scripting/ScriptLoader.ts b/editor/src/scripting/ScriptLoader.ts
index 572518350..043c598bb 100644
--- a/editor/src/scripting/ScriptLoader.ts
+++ b/editor/src/scripting/ScriptLoader.ts
@@ -319,6 +319,8 @@ function extractAndRegisterComponents(source: string): string[] {
function safeParseObjectLiteral(objStr: string): Record<string, unknown> | null {
try {
const json = objStr
+ .replace(/\/\/.*$/gm, '')
+ .replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/'/g, '"')
.replace(/(\w+)\s*:/g, '"$1":')
.replace(/,\s*([}\]])/g, '$1');