Skip to content

Commit

Permalink
fix(playground): fix import map in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Oct 11, 2023
1 parent c0b16ea commit d578a2b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
34 changes: 18 additions & 16 deletions packages/online-playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Header from './Header.vue'
import { Repl, ReplStore, SFCOptions, ReplProps } from '@vue/repl'
import Monaco from '@vue/repl/monaco-editor'
import { ref, watchEffect, onMounted, inject, provide, onUnmounted } from 'vue'
import { ref, watchEffect, onMounted, provide } from 'vue'
import { AppVue, PiniaVersionKey, counterTs } from './defaults'
const setVH = () => {
Expand Down Expand Up @@ -56,30 +56,32 @@ provide(PiniaVersionKey, piniaVersion)
// piniaVersion.value === 'latest' ? '^2.1.0' : piniaVersion.value
// })
console.log('files', store.getFiles()['import-map.json'])
if (!hash) {
store.setImportMap({
imports: {
...store.getImportMap().imports,
pinia: import.meta.env.PROD
? `${location.origin}/'pinia.esm-browser.js'`
? `${location.origin}/pinia.esm-browser.js`
: `${location.origin}/src/pinia-dev-proxy`,
...(import.meta.env.PROD
? {
'@vue/devtools-api':
'https://cdn.jsdelivr.net/npm/@vue/[email protected]/lib/esm/index.js',
'vue-demi':
'https://cdn.jsdelivr.net/npm/[email protected]/lib/v3/index.mjs',
}
: {}),
},
})
store
.setFiles({
// gets the tsconfig and import map
...store.getFiles(),
'App.vue': AppVue,
'counter.ts': counterTs,
})
.then(() => {
console.log(store.state.mainFile)
})
// store.setFiles({}, 'main.ts').then(() => {
// console.log('done')
// })
store.setFiles({
// gets the tsconfig and import map
...store.getFiles(),
'App.vue': AppVue,
'counter.ts': counterTs,
})
}
// persist state
Expand Down
4 changes: 2 additions & 2 deletions packages/online-playground/src/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function toggleDark() {
<VersionSelect
v-model="store.state.typescriptVersion"
pkg="typescript"
label="TypeScript Version"
label="TypeScript"
/>
<!-- <VersionSelect
:model-value="vueVersion"
Expand All @@ -87,7 +87,7 @@ function toggleDark() {
:model-value="store.vueVersion || 'latest'"
@update:model-value="setVueVersion"
pkg="vue"
label="Vue Version"
label="Vue"
/>
<button
title="Toggle development production mode"
Expand Down

0 comments on commit d578a2b

Please sign in to comment.