Refactor(Transform): Remove auto add react import when transform
This commit is contained in:
@@ -2,7 +2,7 @@ import MonacoEditor from '@monaco-editor/react'
|
|||||||
import { Loader } from 'esbuild-wasm'
|
import { Loader } from 'esbuild-wasm'
|
||||||
import '@/components/Playground/Output/Transform/transform.scss'
|
import '@/components/Playground/Output/Transform/transform.scss'
|
||||||
import { IFile, ITheme } from '@/components/Playground/shared'
|
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 Compiler from '@/components/Playground/compiler'
|
||||||
import { MonacoEditorConfig } from '@/components/Playground/CodeEditor/Editor/monacoConfig'
|
import { MonacoEditorConfig } from '@/components/Playground/CodeEditor/Editor/monacoConfig'
|
||||||
|
|
||||||
@@ -16,12 +16,7 @@ const Transform = ({ file, theme }: OutputProps) => {
|
|||||||
const [errorMsg, setErrorMsg] = useState('')
|
const [errorMsg, setErrorMsg] = useState('')
|
||||||
|
|
||||||
const compile = (code: string, loader: Loader) => {
|
const compile = (code: string, loader: Loader) => {
|
||||||
let _code = code
|
Compiler?.transform(code, loader)
|
||||||
if (['jsx', 'tsx'].includes(loader)) {
|
|
||||||
_code = addReactImport(code)
|
|
||||||
}
|
|
||||||
|
|
||||||
Compiler?.transform(_code, loader)
|
|
||||||
.then((value) => {
|
.then((value) => {
|
||||||
setCompiledCode(value.code)
|
setCompiledCode(value.code)
|
||||||
setErrorMsg('')
|
setErrorMsg('')
|
||||||
|
|||||||
Reference in New Issue
Block a user