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

refactor(cli): init auto import components options

上级 a7509f97
......@@ -328,6 +328,19 @@ function addPageUsingComponents (pagePath, usingComponents) {
// 存储自动组件
const autoComponentMap = {}
let lastUsingAutoImportComponentsJson = ''
process.UNI_AUTO_COMPONENTS = []
function initAutoImportComponents (usingAutoImportComponents = {}) {
const newUsingAutoImportComponentsJson = JSON.stringify(usingAutoImportComponents)
if (newUsingAutoImportComponentsJson !== lastUsingAutoImportComponentsJson) {
lastUsingAutoImportComponentsJson = newUsingAutoImportComponentsJson
process.UNI_AUTO_COMPONENTS = parseUsingAutoImportComponents(usingAutoImportComponents)
refreshAutoComponentMap()
}
}
/**
* UNI_AUTO_COMPONENTS 被更新,重新刷新 map
*/
......@@ -384,8 +397,8 @@ module.exports = {
getPagesJson,
parsePagesJson,
pagesJsonJsFileName,
getAutoComponents,
refreshAutoComponentMap,
getAutoComponents,
initAutoImportComponents,
addPageUsingComponents,
getUsingComponentsCode,
generateUsingComponentsCode,
......
......@@ -308,6 +308,12 @@ if (
}
}
const {
initAutoImportComponents
} = require('@dcloudio/uni-cli-shared/lib/pages')
initAutoImportComponents(pagesJsonObj.usingAutoImportComponents)
runByHBuilderX && console.log(`正在编译中...`)
module.exports = {
......
......@@ -18,8 +18,7 @@ const {
const {
pagesJsonJsFileName,
refreshAutoComponentMap,
parseUsingAutoImportComponents
initAutoImportComponents
} = require('@dcloudio/uni-cli-shared/lib/pages')
const parseStyle = require('./util').parseStyle
......@@ -33,17 +32,6 @@ function renameUsingComponents (jsonObj) {
return jsonObj
}
let lastUsingAutoImportComponentsJson = ''
function initAutoImportComponents (usingAutoImportComponents = {}) {
const newUsingAutoImportComponentsJson = JSON.stringify(usingAutoImportComponents)
if (newUsingAutoImportComponentsJson !== lastUsingAutoImportComponentsJson) {
lastUsingAutoImportComponentsJson = newUsingAutoImportComponentsJson
process.UNI_AUTO_COMPONENTS = parseUsingAutoImportComponents(usingAutoImportComponents)
refreshAutoComponentMap()
}
}
module.exports = function (content) {
this.cacheable && this.cacheable()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册