Skip to content

Commit

Permalink
refactor: drop vue-demi dependency (for now)
Browse files Browse the repository at this point in the history
using vue-demi requires that vue2.6 projects install "@vue/composition-api", always! Even though I believe is the norm in 2.6.x projects but still kind of bummer to get an install error. vue-demi lists @vue/composition-api as optional peer dependency because it would otherwise install it for vue2.7 and vue3.x projects. We could list @vue/composition-api as dependency as well to overcome the install issue, but we're not using anything on this package so why complicate things?

1. I've removed vue-demi altogether, replaced the only thing we've use isVue3 with simply version regexp
1. the swap-vue.js from vuelidate allow us to keep the isomorphic testing to ensure it works everything

Related issues:
vueuse/vue-demi#67
vueuse/vue-demi#7
  • Loading branch information
renatodeleao committed Jul 19, 2022
1 parent bf48f43 commit a8b3def
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
22 changes: 9 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"format:staged": "pretty-quick --staged",
"release": "np",
"version": "npm run build",
"use-vue:2": "node scripts/swap-vue.js 2 && vue-demi-switch 2",
"use-vue:3": "node scripts/swap-vue.js 3 && vue-demi-switch 3"
"use-vue:2": "node scripts/swap-vue.js 2",
"use-vue:3": "node scripts/swap-vue.js 3"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -68,16 +68,7 @@
"engines": {
"node": ">=6"
},
"dependencies": {
"vue-demi": "^0.13.2"
},
"peerDependencies": {
"@vue/composition-api": "^1.0.0",
"vue": "^2.6.0 || >=3.2.0"
},
"peerDependenciesMeta": {
"@vue/composition-api": {
"optional": true
}
}
}
8 changes: 7 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { isVue3 } from 'vue-demi'
// vue vue3.x has named export, vue 2.6 has not
// modern import Vue, { version } from 'vue' gives "export 'version' was not
// found in 'vue'" warnings, so inline require call was used
// eslint-disable-next-line
const version = require('vue').version || require('vue').default.version

export const isVue3 = /^3\./.test(version)

// eslint-disable-next-line
export const directiveHooks = {
Expand Down
2 changes: 1 addition & 1 deletion test/test-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { isVue3 } = require('vue-demi')
const { isVue3 } = require('../src/utils')

const lifecycleInstanceMethods = {
unmount: isVue3 ? 'unmount' : 'destroy',
Expand Down

0 comments on commit a8b3def

Please sign in to comment.