Socket
Socket
Sign inDemoInstall

vue-demi

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-demi - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

2

package.json
{
"name": "vue-demi",
"version": "0.5.0",
"version": "0.5.1",
"main": "lib/index.cjs.js",

@@ -5,0 +5,0 @@ "typings": "lib/index.d.ts",

@@ -77,4 +77,6 @@ <p align="center">

### CLI
## CLI
### Manually Switch Versions
To explicitly switch the redirecting version, you can use these commands in your project's root.

@@ -88,2 +90,30 @@

### Package Aliasing
If you would like to import `vue` under an alias, you can use the following command
```bash
npx vue-demi-switch 2 vue2
# or
npx vue-demi-switch 3 vue3
```
Then `vue-demi` will redirect APIs from the alias name you specified, for example:
```ts
import * as Vue from 'vue3'
var isVue2 = false
var isVue3 = true
export * from 'vue3'
export {
Vue,
isVue2,
isVue3,
}
```
### Auto Fix
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.

@@ -90,0 +120,0 @@

const switchVersion = require('./switch')
const version = process.argv[2]
const vueEntry = process.argv[3] || 'vue'
if (version == '2') {
switchVersion(2)
console.log(`[vue-demi] Switched for Vue 2`)
switchVersion(2, vueEntry)
console.log(`[vue-demi] Switched for Vue 2 (entry: "${vueEntry}")`)
} else if (version == '3') {
switchVersion(3)
console.log(`[vue-demi] Switched for Vue 3`)
switchVersion(3, vueEntry)
console.log(`[vue-demi] Switched for Vue 3 (entry: "${vueEntry}")`)
} else {

@@ -12,0 +13,0 @@ console.warn(`[vue-demi] expecting version "2" or "3" but got "${version}"`)

const fs = require('fs')
const path = require('path')
const dir = path.resolve(__dirname, '..')
const dir = path.resolve(__dirname, '..', 'lib')
module.exports = function switchVersion(version) {
fs.writeFileSync(path.join(dir, 'lib', 'index.cjs.js'), `module.exports = require('./v${version}/index.cjs')\n`, 'utf-8')
fs.writeFileSync(path.join(dir, 'lib', 'index.esm.js'), `export * from './v${version}/index.esm'\n`, 'utf-8')
fs.writeFileSync(path.join(dir, 'lib', 'index.d.ts'), `export * from './v${version}/index'\n`, 'utf-8')
function copy(name, version, vue) {
vue = vue || 'vue'
const src = path.join(dir, `v${version}`, name)
const dest = path.join(dir, name)
let content = fs.readFileSync(src, 'utf-8')
content = content.replace(/'vue'/g, `'${vue}'`)
fs.writeFileSync(dest, content, 'utf-8')
}
module.exports = function switchVersion(version, vue) {
copy('index.cjs.js', version, vue)
copy('index.esm.js', version, vue)
copy('index.d.ts', version, vue)
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc