Skip to content

Commit

Permalink
feat: Vue version warning in dev mode (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 30, 2020
1 parent 5f23886 commit 0840aa8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -68,7 +68,7 @@
"vue-server-renderer": "^2.6.11"
},
"peerDependencies": {
"vue": "^2.5.22"
"vue": ">= 2.5 < 3"
},
"dependencies": {
"tslib": "^2.0.0"
Expand Down
11 changes: 10 additions & 1 deletion src/install.ts
Expand Up @@ -46,12 +46,21 @@ export function install(
if (__DEV__) {
assert(
false,
'already installed. Vue.use(plugin) should be called only once'
'already installed. Vue.use(VueCompositionAPI) should be called only once.'
)
}
return
}

if (__DEV__) {
if (!Vue.version.startsWith('2.')) {
assert(
false,
`@vue/composition-api only works with Vue 2, v${Vue.version} found.`
)
}
}

Vue.config.optionMergeStrategies.setup = function (
parent: Function,
child: Function
Expand Down
5 changes: 4 additions & 1 deletion src/runtimeContext.ts
Expand Up @@ -7,7 +7,10 @@ let currentVM: ComponentInstance | null = null

export function getCurrentVue(): VueConstructor {
if (__DEV__) {
assert(currentVue, `must call Vue.use(plugin) before using any function.`)
assert(
currentVue,
`must call Vue.use(VueCompositionAPI) before using any function.`
)
}

return currentVue!
Expand Down

0 comments on commit 0840aa8

Please sign in to comment.