Fix(Preview): Fixed code pollution bug

Methods and variables in base and main code are isolated to solve the problem of code pollution. Close #4
This commit is contained in:
2024-09-09 16:24:22 +08:00
parent bba90c6783
commit 51ee15749e
7 changed files with 129 additions and 131 deletions

View File

@@ -145,7 +145,7 @@ const Create = () => {
.compile(files, importMap, template.entryPoint)
.then((result) => {
const output = result.outputFiles[0].text
setCompiledCode(`${output}\n${baseDist}`)
setCompiledCode(`(() => {${output}})();\n(() => {${baseDist}})();`)
})
.catch((reason) => {
void message.error(`编译失败:${reason}`)