Skip to content

Commit

Permalink
fix: warn versions that do not support in browser SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 25, 2022
1 parent 5e89f07 commit 01cb5b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/output/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@ async function updatePreview() {
runtimeError.value = null
runtimeWarning.value = null
const isSSR = props.ssr
let isSSR = props.ssr
if (store.vueVersion) {
const [_, minor, patch] = store.vueVersion.split('.')
if (parseInt(minor, 10) < 2 || parseInt(patch, 10) < 27) {
alert(
`The selected version of Vue (${store.vueVersion}) does not support in-browser SSR.` +
` Rendering in client mode instead.`
)
isSSR = false
}
}
try {
const mainFile = store.state.mainFile
Expand Down
4 changes: 4 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface Store {
state: StoreState
options?: SFCOptions
compiler: typeof defaultCompiler
vueVersion?: string
init: () => void
setActive: (filename: string) => void
addFile: (filename: string | File) => void
Expand All @@ -81,6 +82,7 @@ export interface StoreOptions {
export class ReplStore implements Store {
state: StoreState
compiler = defaultCompiler
vueVersion?: string
options?: SFCOptions
initialShowOutput: boolean
initialOutputMode: OutputModes
Expand Down Expand Up @@ -240,6 +242,7 @@ export class ReplStore implements Store {
}

async setVueVersion(version: string) {
this.vueVersion = version
const compilerUrl = `https://unpkg.com/@vue/compiler-sfc@${version}/dist/compiler-sfc.esm-browser.js`
const runtimeUrl = `https://unpkg.com/@vue/runtime-dom@${version}/dist/runtime-dom.esm-browser.js`
const ssrUrl = `https://unpkg.com/@vue/server-renderer@${version}/dist/server-renderer.esm-browser.js`
Expand All @@ -257,6 +260,7 @@ export class ReplStore implements Store {
}

resetVueVersion() {
this.vueVersion = undefined
this.compiler = defaultCompiler
this.state.vueRuntimeURL = this.defaultVueRuntimeURL
this.state.vueServerRendererURL = this.defaultVueServerRendererURL
Expand Down

0 comments on commit 01cb5b2

Please sign in to comment.