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

feat: add optionalChaining

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