vuejs / composition-api

Composition API plugin for Vue 2
https://composition-api.vuejs.org/
MIT License
4.19k stars 342 forks source link

Version 1.2.0 and 1.2.1 give runtime error at startup #815

Closed GeekyMonkey closed 3 years ago

GeekyMonkey commented 3 years ago

Version 1.1.5 is fine. But updating to either 1.2.0 or 1.2.1 results in the errors below at startup despite having this loaded in Main.ts. The console log message is displayed before the errors are displayed.

import VueCompositionAPI from "@vue/composition-api";
import Vue from "vue";

console.log("Composition API init");
Vue.use(VueCompositionAPI);

Startup errors:

vue.runtime.esm.js:619 [Vue warn]: Error in mounted hook (Promise/async): "Error: [vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function."

found in

---> <App> at src/App.vue
       <Root>
warn @ vue.runtime.esm.js:619
logError @ vue.runtime.esm.js:1893
globalHandleError @ vue.runtime.esm.js:1888
handleError @ vue.runtime.esm.js:1848
(anonymous) @ vue.runtime.esm.js:1865
Promise.catch (async)
invokeWithErrorHandling @ vue.runtime.esm.js:1865
callHook @ vue.runtime.esm.js:4235
insert @ vue.runtime.esm.js:3158
invokeInsertHook @ vue.runtime.esm.js:6390
patch @ vue.runtime.esm.js:6609
Vue._update @ vue.runtime.esm.js:3960
updateComponent @ vue.runtime.esm.js:4081
get @ vue.runtime.esm.js:4495
Watcher @ vue.runtime.esm.js:4484
mountComponent @ vue.runtime.esm.js:4088
push../node_modules/vue/dist/vue.runtime.esm.js.Vue.$mount @ vue.runtime.esm.js:8459
./src/main.ts @ main.ts:35
__webpack_require__ @ bootstrap:858
fn @ bootstrap:150
1 @ Logout.vue?4cf0:1
__webpack_require__ @ bootstrap:858
checkDeferredModules @ bootstrap:45
(anonymous) @ bootstrap:1039
(anonymous) @ bootstrap:1039
vue.runtime.esm.js:1897 Error: [vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function.
    at assert (vue-composition-api.esm.js:34)
    at getVueConstructor (vue-composition-api.esm.js:315)
    at getWatcherVM (vue-composition-api.esm.js:1132)
    at watch (vue-composition-api.esm.js:1397)
    at index.esm.js:779
    at new Promise (<anonymous>)
    at toMatch (index.esm.js:778)
    at Object.toBeTruthy (index.esm.js:802)
    at App.ts:254
antfu commented 3 years ago

Can you share a minimal reproduction? Thanks.

dragomirweb commented 3 years ago

I get the exact same error running : @vue/composition-api": "1.2.1 vue": "^2.6.10"

dragomirweb commented 3 years ago

reproduction: updated from 1.0.5 to 1.2.1 no compilation error app throws [vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function.

Shinigami92 commented 3 years ago

I'm also affected by this

image

Ttou commented 3 years ago

got same error

微信截图_20210923100421

antfu commented 3 years ago

Can't really help without reproduction

Ttou commented 3 years ago

@antfu maybe @vueuse/core cause this error

微信截图_20210923140311

mokone91 commented 3 years ago

Same issue but with different message image v1.1.5 works fine

a bit more info: we have application (vue2 + @vue/compositon-api) and 2 libs with different build process first use vue2 + vue-demi and it works second use vue2 + @vue/compositon-api which externalised by webpack5 'externals' and it doesn't work

for now issue fixed by downgrading @vue/compositon-api on app side to 1.1.5

RPainter8West commented 3 years ago

Back in business! Thanks!

Shinigami92 commented 3 years ago

Yes, everything working again :slightly_smiling_face: thx