Refactor(Transform): Remove auto add react import when transform

This commit is contained in:
2024-10-26 16:32:52 +08:00
parent 7608502d65
commit b2a3476872

View File

@@ -2,7 +2,7 @@ import MonacoEditor from '@monaco-editor/react'
import { Loader } from 'esbuild-wasm'
import '@/components/Playground/Output/Transform/transform.scss'
import { IFile, ITheme } from '@/components/Playground/shared'
import { cssToJs, jsonToJs, addReactImport } from '@/components/Playground/files'
import { cssToJs, jsonToJs } from '@/components/Playground/files'
import Compiler from '@/components/Playground/compiler'
import { MonacoEditorConfig } from '@/components/Playground/CodeEditor/Editor/monacoConfig'
@@ -16,12 +16,7 @@ const Transform = ({ file, theme }: OutputProps) => {
const [errorMsg, setErrorMsg] = useState('')
const compile = (code: string, loader: Loader) => {
let _code = code
if (['jsx', 'tsx'].includes(loader)) {
_code = addReactImport(code)
}
Compiler?.transform(_code, loader)
Compiler?.transform(code, loader)
.then((value) => {
setCompiledCode(value.code)
setErrorMsg('')