Add compile to ToolBase management page
This commit is contained in:
@@ -2,6 +2,7 @@ import '@/components/Playground/Output/Preview/preview.scss'
|
||||
import { IFiles, IImportMap } from '@/components/Playground/shared'
|
||||
import Compiler from '@/components/Playground/compiler'
|
||||
import iframeRaw from '@/components/Playground/Output/Preview/iframe.html?raw'
|
||||
import { ENTRY_FILE_NAME } from '@/components/Playground/files.ts'
|
||||
|
||||
interface PreviewProps {
|
||||
iframeKey: string
|
||||
@@ -60,7 +61,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
Compiler.compile(files, importMap)
|
||||
Compiler.compile(files, importMap, [ENTRY_FILE_NAME])
|
||||
.then((result) => {
|
||||
if (loaded) {
|
||||
iframeRef.current?.contentWindow?.postMessage({
|
||||
|
||||
@@ -39,7 +39,7 @@ class Compiler {
|
||||
return esbuild.transform(code, { loader })
|
||||
})
|
||||
|
||||
compile = (files: IFiles, importMap: IImportMap) =>
|
||||
compile = (files: IFiles, importMap: IImportMap, entryPoints: string[]) =>
|
||||
new Promise<void>((resolve) => {
|
||||
if (this.init) {
|
||||
resolve()
|
||||
@@ -54,7 +54,7 @@ class Compiler {
|
||||
}).then(() => {
|
||||
return esbuild.build({
|
||||
bundle: true,
|
||||
entryPoints: [ENTRY_FILE_NAME],
|
||||
entryPoints: entryPoints,
|
||||
format: 'esm',
|
||||
metafile: true,
|
||||
write: false,
|
||||
|
||||
Reference in New Issue
Block a user