diff --git a/packages/taro-cli/src/mini/component.ts b/packages/taro-cli/src/mini/component.ts index 79b982430054..6aad6483e192 100644 --- a/packages/taro-cli/src/mini/component.ts +++ b/packages/taro-cli/src/mini/component.ts @@ -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())) } })