提交 e7bc62b9 编写于 作者: fxy060608's avatar fxy060608

feat: add optionalChaining

上级 00f6fd88
......@@ -123,7 +123,9 @@ const PLATFORMS = {
} = getH5Options()
const to = path.join(assetsDir, `[name].${VUE_APP_INDEX_CSS_HASH}.[ext]`)
if (process.env.NODE_ENV === 'production') {
const templateContent = fs.readFileSync(template, { encoding: 'utf8' })
const templateContent = fs.readFileSync(template, {
encoding: 'utf8'
})
if (/\bVUE_APP_INDEX_CSS_HASH\b/.test(templateContent)) {
indexCssCopyOptions[0].to = to
}
......@@ -584,5 +586,18 @@ module.exports = {
},
getPlatformSass () {
return SASS
},
getBabelParserOptions () {
return {
sourceType: 'module',
plugins: [
'optionalChaining',
'typescript',
['decorators', {
decoratorsBeforeExport: true
}],
'classProperties'
]
}
}
}
}
......@@ -13,6 +13,10 @@ const {
jsPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
const {
getBabelParserOptions
} = require('@dcloudio/uni-cli-shared/lib/platform')
const {
updateUsingComponents
} = require('@dcloudio/uni-cli-shared/lib/cache')
......@@ -55,14 +59,14 @@ module.exports = function (content) {
const vuePagePath = path.resolve(process.env.UNI_INPUT_DIR, normalizePath(params.page) + '.vue')
if (!fs.existsSync(vuePagePath)) {
const nvuePagePath = path.resolve(process.env.UNI_INPUT_DIR, normalizePath(params.page) +
'.nvue')
'.nvue')
if (fs.existsSync(nvuePagePath)) {
ext = '.nvue'
}
}
}
return `
import Vue from 'vue'
import Vue from 'vue'
import Page from './${normalizePath(params.page)}${ext}'
createPage(Page)
`
......@@ -78,16 +82,7 @@ createPage(Page)
state: {
components
}
} = traverse(parser.parse(content, {
sourceType: 'module',
plugins: [
'typescript',
['decorators', {
decoratorsBeforeExport: true
}],
'classProperties'
]
}), {
} = traverse(parser.parse(content, getBabelParserOptions()), {
components: []
})
......
......@@ -10,6 +10,10 @@ const {
jsPreprocessOptions
} = require('@dcloudio/uni-cli-shared')
const {
getBabelParserOptions
} = require('@dcloudio/uni-cli-shared/lib/platform')
const {
updateUsingComponents
} = require('@dcloudio/uni-cli-shared/lib/cache')
......@@ -63,16 +67,7 @@ module.exports = function (content, map) {
state: {
components
}
} = traverse(parser.parse(content, {
sourceType: 'module',
plugins: [
'typescript',
['decorators', {
decoratorsBeforeExport: true
}],
'classProperties'
]
}), {
} = traverse(parser.parse(content, getBabelParserOptions()), {
type,
components: []
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册