Fix can not autoload in production mode bug

This commit is contained in:
2024-01-15 15:57:48 +08:00
parent bcf29f74ef
commit 6d08e1a8e8
24 changed files with 36 additions and 57 deletions

View File

@@ -1,5 +1,4 @@
import '@/components/Playground/playground.scss'
import { useUpdatedEffect } from '@/util/hooks'
import { IFiles, IImportMap, ITsconfig } from '@/components/Playground/shared'
import {
IMPORT_MAP_FILE_NAME,
@@ -54,7 +53,7 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
setFiles(files)
}
useUpdatedEffect(() => {
useEffect(() => {
try {
setImportMap(JSON.parse(importMapRaw) as IImportMap)
} catch (e) {
@@ -62,7 +61,7 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
}
}, [importMapRaw])
useUpdatedEffect(() => {
useEffect(() => {
try {
setTsconfig(JSON.parse(tsconfigRaw) as ITsconfig)
} catch (e) {
@@ -76,12 +75,12 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
tsconfig={tsconfig}
files={{
...files,
'import-map.json': {
[IMPORT_MAP_FILE_NAME]: {
name: IMPORT_MAP_FILE_NAME,
language: 'json',
value: importMapRaw
},
'tsconfig.json': {
[TS_CONFIG_FILE_NAME]: {
name: TS_CONFIG_FILE_NAME,
language: 'json',
value: tsconfigRaw