Skip to content

Commit f0e826a

Browse files
committed
feat: provide fs option to support 3.3 external type resolving
1 parent 842ccc2 commit f0e826a

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/Repl.vue

+19-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,26 @@ const props = withDefaults(defineProps<Props>(), {
2525
ssr: false
2626
})
2727
28-
props.store.options = props.sfcOptions
29-
props.store.init()
28+
const { store } = props
29+
const sfcOptions = (store.options = props.sfcOptions || {})
30+
if (!sfcOptions.script) {
31+
sfcOptions.script = {}
32+
}
33+
// @ts-ignore only needed in 3.3
34+
sfcOptions.script.fs = {
35+
fileExists(file: string) {
36+
if (file.startsWith('/')) file = file.slice(1)
37+
return !!store.state.files[file]
38+
},
39+
readFile(file: string) {
40+
if (file.startsWith('/')) file = file.slice(1)
41+
return store.state.files[file].code
42+
}
43+
}
44+
45+
store.init()
3046
31-
provide('store', props.store)
47+
provide('store', store)
3248
provide('autoresize', props.autoResize)
3349
provide('import-map', toRef(props, 'showImportMap'))
3450
provide('clear-console', toRef(props, 'clearConsole'))

0 commit comments

Comments
 (0)