| 94 | (traverse as any).default?.(ast, { |
| 95 | Program: { |
| 96 | exit(path: any) { |
| 97 | if (!mutated) return; |
| 98 | // Prepend namespace/default helpers if they were requested by transforms |
| 99 | const body = path.node.body as t.Statement[]; |
| 100 | const prepend: t.Statement[] = []; |
| 101 | if (!hasNSVNamespace) { |
| 102 | prepend.push(t.importDeclaration([t.importNamespaceSpecifier(t.identifier(nsVarName))], t.stringLiteral('nativescript-vue'))); |
| 103 | hasNSVNamespace = true; |
| 104 | } |
| 105 | if (!hasNSVDefaultVar) { |
| 106 | prepend.push( |
| 107 | t.variableDeclaration('const', [ |
| 108 | t.variableDeclarator( |
| 109 | t.identifier(defVarName), |
| 110 | t.logicalExpression( |
| 111 | '||', |
| 112 | // Prefer explicit default when present; fall back to namespace |
| 113 | t.memberExpression(t.identifier(nsVarName), t.identifier('default'), false), |
| 114 | t.identifier(nsVarName), |
| 115 | ), |
| 116 | ), |
| 117 | ]), |
| 118 | ); |
| 119 | hasNSVDefaultVar = true; |
| 120 | } |
| 121 | path.node.body = [...prepend, ...body]; |
| 122 | }, |
| 123 | }, |
| 124 | ImportDeclaration(path: any) { |
| 125 | const node: t.ImportDeclaration = path.node; |