上传代码
This commit is contained in:
19
uniapp04/node_modules/vue-demi/scripts/postinstall.js
generated
vendored
Normal file
19
uniapp04/node_modules/vue-demi/scripts/postinstall.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
const { switchVersion, loadModule } = require('./utils')
|
||||
|
||||
const Vue = loadModule('vue')
|
||||
|
||||
if (!Vue || typeof Vue.version !== 'string') {
|
||||
console.warn('[vue-demi] Vue is not found. Please run "npm install vue" to install.')
|
||||
}
|
||||
else if (Vue.version.startsWith('2.7.')) {
|
||||
switchVersion(2.7)
|
||||
}
|
||||
else if (Vue.version.startsWith('2.')) {
|
||||
switchVersion(2)
|
||||
}
|
||||
else if (Vue.version.startsWith('3.')) {
|
||||
switchVersion(3)
|
||||
}
|
||||
else {
|
||||
console.warn(`[vue-demi] Vue version v${Vue.version} is not supported.`)
|
||||
}
|
18
uniapp04/node_modules/vue-demi/scripts/switch-cli.js
generated
vendored
Normal file
18
uniapp04/node_modules/vue-demi/scripts/switch-cli.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
const { switchVersion } = require('./utils')
|
||||
|
||||
const version = process.argv[2]
|
||||
const vueEntry = process.argv[3] || 'vue'
|
||||
|
||||
if (version === '2.7') {
|
||||
switchVersion(2.7, vueEntry)
|
||||
console.log(`[vue-demi] Switched for Vue 2.7 (entry: "${vueEntry}")`)
|
||||
} else if (version === '2') {
|
||||
switchVersion(2, vueEntry)
|
||||
console.log(`[vue-demi] Switched for Vue 2 (entry: "${vueEntry}")`)
|
||||
} else if (version === '3') {
|
||||
switchVersion(3, vueEntry)
|
||||
console.log(`[vue-demi] Switched for Vue 3 (entry: "${vueEntry}")`)
|
||||
} else {
|
||||
console.warn(`[vue-demi] expecting version "2" or "2.7" or "3" but got "${version}"`)
|
||||
process.exit(1)
|
||||
}
|
62
uniapp04/node_modules/vue-demi/scripts/utils.js
generated
vendored
Normal file
62
uniapp04/node_modules/vue-demi/scripts/utils.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const dir = path.resolve(__dirname, '..', 'lib')
|
||||
|
||||
function loadModule(name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
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}'`)
|
||||
// unlink for pnpm, #92
|
||||
try {
|
||||
fs.unlinkSync(dest)
|
||||
} catch (error) { }
|
||||
fs.writeFileSync(dest, content, 'utf-8')
|
||||
}
|
||||
|
||||
function updateVue2API() {
|
||||
const ignoreList = ['version', 'default']
|
||||
const VCA = loadModule('@vue/composition-api')
|
||||
if (!VCA) {
|
||||
console.warn('[vue-demi] Composition API plugin is not found. Please run "npm install @vue/composition-api" to install.')
|
||||
return
|
||||
}
|
||||
|
||||
const exports = Object.keys(VCA).filter(i => !ignoreList.includes(i))
|
||||
|
||||
const esmPath = path.join(dir, 'index.mjs')
|
||||
let content = fs.readFileSync(esmPath, 'utf-8')
|
||||
|
||||
content = content.replace(
|
||||
/\/\*\*VCA-EXPORTS\*\*\/[\s\S]+\/\*\*VCA-EXPORTS\*\*\//m,
|
||||
`/**VCA-EXPORTS**/
|
||||
export { ${exports.join(', ')} } from '@vue/composition-api/dist/vue-composition-api.mjs'
|
||||
/**VCA-EXPORTS**/`
|
||||
)
|
||||
|
||||
fs.writeFileSync(esmPath, content, 'utf-8')
|
||||
|
||||
}
|
||||
|
||||
function switchVersion(version, vue) {
|
||||
copy('index.cjs', version, vue)
|
||||
copy('index.mjs', version, vue)
|
||||
copy('index.d.ts', version, vue)
|
||||
|
||||
if (version === 2)
|
||||
updateVue2API()
|
||||
}
|
||||
|
||||
|
||||
module.exports.loadModule = loadModule
|
||||
module.exports.switchVersion = switchVersion
|
Reference in New Issue
Block a user