Skip to content

Commit

Permalink
fix: 解决开启 treeShaking 后 picker 组件无法使用的问题 fixed dcloudio#841
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Oct 12, 2019
1 parent 0b565cb commit 6acf9b7
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ const {
capitalize
} = require('./util')

const platformTags = ['audio', 'map', 'video', 'web-view', 'cover-view', 'cover-image']
const platformTags = ['audio', 'map', 'video', 'web-view', 'cover-view', 'cover-image', 'picker']

//input 在 pageHead 中有使用,resize-sensor 在很多组件中有使用,暂时直接加载
const autoloadTags = ['input', 'resize-sensor']
const autoloadTags = {
// input 在 pageHead 中有使用,resize-sensor 在很多组件中有使用,暂时直接加载
root: ['input', 'resize-sensor'],
other: {
picker: ['picker-view', 'picker-view-column']
}
}

module.exports = function updateComponents(tags) {
autoloadTags.forEach(tagName => {
autoloadTags.root.forEach(tagName => {
tags.add(tagName)
})
tags = [...tags]
Object.keys(autoloadTags.other).forEach(tagName => {
if (tags.includes(tagName)) {
tags.push(...autoloadTags.other[tagName])
}
})
const importsStr = tags.map(tagName => {
if (platformTags.indexOf(tagName) !== -1) {
return `import ${capitalize(camelize(tagName))} from 'uni-platform/view/components/${tagName}'`
Expand Down Expand Up @@ -44,4 +54,4 @@ ${componentsStr}

fs.writeFileSync(path.resolve(dir, 'components.js'), content, 'utf8')

}
}

0 comments on commit 6acf9b7

Please sign in to comment.