diff --git a/src/import-map.ts b/src/import-map.ts index 62a27d6d..bc11cd50 100644 --- a/src/import-map.ts +++ b/src/import-map.ts @@ -5,6 +5,7 @@ export function useVueImportMap( runtimeDev?: string | (() => string) runtimeProd?: string | (() => string) serverRenderer?: string | (() => string) + vueVersion?: string | null } = {}, ) { function normalizeDefaults(defaults?: string | (() => string)) { @@ -13,7 +14,7 @@ export function useVueImportMap( } const productionMode = ref(false) - const vueVersion = ref(null) + const vueVersion = ref(defaults.vueVersion || null) const importMap = computed(() => { const vue = (!vueVersion.value && diff --git a/src/store.ts b/src/store.ts index 556c7717..195c2ccf 100644 --- a/src/store.ts +++ b/src/store.ts @@ -18,7 +18,7 @@ import type { } from 'vue/compiler-sfc' import type { OutputModes } from './types' import type { editor } from 'monaco-editor-core' -import { type ImportMap, mergeImportMap } from './import-map' +import { type ImportMap, mergeImportMap, useVueImportMap } from './import-map' import welcomeSFCCode from './template/welcome.vue?raw' import newSFCCode from './template/new-sfc.vue?raw' @@ -35,7 +35,7 @@ export function useStore( welcomeSFC: welcomeSFCCode, newSFC: newSFCCode, }), - builtinImportMap = ref({}), + builtinImportMap = undefined!, // set later errors = ref([]), showOutput = ref(false), @@ -51,6 +51,11 @@ export function useStore( }: Partial = {}, serializedState?: string, ): ReplStore { + if (!builtinImportMap) { + ;({ importMap: builtinImportMap, vueVersion } = useVueImportMap({ + vueVersion: vueVersion.value, + })) + } const loading = ref(false) function applyBuiltinImportMap() {