diff --git a/lib/mp-compiler/parse.js b/lib/mp-compiler/parse.js index c15cd7e..f701295 100644 --- a/lib/mp-compiler/parse.js +++ b/lib/mp-compiler/parse.js @@ -43,6 +43,26 @@ const configVisitor = { path.traverse(traverseConfigVisitor) path.remove() }, + + CallExpression: function (path) { + const { + metadata + } = path.hub.file + const { + importsMap + } = getImportsMap(metadata) + const calleeName = path.node.callee.name + if (calleeName !== 'Page') return; + const pageArg = path.node.arguments[0]; + if (!pageArg || pageArg.type !== 'CallExpression') { + return + } + const arg = pageArg.arguments[0]; + if (!arg) return; + const v = arg.type === 'Identifier' ? importsMap[arg.name] : importsMap['App'] + metadata.rootComponent = v; + }, + NewExpression: function (path) { const { metadata } = path.hub.file const { importsMap } = getImportsMap(metadata)