| | |
| | | const staticBlockPrivateId = generateUid(scope, privateNames); |
| | | privateNames.add(staticBlockPrivateId); |
| | | const staticBlockRef = t.privateName(t.identifier(staticBlockPrivateId)); |
| | | path.replaceWith(t.classPrivateProperty(staticBlockRef, template.expression.ast`(() => { ${path.node.body} })()`, [], true)); |
| | | let replacement; |
| | | const blockBody = path.node.body; |
| | | |
| | | if (blockBody.length === 1 && t.isExpressionStatement(blockBody[0])) { |
| | | replacement = blockBody[0].expression; |
| | | } else { |
| | | replacement = template.expression.ast`(() => { ${blockBody} })()`; |
| | | } |
| | | |
| | | path.replaceWith(t.classPrivateProperty(staticBlockRef, replacement, [], true)); |
| | | } |
| | | } |
| | | |