Skip to content

Commit 9718146

Browse files
authored
fix: compatible with Vue 3.2 (#330)
1 parent a6a16ee commit 9718146

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/composables/store.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {
2-
compileFile,
2+
compileFile as originalCompileFile,
33
File,
44
mergeImportMap,
55
useStore as useReplStore,
66
type ImportMap,
77
type StoreState,
8+
type ReplStore,
89
} from '@vue/repl'
910
import { objectOmit } from '@vueuse/core'
1011
import { IS_DEV } from '@/constants'
@@ -248,6 +249,17 @@ export const useStore = (initial: Initial) => {
248249
break
249250
}
250251
}
252+
async function compileFile(store: ReplStore, file: File) {
253+
const errs = await originalCompileFile(store, file)
254+
if (userOptions.vueVersion?.startsWith('3.2')) {
255+
file.compiled.js = file.compiled.js.replace(
256+
/export default (?!__sfc__)/,
257+
'const __sfc__ = ',
258+
)
259+
}
260+
261+
return errs
262+
}
251263

252264
const resetFiles = () => {
253265
const { files, addFile } = store

0 commit comments

Comments
 (0)