Skip to content

Commit 0840aa8

Browse files
authoredJun 30, 2020
feat: Vue version warning in dev mode (#408)
1 parent 5f23886 commit 0840aa8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"vue-server-renderer": "^2.6.11"
6969
},
7070
"peerDependencies": {
71-
"vue": "^2.5.22"
71+
"vue": ">= 2.5 < 3"
7272
},
7373
"dependencies": {
7474
"tslib": "^2.0.0"

‎src/install.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,21 @@ export function install(
4646
if (__DEV__) {
4747
assert(
4848
false,
49-
'already installed. Vue.use(plugin) should be called only once'
49+
'already installed. Vue.use(VueCompositionAPI) should be called only once.'
5050
)
5151
}
5252
return
5353
}
5454

55+
if (__DEV__) {
56+
if (!Vue.version.startsWith('2.')) {
57+
assert(
58+
false,
59+
`@vue/composition-api only works with Vue 2, v${Vue.version} found.`
60+
)
61+
}
62+
}
63+
5564
Vue.config.optionMergeStrategies.setup = function (
5665
parent: Function,
5766
child: Function

‎src/runtimeContext.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ let currentVM: ComponentInstance | null = null
77

88
export function getCurrentVue(): VueConstructor {
99
if (__DEV__) {
10-
assert(currentVue, `must call Vue.use(plugin) before using any function.`)
10+
assert(
11+
currentVue,
12+
`must call Vue.use(VueCompositionAPI) before using any function.`
13+
)
1114
}
1215

1316
return currentVue!

0 commit comments

Comments
 (0)
Please sign in to comment.