提交 983e3443 编写于 作者: Q qiang

fix(mp): __sfc_main.components = Object.assign... #3748

上级 11b3ae74
......@@ -163,6 +163,20 @@ global['__wxVueOptions'] = {
}
])
assertCodegen(`
import CustomButton from './custom-button.vue'
const __sfc_main = {}
__sfc_main.components = Object.assign({
'custom-button': CustomButton
}, __sfc_main.components)
export default __sfc_main
`,
[{
name: 'custom-button',
value: 'CustomButton',
source: './custom-button.vue'
}])
assertCodegen(
`import myButton from '@/components/my-button/my-button.vue';
export default {
......@@ -311,4 +325,4 @@ global['__wxVueOptions'] = {
source: '@/components/tab-nvue/mediaList.vue'
}], false)
})
})
})
......@@ -83,10 +83,15 @@ function handleIdentifier ({
if (t.isVariableDeclarator(declaration)) {
identifier = declaration.id
declaration = declaration.init
} else if (t.isExpressionStatement(declaration)) {
} else if (t.isExpressionStatement(declaration) && t.isAssignmentExpression(declaration.expression)) {
identifier = declaration.expression.left
declaration = declaration.expression.right
}
// __sfc_main.components = Object.assign({CustomButton}, __sfc_main.components);
if (t.isMemberExpression(identifier) && identifier.object.name === name && identifier.property.name === 'components' && t.isCallExpression(declaration) && declaration.arguments.length === 2 && t.isObjectExpression(declaration.arguments[0])) {
handleComponentsObjectExpression(declaration.arguments[0], path, state, true)
return
}
if (identifier.name === name) {
if (t.isCallExpression(declaration) &&
t.isMemberExpression(declaration.callee) &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册