diff --git a/src/index.ts b/src/index.ts index 4d149bf1..325bd340 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ import Vue, { VueConstructor } from 'vue' import { Data, SetupFunction, SetupContext } from './component' -import { currentVue } from './runtimeContext' import { install } from './install' import { mixin } from './setup' @@ -10,17 +9,12 @@ declare module 'vue/types/options' { } } -const _install = (Vue: VueConstructor) => install(Vue, mixin) -const plugin = { - install: _install, -} -// Auto install if it is not done yet and `window` has `Vue`. -// To allow users to avoid auto-installation in some cases, -if (currentVue && typeof window !== 'undefined' && window.Vue) { - _install(window.Vue) +const VueCompositionAPI = { + install: (Vue: VueConstructor) => install(Vue, mixin), } -export default plugin +export default VueCompositionAPI + export { nextTick } from './nextTick' export { default as createElement } from './createElement' export { SetupContext } @@ -40,3 +34,8 @@ export * from './apis/lifecycle' export * from './apis/watch' export * from './apis/computed' export * from './apis/inject' + +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(VueCompositionAPI) +}