Having issues with projects that use Vue2 and do not use the composition api. Do I need to make it compulsory in my package?
See original GitHub issueDiscussed in https://github.com/vueuse/vue-demi/discussions/78
<div type='discussions-op-text'>Originally posted by sduduzog July 23, 2021 Here’s my package.json
{
"name": "vue-supabase",
"version": "1.0.4",
"description": "A small wrapper for integrating supabase to Vuejs",
"main": "index.js",
"engine": {
"node": ">= 1"
},
"scripts": {
"test": "npm run test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/scottrobertson/vue-supabase.git"
},
"keywords": [
"vue",
"custom",
"supabase"
],
"author": "Scott Robertson",
"types": "index.d.ts",
"license": "MIT",
"files": [
"index.js",
"index.d.ts"
],
"bugs": {
"url": "https://github.com/scottrobertson/vue-supabase/issues"
},
"homepage": "https://github.com/scottrobertson/vue-supabase#readme",
"dependencies": {
"@supabase/supabase-js": "^1.4.2",
"vue-demi": "^0.11.2"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0-rc.1",
"vue": "^2.0.0 || >=3.0.0"
}
}
And here’s my index.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const { inject, isVue3 } = require('vue-demi');
const { createClient } = require('@supabase/supabase-js')
const supabaseKey = 'supabase';
function useSupabase(key = null) {
return inject(key !== null ? key : supabaseKey);
}
exports['default'] = {
supabaseKey,
useSupabase,
install: function (app, options) {
const supabase = createClient(options.supabaseUrl, options.supabaseKey, options.supabaseOptions)
app.provide(supabaseKey, supabase);
if (isVue3){
app.config.globalProperties.$supabase = supabase;
} else {
Object.defineProperties(app.prototype, {
$supabase: {
get: function() {
return supabase;
},
},
});
app.supabase = supabase;
}
}
}
module.exports = exports['default'];
This is from a branch of a vue-supabase fork. It works for vite and vue3 but not for Vue2 using @vue/cli to create the project https://github.com/sduduzog/vue-supabase/tree/use-vue-demi </div>
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Having issues with projects that use Vue2 and do not ... - GitHub
Having issues with projects that use Vue2 and do not use the composition api. Do I need to make it compulsory in my...
Read more >Why you should be using Vue's new Composition API
I have quite large Vue 2 projects and never had problems like this. Actually this is why I prefer Vue over React. With...
Read more >Do I have to use the Composition API in Vue 3, or can I still do ...
For some reason, I was thinking that Vue 3 still allowed you to do things the Vue-2 way, using the Options API instead....
Read more >From vue-class-component to Composition API
First of all, we want to convert components. Every Vue component in your current codebase is probably a class, marked with @Component ....
Read more >Vue 3.2 - Using Composition API with Script Setup
If you were using the Options API (the standard of Vue 2), all of your ... When using <script setup> , we don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe someone could fork and maintain one that does not include
@vue/composition-api
- for example,vue-demi-lite
? To me,vue-demi
is designed to be filling the API difference between Vue 2 and Vue 3, in which@vue/composition-api
is necessary.Will definitely consider this… But I’ll wait until it’s a painpoint to at least one user of the package