Skip to content

Commit

Permalink
fix(taroize): export default 和装饰器混用导致 babel 解析失败
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Dec 3, 2018
1 parent bff2b14 commit 146e6c6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/taroize/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function parseScript (
if (componentType !== 'App') {
classDecl.decorators = [buildDecorator(componentType)]
}
path.insertAfter(t.exportDefaultDeclaration(classDecl))
path.insertAfter(t.exportDefaultDeclaration(t.identifier(defaultClassName)))
path.remove()
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/taroize/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function buildRender (
if (stateKeys.length) {
const stateDecl = t.variableDeclaration('const', [
t.variableDeclarator(
t.objectPattern(stateKeys.map(s =>
t.objectPattern(Array.from(new Set(stateKeys)).map(s =>
t.objectProperty(t.identifier(s), t.identifier(s))
) as any),
t.memberExpression(t.thisExpression(), t.identifier('state'))
Expand All @@ -38,7 +38,7 @@ export function buildRender (
}

if (propsKeys.length) {
let patterns = t.objectPattern(propsKeys.map(s =>
let patterns = t.objectPattern(Array.from(new Set(propsKeys)).map(s =>
t.objectProperty(t.identifier(s), t.identifier(s))
) as any)
if (typeof templateType === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion packages/taroize/src/wxml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function transformLoop (
const attrs = jsx.get('openingElement').get('attributes').map(a => a.node)
const wxForItem = attrs.find(a => a.name.name === WX_FOR_ITEM)
const hasSinglewxForItem = wxForItem && wxForItem.value && t.isJSXExpressionContainer(wxForItem.value)
if (hasSinglewxForItem || name === WX_FOR) {
if (hasSinglewxForItem || name === WX_FOR || name === 'wx:for-items') {
if (!value || !t.isJSXExpressionContainer(value)) {
throw new Error('wx:for 的值必须使用 "{{}}" 包裹')
}
Expand Down

0 comments on commit 146e6c6

Please sign in to comment.