Gathering detailed insights and metrics for vue-demi
Gathering detailed insights and metrics for vue-demi
Gathering detailed insights and metrics for vue-demi
Gathering detailed insights and metrics for vue-demi
v-code-diff
template component for vue-demi, can dev and build
sy-assistant
本项目基于[Vue-demi](https://github.com/vue-demi/vue-demi),可以同时兼容Vue2和Vue3。
vue-inbrowser-compiler-demi
use this with vue-inbrowser-compiler to compile for vue2 or vue3
universal-panduan-oss
- Building Universal Vue Libraries panduan for Vue 2 & 3 - Using vue-demi but you don't need to write "render" function, "template" and "tsx" are supported!
npm install vue-demi
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,014 Stars
210 Commits
158 Forks
27 Watching
1 Branches
60 Contributors
Updated on 26 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-1%
925,169
Compared to previous day
Last week
1.4%
4,730,602
Compared to previous week
Last month
12.6%
19,868,058
Compared to previous month
Last year
104.2%
185,136,388
Compared to previous year
2
Vue Demi (half in French) is a developing utility
allows you to write Universal Vue Libraries for Vue 2 & 3
See more details in this blog post
<=2.6
: exports from vue
+ @vue/composition-api
with plugin auto installing.2.7
: exports from vue
(Composition API is built-in in Vue 2.7).>=3.0
: exports from vue
, with polyfill of Vue 2's set
and del
API.Install this as your plugin's dependency:
1npm i vue-demi 2# or 3yarn add vue-demi 4# or 5pnpm i vue-demi
Add vue
and @vue/composition-api
to your plugin's peer dependencies to specify what versions you support.
1{ 2 "dependencies": { 3 "vue-demi": "latest" 4 }, 5 "peerDependencies": { 6 "@vue/composition-api": "^1.0.0-rc.1", 7 "vue": "^2.0.0 || >=3.0.0" 8 }, 9 "peerDependenciesMeta": { 10 "@vue/composition-api": { 11 "optional": true 12 } 13 }, 14 "devDependencies": { 15 "vue": "^3.0.0" // or "^2.6.0" base on your preferred working environment 16 }, 17}
Import everything related to Vue from it, it will redirect to vue@2
+ @vue/composition-api
or vue@3
based on users' environments.
1import { ref, reactive, defineComponent } from 'vue-demi'
Publish your plugin and all is done!
When using with Vite, you will need to opt-out the pre-bundling to get
vue-demi
work properly by1// vite.config.js 2export default defineConfig({ 3 optimizeDeps: { 4 exclude: ['vue-demi'] 5 } 6})
Vue Demi
provides extra APIs to help distinguish users' environments and to do some version-specific logic.
isVue2
isVue3
1import { isVue2, isVue3 } from 'vue-demi' 2 3if (isVue2) { 4 // Vue 2 only 5} else { 6 // Vue 3 only 7}
Vue2
To avoid bringing in all the tree-shakable modules, we provide a Vue2
export to support access to Vue 2's global API. (See #41.)
1import { Vue2 } from 'vue-demi' 2 3if (Vue2) { 4 Vue2.config.ignoredElements.push('x-foo') 5}
install()
Composition API in Vue 2 is provided as a plugin and needs to be installed on the Vue instance before using. Normally, vue-demi
will try to install it automatically. For some usages where you might need to ensure the plugin gets installed correctly, the install()
API is exposed to as a safe version of Vue.use(CompositionAPI)
. install()
in the Vue 3 environment will be an empty function (no-op).
1import { install } from 'vue-demi' 2 3install()
To explicitly switch the redirecting version, you can use these commands in your project's root.
1npx vue-demi-switch 2 2# or 3npx vue-demi-switch 3
If you would like to import vue
under an alias, you can use the following command
1npx vue-demi-switch 2 vue2 2# or 3npx vue-demi-switch 3 vue3
Then vue-demi
will redirect APIs from the alias name you specified, for example:
1import * as Vue from 'vue3' 2 3var isVue2 = false 4var isVue3 = true 5var Vue2 = undefined 6 7export * from 'vue3' 8export { 9 Vue, 10 Vue2, 11 isVue2, 12 isVue3, 13}
If the postinstall
hook doesn't get triggered or you have updated the Vue version, try to run the following command to resolve the redirecting.
1npx vue-demi-fix
You can support testing for both versions by adding npm alias in your dev dependencies. For example:
1{ 2 "scripts": { 3 "test:2": "vue-demi-switch 2 vue2 && jest", 4 "test:3": "vue-demi-switch 3 && jest", 5 }, 6 "devDependencies": { 7 "vue": "^3.0.0", 8 "vue2": "npm:vue@2" 9 }, 10}
or
1{ 2 "scripts": { 3 "test:2": "vue-demi-switch 2 && jest", 4 "test:3": "vue-demi-switch 3 vue3 && jest", 5 }, 6 "devDependencies": { 7 "vue": "^2.6.0", 8 "vue3": "npm:vue@3" 9 }, 10}
See examples.
open a PR to add your library ;)
See the blog post.
MIT License © 2020 Anthony Fu
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 14/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More