diff --git a/packages/macros/src/glimmer/ast-transform.ts b/packages/macros/src/glimmer/ast-transform.ts index 27b6652b4..67086fa30 100644 --- a/packages/macros/src/glimmer/ast-transform.ts +++ b/packages/macros/src/glimmer/ast-transform.ts @@ -72,7 +72,7 @@ export function makeFirstTransform(opts: FirstTransformParams) { name: '@embroider/macros/first', visitor: { - Template: { + [rootVisitorKey(env)]: { enter(node: any) { if (node.blockParams.length > 0) { scopeStack.push(node.blockParams); @@ -169,7 +169,7 @@ export function makeSecondTransform() { name: '@embroider/macros/second', visitor: { - Template: { + [rootVisitorKey(env)]: { enter(node: any) { if (node.blockParams.length > 0) { scopeStack.push(node.blockParams); @@ -294,3 +294,14 @@ function headOf(path: any) { return 'head' in path ? path.head : path.parts[0]; } + +/** + * Template is available in ember-source 3.17+ + * Program is deprecated in ember-source 5.9+ + */ +function rootVisitorKey(env: any) { + let hasTemplate = 'template' in env.syntax.builders; + let rootKey = hasTemplate ? 'Template' : 'Program'; + + return rootKey; +}