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

@@ -32,7 +32,7 @@ const Preview = ({
Compiler.compile(files, importMap, entryPoint)
.then((result) => {
setCompiledCode(
`${preExpansionCode}\n${result.outputFiles[0].text}\n${postExpansionCode}`
`(()=>{${preExpansionCode}})();\n(()=>{${result.outputFiles[0].text}})();\n(()=>{${postExpansionCode}})();`
)
setErrorMsg('')
})