Skip to content

Commit

Permalink
fix(cli): 修正对是否是 Taro 组件的判断,close #3751
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jul 10, 2019
1 parent 81d90ac commit 0db4742
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions packages/taro-cli/src/mini/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,8 @@ export function isFileToBeTaroComponent (
let isTaroComponent = false

traverse(ast, {
ClassDeclaration (astPath) {
astPath.traverse({
ClassMethod (astPath) {
if (astPath.get('key').isIdentifier({ name: 'render' })) {
astPath.traverse({
JSXElement () {
isTaroComponent = true
}
})
}
}
})
},

ClassExpression (astPath) {
astPath.traverse({
ClassMethod (astPath) {
if (astPath.get('key').isIdentifier({ name: 'render' })) {
astPath.traverse({
JSXElement () {
isTaroComponent = true
}
})
}
}
})
JSXElement (astPath) {
isTaroComponent = !!astPath.findParent(p => (p.isReturnStatement() || p.isArrowFunctionExpression()))
}
})

Expand Down

0 comments on commit 0db4742

Please sign in to comment.