Skip to content

Commit

Permalink
fix: add vue import maps for default import map
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 14, 2024
1 parent c8887d6 commit c74673f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/import-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function useVueImportMap(
runtimeDev?: string | (() => string)
runtimeProd?: string | (() => string)
serverRenderer?: string | (() => string)
vueVersion?: string | null
} = {},
) {
function normalizeDefaults(defaults?: string | (() => string)) {
Expand All @@ -13,7 +14,7 @@ export function useVueImportMap(
}

const productionMode = ref(false)
const vueVersion = ref<string | null>(null)
const vueVersion = ref<string | null>(defaults.vueVersion || null)
const importMap = computed<ImportMap>(() => {
const vue =
(!vueVersion.value &&
Expand Down
9 changes: 7 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -35,7 +35,7 @@ export function useStore(
welcomeSFC: welcomeSFCCode,
newSFC: newSFCCode,
}),
builtinImportMap = ref({}),
builtinImportMap = undefined!, // set later

errors = ref([]),
showOutput = ref(false),
Expand All @@ -51,6 +51,11 @@ export function useStore(
}: Partial<StoreState> = {},
serializedState?: string,
): ReplStore {
if (!builtinImportMap) {
;({ importMap: builtinImportMap, vueVersion } = useVueImportMap({
vueVersion: vueVersion.value,
}))
}
const loading = ref(false)

function applyBuiltinImportMap() {
Expand Down

0 comments on commit c74673f

Please sign in to comment.