Skip to content

Commit c74673f

Browse files
committed
fix: add vue import maps for default import map
1 parent c8887d6 commit c74673f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/import-map.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function useVueImportMap(
55
runtimeDev?: string | (() => string)
66
runtimeProd?: string | (() => string)
77
serverRenderer?: string | (() => string)
8+
vueVersion?: string | null
89
} = {},
910
) {
1011
function normalizeDefaults(defaults?: string | (() => string)) {
@@ -13,7 +14,7 @@ export function useVueImportMap(
1314
}
1415

1516
const productionMode = ref(false)
16-
const vueVersion = ref<string | null>(null)
17+
const vueVersion = ref<string | null>(defaults.vueVersion || null)
1718
const importMap = computed<ImportMap>(() => {
1819
const vue =
1920
(!vueVersion.value &&

src/store.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {
1818
} from 'vue/compiler-sfc'
1919
import type { OutputModes } from './types'
2020
import type { editor } from 'monaco-editor-core'
21-
import { type ImportMap, mergeImportMap } from './import-map'
21+
import { type ImportMap, mergeImportMap, useVueImportMap } from './import-map'
2222

2323
import welcomeSFCCode from './template/welcome.vue?raw'
2424
import newSFCCode from './template/new-sfc.vue?raw'
@@ -35,7 +35,7 @@ export function useStore(
3535
welcomeSFC: welcomeSFCCode,
3636
newSFC: newSFCCode,
3737
}),
38-
builtinImportMap = ref({}),
38+
builtinImportMap = undefined!, // set later
3939

4040
errors = ref([]),
4141
showOutput = ref(false),
@@ -51,6 +51,11 @@ export function useStore(
5151
}: Partial<StoreState> = {},
5252
serializedState?: string,
5353
): ReplStore {
54+
if (!builtinImportMap) {
55+
;({ importMap: builtinImportMap, vueVersion } = useVueImportMap({
56+
vueVersion: vueVersion.value,
57+
}))
58+
}
5459
const loading = ref(false)
5560

5661
function applyBuiltinImportMap() {

0 commit comments

Comments
 (0)