Skip to content

Commit

Permalink
feat(pre): support uniVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Sep 9, 2023
1 parent c057f9e commit 8d1ec39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/uni-cli-shared/lib/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {

const defaultContext = {}

defaultContext.uniVersion = parseFloat(process.env.UNI_COMPILER_VERSION) || 0

const userDefineKeys = Object.keys(userDefines)

platforms
Expand Down
15 changes: 8 additions & 7 deletions packages/vue-cli-plugin-uni/lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}

// 输出编译器版本等信息
const pagesPkg = require('@dcloudio/webpack-uni-pages-loader/package.json')
process.env.UNI_COMPILER_VERSION = ''
if (pagesPkg) {
process.env.UNI_COMPILER_VERSION = pagesPkg['uni-app'].compilerVersion
}

const defaultInputDir = 'src'
if (process.env.UNI_INPUT_DIR && process.env.UNI_INPUT_DIR.indexOf('./') === 0) {
process.env.UNI_INPUT_DIR = path.resolve(process.cwd(), process.env.UNI_INPUT_DIR)
Expand Down Expand Up @@ -461,12 +468,6 @@ const warningMsg =

const needWarning = !platformOptions.usingComponents || usingComponentsAbsent
let hasNVue = false
// 输出编译器版本等信息
const pagesPkg = require('@dcloudio/webpack-uni-pages-loader/package.json')
process.env.UNI_COMPILER_VERSION = ''
if (pagesPkg) {
process.env.UNI_COMPILER_VERSION = pagesPkg['uni-app'].compilerVersion
}
const compileModeUrl = 'https://ask.dcloud.net.cn/article/36074'
if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
const compileMode = (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex')
Expand Down Expand Up @@ -625,4 +626,4 @@ runByHBuilderX && console.log(uniI18n.__('compiling'))

module.exports = {
manifestPlatformOptions: platformOptions
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ function getTestTemplate (test) {
test = test.trim()

// force single equals replacement
test = test.replace(/([^=!])=([^=])/g, '$1==$2')
// fixed by xxxxxx 不替换,会影响 >= 等判断
// test = test.replace(/([^=!])=([^=])/g, '$1==$2');
//fixed by xxxxxx
test = test.replace(/-/g,'_')
/* eslint-disable no-new-func */
Expand Down

0 comments on commit 8d1ec39

Please sign in to comment.