Skip to content

Commit

Permalink
feat: provide fs option to support 3.3 external type resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 13, 2023
1 parent 842ccc2 commit f0e826a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/Repl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,26 @@ const props = withDefaults(defineProps<Props>(), {
ssr: false
})
props.store.options = props.sfcOptions
props.store.init()
const { store } = props
const sfcOptions = (store.options = props.sfcOptions || {})
if (!sfcOptions.script) {
sfcOptions.script = {}
}
// @ts-ignore only needed in 3.3
sfcOptions.script.fs = {
fileExists(file: string) {
if (file.startsWith('/')) file = file.slice(1)
return !!store.state.files[file]
},
readFile(file: string) {
if (file.startsWith('/')) file = file.slice(1)
return store.state.files[file].code
}
}
store.init()
provide('store', props.store)
provide('store', store)
provide('autoresize', props.autoResize)
provide('import-map', toRef(props, 'showImportMap'))
provide('clear-console', toRef(props, 'clearConsole'))
Expand Down

0 comments on commit f0e826a

Please sign in to comment.