\r\n \u003C/button>\r\n \u003C/label>\r\n\u003C/template>\r\n```\r\n\r\nBuild output:\r\n```js\r\nimport { defineComponent, ref, openBlock, createElementBlock, createTextVNode, toDisplayString, createElementVNode, mergeProps, renderSlot } from \"vue\";\r\nconst _sfc_main = /* @__PURE__ */ defineComponent({\r\n props: {\r\n label: {\r\n type: String,\r\n default: \"\"\r\n }\r\n },\r\n setup(__props) {\r\n const counter = ref(0);\r\n return (_ctx, _cache) => {\r\n return openBlock(), createElementBlock(\"label\", null, [\r\n createTextVNode(toDisplayString(__props.label) + \" \" + toDisplayString(counter.value) + \" \", 1),\r\n createElementVNode(\"button\", mergeProps(_ctx.$attrs, {\r\n onClick: _cache[0] || (_cache[0] = ($event) => counter.value++)\r\n }), [\r\n renderSlot(_ctx.$slots, \"default\")\r\n ], 16)\r\n ]);\r\n };\r\n }\r\n});\r\nexport { _sfc_main as BaseButton };\r\n```\r\n\r\nIn Vue 2 I run into `Uncaught TypeError: Object(...) is not a function` error with `defineComponent()`. I suppose it should be importing from \"vue-demi\" instead of \"vue\"?\r\n\r\nPackage.json\r\n```json\r\n\"dependencies\": {\r\n \"vue-demi\": \"^0.12.4\"\r\n },\r\n \"devDependencies\": {\r\n \"@types/node\": \"^17.0.21\",\r\n \"@vitejs/plugin-vue\": \"^2.2.0\",\r\n \"@vue/composition-api\": \"^1.4.9\",\r\n \"typescript\": \"^4.5.4\",\r\n \"vite\": \"^2.8.0\",\r\n \"vue\": \"^3.2.25\",\r\n \"vue-tsc\": \"^0.29.8\"\r\n },\r\n \"peerDependencies\": {\r\n \"@vue/composition-api\": \"^1.0.0-rc.1\",\r\n \"vue\": \"^2.0.0 || >=3.0.0\"\r\n },\r\n \"peerDependenciesMeta\": {\r\n \"@vue/composition-api\": {\r\n \"optional\": true\r\n }\r\n },\r\n```\r\n\r\nvite.config.ts\r\n```ts\r\nexport default defineConfig({\r\n plugins: [vue()],\r\n build: {\r\n lib: {\r\n entry: path.resolve(__dirname, \"src/lib.ts\"),\r\n name: \"myLib\",\r\n fileName: (format) => `lib.${format}.js`,\r\n },\r\n rollupOptions: {\r\n // make sure to externalize deps that shouldn't be bundled\r\n // into your library\r\n external: [\"vue\"],\r\n output: {\r\n // Provide global variables to use in the UMD build\r\n // for externalized deps\r\n globals: {\r\n vue: \"Vue\",\r\n },\r\n },\r\n },\r\n },\r\n optimizeDeps: {\r\n exclude: [\"vue-demi\"],\r\n },\r\n});\r\n```",[],145,"Not running on Vue 2 App","2022-09-04T15:48:05Z","https://github.com/vueuse/vue-demi/issues/145",0.68907243,{"description":2916,"labels":2917,"number":1600,"owner":2868,"repository":2869,"state":2887,"title":2918,"updated_at":2919,"url":2920,"score":2921},"Hello @antfu ,\r\n\r\nI am currently working on a SPA using `vue2` + `options-api` . This SPA imports another component library (`vue2` + `@vue/composition-api`), which simply exposes a single vue component. The component library also uses `@vueuse/core` using `vue-demi`.\r\n\r\nHere's an example of the exported component of the library (can not share everything since it's an company internal project)\r\n```vue\r\n\u003Ctemplate>\r\n \u003Cdiv>\r\n \u003Cp>FOO: {{ blub }}\u003C/p> \u003C!-- will stay false -->\r\n \u003Cbutton @click.stop=\"click\">CLICK ME\u003C/button>\r\n \u003C/div>\r\n\u003C/template>\r\n\r\n\u003Cscript>\r\nimport { defineComponent, ref } from \"@vue/composition-api\"\r\nimport { useLocalStorage } from \"@vueuse/core\"\r\n\r\nexport default defineComponent({\r\n setup: (props) => {\r\n const foo = ref(false)\r\n\r\n const storageLocale = useLocalStorage(\"some_key\", \"en-GB\", {\r\n listenToStorageChanges: true,\r\n window,\r\n })\r\n\r\n return {\r\n foo,\r\n click: () => {\r\n console.log(\"before click\", foo.value)\r\n foo.value = true\r\n console.log(\"after click\", foo.value) // \u003C-- will be true\r\n },\r\n }\r\n },\r\n})\r\n\u003C/script>\r\n```\r\n\r\nSo basically everything works pretty good. But as soon as I add the `useLocalStorage` or any other composable from `@vueuse/core`, the template will not re-render as soon as the button was clicked. The ref value itself works, only the template does not update. I did a lot of debugging together with my colleague, and we figured out that the template will update, as soon as we get rid of all `vue-demi` based code.\r\n\r\nDependencies of the SPA:\r\n```json\r\n\"dependencies\": {\r\n \"vue\": \"^2.6.10\",\r\n \"@company/components\": \"1.0.0\",\r\n \"@vue/composition-api\": \"1.0.0-beta.25\"\r\n},\r\n\"devDependencies\": {\r\n ... all other\r\n}\r\n``` \r\nDependencies of the ComponentLibrary: \r\n```json\r\n\"dependencies\": {\r\n \"@vueuse/core\": \"4.0.10\"\r\n},\r\n\"devDependencies\": {\r\n \"vue\": \"^2.6.10\",\r\n \"@vue/composition-api\": \"1.0.0-beta.25\"\r\n ... all other\r\n}\r\n```\r\n\r\nDo you know what could be the issue here?\r\n\r\nKind regards,\r\nLukas",[],"vue-demi breaks composition-api template re-rendering (vue2)","2021-02-06T14:34:10Z","https://github.com/vueuse/vue-demi/issues/35",0.6916529,{"description":2923,"labels":2924,"number":2925,"owner":2868,"repository":2869,"state":2887,"title":2926,"updated_at":2927,"url":2928,"score":2929},"I have encountered an error when compiling a library to `cjs` format and using it with Vue2.\r\nError:\r\n```js\r\nUncaught TypeError: _vue.use is not a function\r\n at install (index.cjs.js:8)\r\n at index.cjs.js:14\r\n at chunk-4I6LKIR4.js?v=1e7b36e0:6\r\n at match-sorter.esm.js:441\r\n at chunk-4I6LKIR4.js?v=1e7b36e0:6\r\n at index.js:12\r\n at chunk-4I6LKIR4.js?v=1e7b36e0:6\r\n at dep:vue-query_devtools:1\r\n```\r\n\r\n\r\nAs seen on the screenshot Vue2 provides default export, which is only used on compositionApi currently, but not with the Vue itself.\r\n\r\nI can fix said error by changing line 5\r\nfrom : `_vue = _vue || Vue`\r\nto: `_vue = _vue.default || _vue || Vue.default || Vue`\r\n\r\nReproduction steps:\r\n- clone vue-query repo: https://github.com/DamianOsipiuk/vue-query\r\n- `npm i`\r\n- `npm pack` (npm link does not work somehow, there is a different error when using it which is not connected)\r\n- `cd examples/basic-vue-2.x/`\r\n- `npm i`\r\n- extract result of `npm pack` to example node_modules\r\n- `npm run dev`\r\n\r\nAm I missing some configuration part, or is it a real issue?\r\nI can provide a PR if necessary with the mentioned fix.",[],62,"TypeError when trying to use vue-demi with vue2 and cjs","2021-05-05T23:37:21Z","https://github.com/vueuse/vue-demi/issues/62",0.6942385,{"description":2931,"labels":2932,"number":2933,"owner":2868,"repository":2869,"state":2887,"title":2934,"updated_at":2935,"url":2936,"score":2937},"Problem\r\n---\r\n\r\nThe newly introduced setup helper `useSlots` and `useAttrs` was add in VCA with version `1.1.2`\r\nBut the current `vue-demi` peerDependencies still requiring outdated `^1.0.0-rc.1`\r\n\r\n\r\nReproduce\r\n---\r\n\r\n**npm**: `0.7.x` (for auto peer install)\r\n**node**: `14.x.x LTS`\r\n**vue-demi**: `0.11.3`\r\n**@vue/composition-api**: `1.1.1` (installed automatedly by npm@7 before)\r\n\r\n```text\r\n error in ./node_modules/vue-demi/lib/index.mjs\r\n\"export 'useAttrs' was not found in '@vue/composition-api/dist/vue-composition-api.esm.js'\r\n error in ./node_modules/vue-demi/lib/index.mjs\r\n\"export 'useSlots' was not found in '@vue/composition-api/dist/vue-composition-api.esm.js'\r\n```\r\n\r\n** Notice that VCA `1.1.1` is still legit for `^1.0.0-rc.1`\r\n\r\n\r\nPotential Solution\r\n---\r\nupdate `package.json` for VCA to `\"@vue/composition-api\": \"^1.1.2\",`",[],95,"Outdated Dependency: update package.json for composition api","2021-08-23T09:58:59Z","https://github.com/vueuse/vue-demi/issues/95",0.6970822,{"description":2939,"labels":2940,"number":2941,"owner":2868,"repository":2869,"state":2887,"title":2942,"updated_at":2943,"url":2944,"score":2945},"After upgrading to vue-demi \"^0.12.1\",\r\n\r\nI have \"[vue-composition-api] must call Vue.use(VueCompositionAPI) before using any function.\" all over the place.\r\nI tried to solve with https://stackoverflow.com/questions/69846717/vue2-and-composition-api-cannot-import-store-error-vue-composition-api-must, but with no success.\r\n\r\nThis upgrade was triggered by the upgrade \"@vue/apollo-composable\", from \"^4.0.0-alpha.15\" to \"^4.0.0-alpha.16\"\r\n\r\nMy current setup:\r\n \"@vue/apollo-composable\": \"^4.0.0-alpha.15\",\r\nvue-demi \"^0.11.4\"\r\n\r\nis not having any issues\r\n",[],127,"Issue with compositionApi","2022-01-26T12:53:52Z","https://github.com/vueuse/vue-demi/issues/127",0.69792885,["Reactive",2947],{},["Set"],["ShallowReactive",2950],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fUQ9FWrTdWe3G_Wj8HyM2ROjARLy1SRgokVA6n83MJog":-1},"/vueuse/vue-demi/79"]