Skip to content

Commit

Permalink
fix(RN): taro 编译 rn 时分包路径有问题 close #1610
Browse files Browse the repository at this point in the history
  • Loading branch information
Pines-Cheng committed Jan 8, 2019
1 parent fddff16 commit 2eaf122
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/taro-cli/src/rn/transformJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,16 @@ function getClassPropertyVisitor ({filePath, pages, iconPaths, isEntryFile}) {
const value = node.value
// if (key.name !== 'pages' || !t.isArrayExpression(value)) return
if (key.name === 'pages' && t.isArrayExpression(value)) {
// 分包
let root = ''
const rootNode = astPath.parent.properties.find(v => {
return v.key.name === 'root'
})
root = rootNode ? rootNode.value.value : ''

value.elements.forEach(v => {
pages.push(v.value)
const pagePath = `${root}/${v.value}`.replace(/\/{2,}/g, '/')
pages.push(pagePath.replace(/^\//, ''))
})
astPath.remove()
}
Expand Down

0 comments on commit 2eaf122

Please sign in to comment.